Skip to content

Commit

Permalink
Take the number of statements to report from a switch
Browse files Browse the repository at this point in the history
  • Loading branch information
amcasey committed Apr 4, 2020
1 parent 5162827 commit 0da8143
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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();

Expand Down
6 changes: 6 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 9 additions & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5152,6 +5152,7 @@ namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
/*@internal*/ expensiveStatements?: number;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
/*@internal*/generateCpuProfile?: string;
Expand Down

0 comments on commit 0da8143

Please sign in to comment.