Skip to content

Commit 5c5e149

Browse files
committed
Take the number of statements to report from a switch
1 parent dca2972 commit 5c5e149

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,6 @@ namespace ts {
317317
let constraintDepth = 0;
318318
let currentNode: Node | undefined;
319319

320-
interface ExpensiveStatement {
321-
node: Node;
322-
typeDelta: number;
323-
symbolDelta: number;
324-
}
325-
326-
let ignoreExpensiveStatement = true;
327-
const maxExpensiveStatementCount = 5;
328-
const expensiveStatements: ExpensiveStatement[] = [];
329-
330320
const emptySymbols = createSymbolTable();
331321
const arrayVariances = [VarianceFlags.Covariant];
332322

@@ -343,6 +333,16 @@ namespace ts {
343333
const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
344334
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
345335

336+
interface ExpensiveStatement {
337+
node: Node;
338+
typeDelta: number;
339+
symbolDelta: number;
340+
}
341+
342+
let ignoreExpensiveStatement = true;
343+
const maxExpensiveStatementCount = compilerOptions.expensiveStatements ?? 0;
344+
const expensiveStatements: ExpensiveStatement[] = [];
345+
346346
const emitResolver = createResolver();
347347
const nodeBuilder = createNodeBuilder();
348348

src/compiler/commandLineParser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ namespace ts {
219219
category: Diagnostics.Advanced_Options,
220220
description: Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
221221
},
222+
{
223+
name: "expensiveStatements",
224+
type: "number",
225+
category: Diagnostics.Advanced_Options,
226+
description: Diagnostics.Heuristically_reports_statements_that_appear_to_contribute_disproportionately_to_check_time
227+
},
222228
];
223229

224230
/* @internal */

src/compiler/diagnosticMessages.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4473,6 +4473,10 @@
44734473
"category": "Message",
44744474
"code": 6235
44754475
},
4476+
"Heuristically reports statements that appear to contribute disproportionately to check time.": {
4477+
"category": "Message",
4478+
"code": 6236
4479+
},
44764480

44774481
"Projects to reference": {
44784482
"category": "Message",
@@ -5975,5 +5979,10 @@
59755979
"Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name.": {
59765980
"category": "Error",
59775981
"code": 18035
5982+
},
5983+
5984+
"Checking this statement may result in the creation of as many as {0} types and {1} symbols.": {
5985+
"category": "Warning",
5986+
"code": 19000
59785987
}
59795988
}

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5674,6 +5674,7 @@ namespace ts {
56745674
downlevelIteration?: boolean;
56755675
emitBOM?: boolean;
56765676
emitDecoratorMetadata?: boolean;
5677+
/*@internal*/ expensiveStatements?: number;
56775678
experimentalDecorators?: boolean;
56785679
forceConsistentCasingInFileNames?: boolean;
56795680
/*@internal*/generateCpuProfile?: string;

0 commit comments

Comments
 (0)