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
Add browser globals to known globals and prevent "typeof" side-effects #3117
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3117 +/- ##
==========================================
+ Coverage 89.28% 89.28% +<.01%
==========================================
Files 165 165
Lines 5731 5732 +1
Branches 1740 1741 +1
==========================================
+ Hits 5117 5118 +1
Misses 380 380
Partials 234 234
Continue to review full report at Codecov.
|
👍 This seems like a reasonable way of getting at the same end result for my case. Thank you! |
src/ast/nodes/shared/knownGlobals.ts
Outdated
// @ts-ignore | ||
__proto__: null, | ||
[ValueProperties]: IMPURE | ||
}; | ||
|
||
const PURE_FUNCTION: GlobalDescription = { | ||
// We use shortened variables to reduce file size here |
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.
Nit, but maybe stick this comment above /* OBJECT */
instead?
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #3115
Description
This will make sure that
typeof globalVariable
is not considered a side-effect. Note thattypeof globalFunction()
would still be a side-effect as it should be. Also, unfortunately Rollup is not yet capable of "remembering" the result of such a check, so in