@@ -110,12 +110,22 @@ export interface LoggingHost {
110
110
111
111
/** @internal */
112
112
export namespace Debug {
113
- /* eslint-disable prefer-const */
114
- let currentAssertionLevel = AssertionLevel . None ;
115
- export let currentLogLevel = LogLevel . Warning ;
116
- export let isDebugging = false ;
117
- export let loggingHost : LoggingHost | undefined ;
118
- /* eslint-enable prefer-const */
113
+ // Why var? It avoids TDZ checks in the runtime which can be costly.
114
+ // See: https://github.com/microsoft/TypeScript/issues/52924
115
+ // TODO(jakebailey): restore to let/const once Debug is no longer a namespace.
116
+ /* eslint-disable no-var */
117
+ var currentAssertionLevel = AssertionLevel . None ;
118
+ export var currentLogLevel = LogLevel . Warning ;
119
+ export var isDebugging = false ;
120
+ export var loggingHost : LoggingHost | undefined ;
121
+
122
+ var enumMemberCache = new Map < any , SortedReadonlyArray < [ number , string ] > > ( ) ;
123
+
124
+ var isDebugInfoEnabled = false ;
125
+
126
+ var flowNodeProto : FlowNodeBase | undefined ;
127
+ var nodeArrayProto : NodeArray < Node > | undefined ;
128
+ /* eslint-enable no-var */
119
129
120
130
type AssertionKeys = MatchingKeys < typeof Debug , AnyFunction > ;
121
131
@@ -408,7 +418,6 @@ export namespace Debug {
408
418
return value . toString ( ) ;
409
419
}
410
420
411
- const enumMemberCache = new Map < any , SortedReadonlyArray < [ number , string ] > > ( ) ;
412
421
413
422
function getEnumMembers ( enumObject : any ) {
414
423
// Assuming enum objects do not change at runtime, we can cache the enum members list
@@ -496,9 +505,7 @@ export namespace Debug {
496
505
return formatEnum ( facts , ( ts as any ) . TypeFacts , /*isFlags*/ true ) ;
497
506
}
498
507
499
- let isDebugInfoEnabled = false ;
500
508
501
- let flowNodeProto : FlowNodeBase | undefined ;
502
509
503
510
function attachFlowNodeDebugInfoWorker ( flowNode : FlowNodeBase ) {
504
511
if ( ! ( "__debugFlowFlags" in flowNode ) ) { // eslint-disable-line local/no-in-operator
@@ -547,8 +554,6 @@ export namespace Debug {
547
554
}
548
555
}
549
556
550
- let nodeArrayProto : NodeArray < Node > | undefined ;
551
-
552
557
function attachNodeArrayDebugInfoWorker ( array : NodeArray < Node > ) {
553
558
if ( ! ( "__tsDebuggerDisplay" in array ) ) { // eslint-disable-line local/no-in-operator
554
559
Object . defineProperties ( array , {
0 commit comments