mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Merge pull request #26289 from amcasey/LibSuggestions
Don't compute suggestion diagnostics for lib files
This commit is contained in:
@@ -314,6 +314,10 @@ namespace ts {
|
||||
return node && getTypeArgumentConstraint(node);
|
||||
},
|
||||
getSuggestionDiagnostics: (file, ct) => {
|
||||
if (skipTypeChecking(file, compilerOptions)) {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
let diagnostics: DiagnosticWithLocation[] | undefined;
|
||||
try {
|
||||
// Record the cancellation token so it can be checked later on during checkSourceElement.
|
||||
@@ -26887,10 +26891,7 @@ namespace ts {
|
||||
function checkSourceFileWorker(node: SourceFile) {
|
||||
const links = getNodeLinks(node);
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
// If skipLibCheck is enabled, skip type checking if file is a declaration file.
|
||||
// If skipDefaultLibCheck is enabled, skip type checking if file contains a
|
||||
// '/// <reference no-default-lib="true"/>' directive.
|
||||
if (compilerOptions.skipLibCheck && node.isDeclarationFile || compilerOptions.skipDefaultLibCheck && node.hasNoDefaultLib) {
|
||||
if (skipTypeChecking(node, compilerOptions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1476,10 +1476,7 @@ namespace ts {
|
||||
|
||||
function getSemanticDiagnosticsForFileNoCache(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] | undefined {
|
||||
return runWithCancellationToken(() => {
|
||||
// If skipLibCheck is enabled, skip reporting errors if file is a declaration file.
|
||||
// If skipDefaultLibCheck is enabled, skip reporting errors if file contains a
|
||||
// '/// <reference no-default-lib="true"/>' directive.
|
||||
if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) {
|
||||
if (skipTypeChecking(sourceFile, options)) {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -8225,4 +8225,11 @@ namespace ts {
|
||||
// Include the `<>`
|
||||
return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
|
||||
}
|
||||
|
||||
export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOptions) {
|
||||
// If skipLibCheck is enabled, skip reporting errors if file is a declaration file.
|
||||
// If skipDefaultLibCheck is enabled, skip reporting errors if file contains a
|
||||
// '/// <reference no-default-lib="true"/>' directive.
|
||||
return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user