Skip to content

Commit 8ef7ced

Browse files
authored
Merge pull request #26289 from amcasey/LibSuggestions
Don't compute suggestion diagnostics for lib files
2 parents ad4403e + daccc97 commit 8ef7ced

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ namespace ts {
314314
return node && getTypeArgumentConstraint(node);
315315
},
316316
getSuggestionDiagnostics: (file, ct) => {
317+
if (skipTypeChecking(file, compilerOptions)) {
318+
return emptyArray;
319+
}
320+
317321
let diagnostics: DiagnosticWithLocation[] | undefined;
318322
try {
319323
// Record the cancellation token so it can be checked later on during checkSourceElement.
@@ -26887,10 +26891,7 @@ namespace ts {
2688726891
function checkSourceFileWorker(node: SourceFile) {
2688826892
const links = getNodeLinks(node);
2688926893
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
26890-
// If skipLibCheck is enabled, skip type checking if file is a declaration file.
26891-
// If skipDefaultLibCheck is enabled, skip type checking if file contains a
26892-
// '/// <reference no-default-lib="true"/>' directive.
26893-
if (compilerOptions.skipLibCheck && node.isDeclarationFile || compilerOptions.skipDefaultLibCheck && node.hasNoDefaultLib) {
26894+
if (skipTypeChecking(node, compilerOptions)) {
2689426895
return;
2689526896
}
2689626897

src/compiler/program.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,10 +1476,7 @@ namespace ts {
14761476

14771477
function getSemanticDiagnosticsForFileNoCache(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] | undefined {
14781478
return runWithCancellationToken(() => {
1479-
// If skipLibCheck is enabled, skip reporting errors if file is a declaration file.
1480-
// If skipDefaultLibCheck is enabled, skip reporting errors if file contains a
1481-
// '/// <reference no-default-lib="true"/>' directive.
1482-
if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) {
1479+
if (skipTypeChecking(sourceFile, options)) {
14831480
return emptyArray;
14841481
}
14851482

src/compiler/utilities.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8225,4 +8225,11 @@ namespace ts {
82258225
// Include the `<>`
82268226
return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
82278227
}
8228+
8229+
export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOptions) {
8230+
// If skipLibCheck is enabled, skip reporting errors if file is a declaration file.
8231+
// If skipDefaultLibCheck is enabled, skip reporting errors if file contains a
8232+
// '/// <reference no-default-lib="true"/>' directive.
8233+
return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib;
8234+
}
82288235
}

0 commit comments

Comments
 (0)