Skip to content

Commit 9d1f049

Browse files
committed
Take the number of statements to report from a switch
1 parent 8d2511a commit 9d1f049

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
@@ -315,16 +315,6 @@ namespace ts {
315315
let constraintDepth = 0;
316316
let currentNode: Node | undefined;
317317

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

@@ -341,6 +331,16 @@ namespace ts {
341331
const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
342332
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
343333

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

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
@@ -4420,6 +4420,10 @@
44204420
"category": "Error",
44214421
"code": 6234
44224422
},
4423+
"Heuristically reports statements that appear to contribute disproportionately to check time.": {
4424+
"category": "Message",
4425+
"code": 6235
4426+
},
44234427

44244428
"Projects to reference": {
44254429
"category": "Message",
@@ -5833,5 +5837,10 @@
58335837
"Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.": {
58345838
"category": "Error",
58355839
"code": 18033
5840+
},
5841+
5842+
"Checking this statement may result in the creation of as many as {0} types and {1} symbols.": {
5843+
"category": "Warning",
5844+
"code": 19000
58365845
}
58375846
}

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5160,6 +5160,7 @@ namespace ts {
51605160
downlevelIteration?: boolean;
51615161
emitBOM?: boolean;
51625162
emitDecoratorMetadata?: boolean;
5163+
/*@internal*/ expensiveStatements?: number;
51635164
experimentalDecorators?: boolean;
51645165
forceConsistentCasingInFileNames?: boolean;
51655166
/*@internal*/generateCpuProfile?: string;

0 commit comments

Comments
 (0)