Skip to content

Why is Object overwritten? #1236

Answered by sinclairzx81
tylersayshi asked this question in Q&A
Discussion options

You must be logged in to vote

@tylersayshi Hi,

by using var here, the runtime Object class is being overwritten. I'm curious if this is done intentionally. If it is intentional, is the code extending the default Object or replacing it fully?

This Object declaration is both intentional and unfortunate. The reason Object is defined this way is due Babel transforms not qualifying globalThis.Object in the module header polyfill. There were issues related to "Object used before initialization" when TypeBox declared the Object with const. The following is the high level summary.

// Babel Polyfill Header
Object.defineProperty(....)   // <--- 'Object used before initialization error here

// TypeBox export
export const Object 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tylersayshi
Comment options

Answer selected by tylersayshi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants