-
-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix missing error output in root project with project references #937
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import * as path from 'path'; | ||
import * as ts from 'typescript'; | ||
import * as webpack from 'webpack'; | ||
|
||
import * as constants from './constants'; | ||
|
@@ -12,6 +13,7 @@ import { | |
} from './interfaces'; | ||
import { | ||
collectAllDependants, | ||
ensureProgram, | ||
formatErrors, | ||
isUsingProjectReferences | ||
} from './utils'; | ||
|
@@ -174,8 +176,6 @@ function provideErrorsToWebpack( | |
) { | ||
const { | ||
compiler, | ||
program, | ||
languageService, | ||
files, | ||
loaderOptions, | ||
compilerOptions, | ||
|
@@ -187,13 +187,14 @@ function provideErrorsToWebpack( | |
? constants.dtsTsTsxJsJsxRegex | ||
: constants.dtsTsTsxRegex; | ||
|
||
// I’m pretty sure this will never be undefined here | ||
const program = ensureProgram(instance); | ||
for (const filePath of filesToCheckForErrors.keys()) { | ||
if (filePath.match(filePathRegex) === null) { | ||
continue; | ||
} | ||
|
||
const sourceFile = | ||
program === undefined ? undefined : program.getSourceFile(filePath); | ||
const sourceFile = program && program.getSourceFile(filePath); | ||
|
||
// If the source file is undefined, that probably means it’s actually part of an unbuilt project reference, | ||
// which will have already produced a more useful error than the one we would get by proceeding here. | ||
|
@@ -203,16 +204,17 @@ function provideErrorsToWebpack( | |
continue; | ||
} | ||
|
||
const errors = | ||
program === undefined | ||
? [ | ||
...languageService!.getSyntacticDiagnostics(filePath), | ||
...languageService!.getSemanticDiagnostics(filePath) | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity, can you recall why we used to alternate between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify, these lines weren't the issue, I just updated them for consistency with the changes above, which were the issue.
TL;DR: these lines are basically equivalent because of |
||
: [ | ||
...program.getSyntacticDiagnostics(sourceFile), | ||
...program.getSemanticDiagnostics(sourceFile) | ||
]; | ||
const errors: ts.Diagnostic[] = []; | ||
if (program && sourceFile) { | ||
errors.push( | ||
...program!.getSyntacticDiagnostics(sourceFile), | ||
...program! | ||
.getSemanticDiagnostics(sourceFile) | ||
// Output file has not been built from source file - this message is redundant with | ||
// program.getOptionsDiagnostics() separately added in instances.ts | ||
.filter(({ code }) => code !== 6305) | ||
); | ||
} | ||
if (errors.length > 0) { | ||
const fileWithError = files.get(filePath) || otherFiles.get(filePath); | ||
filesWithErrors.set(filePath, fileWithError!); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I trust you dude 😁