-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix detecting an existing Map
/Set
#47409
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
The point of the |
The problem is not in the CJS output. If I set
|
ccca96d
to
7a9577d
Compare
@rbuckton, does that make sense? |
c1beaa1
to
bb2334f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few more small issues I noticed, after which this should be ready to merge.
src/compiler/corePublic.ts
Outdated
const globals = typeof globalThis !== "undefined" ? globalThis | ||
: typeof global !== "undefined" ? global | ||
: typeof self !== "undefined" ? self | ||
: undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor formatting nit:
const globals = typeof globalThis !== "undefined" ? globalThis | |
: typeof global !== "undefined" ? global | |
: typeof self !== "undefined" ? self | |
: undefined; | |
const globals = typeof globalThis !== "undefined" ? globalThis : | |
typeof global !== "undefined" ? global : | |
typeof self !== "undefined" ? self : | |
undefined; |
src/compiler/corePublic.ts
Outdated
|
||
/** | ||
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration). | ||
*/ | ||
export function tryGetNativeMap(): MapConstructor | undefined { | ||
// Internet Explorer's Map doesn't support iteration, so don't use it. | ||
const gMap = globals.Map; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globals
is possibly undefined
.
const gMap = globals.Map; | |
const gMap = globals?.Map; |
src/compiler/corePublic.ts
Outdated
} | ||
|
||
/** | ||
* Returns the native Set implementation if it is available and compatible (i.e. supports iteration). | ||
*/ | ||
export function tryGetNativeSet(): SetConstructor | undefined { | ||
// Internet Explorer's Set doesn't support iteration, so don't use it. | ||
const gSet = globals.Set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globals
is possibly undefined
.
const gSet = globals.Set; | |
const gSet = globals?.Set; |
This didn't affect compilation to CJS since that sets `exports.Map` instead of creating a global.
bb2334f
to
e0735dd
Compare
This didn't affect compilation to CJS since that sets
exports.Map
instead of creating a global.