-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: remove global_eval.ts #1813
Conversation
// TODO: this should be replaced with globalThis | ||
// when the proposal goes to stage 4 | ||
// See https://github.com/tc39/proposal-global | ||
export const window = (0, eval)("this"); |
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.
What does this mean? (0, eval)
?
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.
it is indirect eval
https://tc39.github.io/ecma262/#sec-performeval
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.
Yes, it's indirect call of eval. Basically the same as the previous code. Please see the stackoverflow link above for details.
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.
Please add a comment.. Something like this
// (0, eval) is indirect eval https://tc39.github.io/ecma262/#sec-performeval
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.
+16 −35
nice
aed71ea
to
efd9fe6
Compare
Updated the comments. Fixed the lint errors. |
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.
LGTM - thanks
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.
We should try to use globalThis
now if we are going to refactor it.
// - https://stackoverflow.com/a/14120023 | ||
// - https://tc39.github.io/ecma262/#sec-performeval (spec) | ||
export const window = (0, eval)("this"); | ||
// TODO: The above should be replaced with globalThis |
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.
globalThis
is already in the runtime... We should be able to do this now, but when I tried it before, there was some sort of error in the snapshotting, I don't know if the snapshot is being done with the right config or some other issue.
@kitsonk |
@kt3k from the notes: https://tc39.github.io/tc39-notes/2019-01_jan-31.html#globalthis-follow-up it was decided to keep TypeScript is just about to implement it into master: microsoft/TypeScript#29332 |
@kitsonk Thank you for the pointer! OK. Let's replace it soon! 👍 |
This PR replaced the
globalEval
usages with exportedwindow
object. I created//js/window.ts
file to separateconst window
declaration from other globals settings and avoid circular reference.