Skip to content
Closed
Prev Previous commit
Next Next commit
Ignore expensive statements in .d.ts files
...rather than just dropping the first one, now that .d.ts file checking
is front-loaded.
  • Loading branch information
amcasey committed Aug 4, 2020
commit 3ddf1ff608ca1ad6c6e8fdbd99a0b6f7030a751c
13 changes: 6 additions & 7 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ namespace ts {
const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;

let ignoreExpensiveStatement = true;
let checkingDtsFile: boolean;
const maxExpensiveStatementCount = compilerOptions.expensiveStatements ?? 0;
const expensiveStatements: ExpensiveStatement[] = [];

Expand Down Expand Up @@ -35667,12 +35667,9 @@ namespace ts {

checkSourceElementWorker(node);

if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement) {
if (ignoreExpensiveStatement) {
// The first statement is unfairly blamed for a lot of lib types
ignoreExpensiveStatement = false;
}
else {
// Never report expensive statements in .d.ts files
if (!checkingDtsFile) {
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement) {
const typeDelta = typeCount - oldTypeCount;
const symbolDelta = symbolCount - oldSymbolCount;
const record = { node, typeDelta, symbolDelta };
Expand Down Expand Up @@ -36011,10 +36008,12 @@ namespace ts {
}

function checkSourceFile(node: SourceFile) {
checkingDtsFile = fileExtensionIs(node.path, Extension.Dts);
performance.mark("beforeCheck");
checkSourceFileWorker(node);
performance.mark("afterCheck");
performance.measure("Check", "beforeCheck", "afterCheck");
checkingDtsFile = false;
}

function unusedIsError(kind: UnusedKind, isAmbient: boolean): boolean {
Expand Down