diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8dda4d32e0835..25e959311b255 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -312,16 +312,6 @@ namespace ts { let constraintDepth = 0; let currentNode: Node | undefined; - interface ExpensiveStatement { - node: Node; - typeDelta: number; - symbolDelta: number; - } - - let ignoreExpensiveStatement = true; - const maxExpensiveStatementCount = 5; - const expensiveStatements: ExpensiveStatement[] = []; - const emptySymbols = createSymbolTable(); const arrayVariances = [VarianceFlags.Covariant]; @@ -338,6 +328,16 @@ namespace ts { const keyofStringsOnly = !!compilerOptions.keyofStringsOnly; const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral; + interface ExpensiveStatement { + node: Node; + typeDelta: number; + symbolDelta: number; + } + + let ignoreExpensiveStatement = true; + const maxExpensiveStatementCount = compilerOptions.expensiveStatements ?? 0; + const expensiveStatements: ExpensiveStatement[] = []; + const emitResolver = createResolver(); const nodeBuilder = createNodeBuilder(); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d286eaf3118a0..9aa6c62d3778c 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -218,6 +218,12 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, + { + name: "expensiveStatements", + type: "number", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Heuristically_reports_statements_that_appear_to_contribute_disproportionately_to_check_time + }, ]; /* @internal */ diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f53ef4cb1d35c..64fab3bd5caad 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4388,6 +4388,10 @@ "category": "Error", "code": 6231 }, + "Heuristically reports statements that appear to contribute disproportionately to check time.": { + "category": "Message", + "code": 6232 + }, "Projects to reference": { "category": "Message", @@ -5645,7 +5649,7 @@ "category": "Message", "code": 95116 }, - + "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": { "category": "Error", "code": 18004 @@ -5733,5 +5737,9 @@ "An optional chain cannot contain private identifiers.": { "category": "Error", "code": 18030 + }, + "Checking this statement may result in the creation of as many as {0} types and {1} symbols.": { + "category": "Warning", + "code": 19000 } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3add4e354ae28..9f399bdabf1b5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5152,6 +5152,7 @@ namespace ts { downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; + /*@internal*/ expensiveStatements?: number; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; /*@internal*/generateCpuProfile?: string;