Skip to content

Commit 2373db9

Browse files
committed
Ignore expensive statements in .d.ts files
...rather than just dropping the first one, now that .d.ts file checking is front-loaded.
1 parent 67edefe commit 2373db9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ namespace ts {
333333
const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
334334
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
335335

336-
let ignoreExpensiveStatement = true;
336+
let checkingDtsFile: boolean;
337337
const maxExpensiveStatementCount = compilerOptions.expensiveStatements ?? 0;
338338
const expensiveStatements: ExpensiveStatement[] = [];
339339

@@ -35630,12 +35630,9 @@ namespace ts {
3563035630

3563135631
checkSourceElementWorker(node);
3563235632

35633-
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement) {
35634-
if (ignoreExpensiveStatement) {
35635-
// The first statement is unfairly blamed for a lot of lib types
35636-
ignoreExpensiveStatement = false;
35637-
}
35638-
else {
35633+
// Never report expensive statements in .d.ts files
35634+
if (!checkingDtsFile) {
35635+
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement) {
3563935636
const typeDelta = typeCount - oldTypeCount;
3564035637
const symbolDelta = symbolCount - oldSymbolCount;
3564135638
const record = { node, typeDelta, symbolDelta };
@@ -35974,10 +35971,12 @@ namespace ts {
3597435971
}
3597535972

3597635973
function checkSourceFile(node: SourceFile) {
35974+
checkingDtsFile = fileExtensionIs(node.path, Extension.Dts);
3597735975
performance.mark("beforeCheck");
3597835976
checkSourceFileWorker(node);
3597935977
performance.mark("afterCheck");
3598035978
performance.measure("Check", "beforeCheck", "afterCheck");
35979+
checkingDtsFile = false;
3598135980
}
3598235981

3598335982
function unusedIsError(kind: UnusedKind, isAmbient: boolean): boolean {

0 commit comments

Comments
 (0)