File tree 1 file changed +10
-2
lines changed 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -117,22 +117,30 @@ namespace ts {
117
117
declare const Map : MapConstructor | undefined ;
118
118
declare const Set : SetConstructor | undefined ;
119
119
120
+ const globals = typeof globalThis !== "undefined" ? globalThis
121
+ : typeof global !== "undefined" ? global
122
+ // @ts -ignore
123
+ : typeof window !== "undefined" ? window
124
+ : undefined ;
125
+
120
126
/**
121
127
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
122
128
*/
123
129
export function tryGetNativeMap ( ) : MapConstructor | undefined {
124
130
// Internet Explorer's Map doesn't support iteration, so don't use it.
131
+ const gMap = globals . Map ;
125
132
// eslint-disable-next-line no-in-operator
126
- return typeof Map !== "undefined" && "entries" in Map . prototype && new Map ( [ [ 0 , 0 ] ] ) . size === 1 ? Map : undefined ;
133
+ return typeof gMap !== "undefined" && "entries" in gMap . prototype && new gMap ( [ [ 0 , 0 ] ] ) . size === 1 ? gMap : undefined ;
127
134
}
128
135
129
136
/**
130
137
* Returns the native Set implementation if it is available and compatible (i.e. supports iteration).
131
138
*/
132
139
export function tryGetNativeSet ( ) : SetConstructor | undefined {
133
140
// Internet Explorer's Set doesn't support iteration, so don't use it.
141
+ const gSet = globals . Set ;
134
142
// eslint-disable-next-line no-in-operator
135
- return typeof Set !== "undefined" && "entries" in Set . prototype && new Set ( [ 0 ] ) . size === 1 ? Set : undefined ;
143
+ return typeof gSet !== "undefined" && "entries" in gSet . prototype && new gSet ( [ 0 ] ) . size === 1 ? gSet : undefined ;
136
144
}
137
145
}
138
146
You can’t perform that action at this time.
0 commit comments