Skip to content

Commit 0da8143

Browse files
committed
Take the number of statements to report from a switch
1 parent 5162827 commit 0da8143

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,6 @@ namespace ts {
312312
let constraintDepth = 0;
313313
let currentNode: Node | undefined;
314314

315-
interface ExpensiveStatement {
316-
node: Node;
317-
typeDelta: number;
318-
symbolDelta: number;
319-
}
320-
321-
let ignoreExpensiveStatement = true;
322-
const maxExpensiveStatementCount = 5;
323-
const expensiveStatements: ExpensiveStatement[] = [];
324-
325315
const emptySymbols = createSymbolTable();
326316
const arrayVariances = [VarianceFlags.Covariant];
327317

@@ -338,6 +328,16 @@ namespace ts {
338328
const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
339329
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
340330

331+
interface ExpensiveStatement {
332+
node: Node;
333+
typeDelta: number;
334+
symbolDelta: number;
335+
}
336+
337+
let ignoreExpensiveStatement = true;
338+
const maxExpensiveStatementCount = compilerOptions.expensiveStatements ?? 0;
339+
const expensiveStatements: ExpensiveStatement[] = [];
340+
341341
const emitResolver = createResolver();
342342
const nodeBuilder = createNodeBuilder();
343343

src/compiler/commandLineParser.ts

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

223229
/* @internal */

src/compiler/diagnosticMessages.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4388,6 +4388,10 @@
43884388
"category": "Error",
43894389
"code": 6231
43904390
},
4391+
"Heuristically reports statements that appear to contribute disproportionately to check time.": {
4392+
"category": "Message",
4393+
"code": 6232
4394+
},
43914395

43924396
"Projects to reference": {
43934397
"category": "Message",
@@ -5645,7 +5649,7 @@
56455649
"category": "Message",
56465650
"code": 95116
56475651
},
5648-
5652+
56495653
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
56505654
"category": "Error",
56515655
"code": 18004
@@ -5733,5 +5737,9 @@
57335737
"An optional chain cannot contain private identifiers.": {
57345738
"category": "Error",
57355739
"code": 18030
5740+
},
5741+
"Checking this statement may result in the creation of as many as {0} types and {1} symbols.": {
5742+
"category": "Warning",
5743+
"code": 19000
57365744
}
57375745
}

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5152,6 +5152,7 @@ namespace ts {
51525152
downlevelIteration?: boolean;
51535153
emitBOM?: boolean;
51545154
emitDecoratorMetadata?: boolean;
5155+
/*@internal*/ expensiveStatements?: number;
51555156
experimentalDecorators?: boolean;
51565157
forceConsistentCasingInFileNames?: boolean;
51575158
/*@internal*/generateCpuProfile?: string;

0 commit comments

Comments
 (0)