mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
don't emit "unused @ts-expect-error" in unchecked js files (#40046)
* don't emit unused ts-expect-error in unchecked js files * simplify code
This commit is contained in:
@@ -1747,13 +1747,13 @@ namespace ts {
|
||||
const bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
|
||||
const checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
|
||||
|
||||
return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
|
||||
return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
|
||||
});
|
||||
}
|
||||
|
||||
function getMergedBindAndCheckDiagnostics(sourceFile: SourceFile, ...allDiagnostics: (readonly Diagnostic[] | undefined)[]) {
|
||||
function getMergedBindAndCheckDiagnostics(sourceFile: SourceFile, includeBindAndCheckDiagnostics: boolean, ...allDiagnostics: (readonly Diagnostic[] | undefined)[]) {
|
||||
const flatDiagnostics = flatten(allDiagnostics);
|
||||
if (!sourceFile.commentDirectives?.length) {
|
||||
if (!includeBindAndCheckDiagnostics || !sourceFile.commentDirectives?.length) {
|
||||
return flatDiagnostics;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user