@@ -106,12 +106,22 @@ export interface LoggingHost {
106
106
107
107
/** @internal */
108
108
export namespace Debug {
109
- /* eslint-disable prefer-const */
110
- let currentAssertionLevel = AssertionLevel . None ;
111
- export let currentLogLevel = LogLevel . Warning ;
112
- export let isDebugging = false ;
113
- export let loggingHost : LoggingHost | undefined ;
114
- /* eslint-enable prefer-const */
109
+ // Why var? It avoids TDZ checks in the runtime which can be costly.
110
+ // See: https://github.com/microsoft/TypeScript/issues/52924
111
+ // TODO(jakebailey): restore to let/const once Debug is no longer a namespace.
112
+ /* eslint-disable no-var */
113
+ var currentAssertionLevel = AssertionLevel . None ;
114
+ export var currentLogLevel = LogLevel . Warning ;
115
+ export var isDebugging = false ;
116
+ export var loggingHost : LoggingHost | undefined ;
117
+
118
+ var enumMemberCache = new Map < any , SortedReadonlyArray < [ number , string ] > > ( ) ;
119
+
120
+ var isDebugInfoEnabled = false ;
121
+
122
+ var flowNodeProto : FlowNodeBase | undefined ;
123
+ var nodeArrayProto : NodeArray < Node > | undefined ;
124
+ /* eslint-enable no-var */
115
125
116
126
export function shouldLog ( level : LogLevel ) : boolean {
117
127
return currentLogLevel <= level ;
@@ -373,7 +383,6 @@ export namespace Debug {
373
383
return value . toString ( ) ;
374
384
}
375
385
376
- const enumMemberCache = new Map < any , SortedReadonlyArray < [ number , string ] > > ( ) ;
377
386
378
387
function getEnumMembers ( enumObject : any ) {
379
388
// Assuming enum objects do not change at runtime, we can cache the enum members list
@@ -457,9 +466,7 @@ export namespace Debug {
457
466
return formatEnum ( facts , ( ts as any ) . TypeFacts , /*isFlags*/ true ) ;
458
467
}
459
468
460
- let isDebugInfoEnabled = false ;
461
469
462
- let flowNodeProto : FlowNodeBase | undefined ;
463
470
464
471
function attachFlowNodeDebugInfoWorker ( flowNode : FlowNodeBase ) {
465
472
if ( ! ( "__debugFlowFlags" in flowNode ) ) { // eslint-disable-line local/no-in-operator
@@ -508,7 +515,7 @@ export namespace Debug {
508
515
}
509
516
}
510
517
511
- let nodeArrayProto : NodeArray < Node > | undefined ;
518
+
512
519
513
520
function attachNodeArrayDebugInfoWorker ( array : NodeArray < Node > ) {
514
521
if ( ! ( "__tsDebuggerDisplay" in array ) ) { // eslint-disable-line local/no-in-operator
0 commit comments