-
Notifications
You must be signed in to change notification settings - Fork 12.8k
--alwaysStrict not ... always strict #15041
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
Comments
This definitely should work. It is also completely forwards compatible, valid ES2015 to emit a potentially redundant |
It looks like the real culprit is the babel preset used in React Native's packager. This can be overrode in |
@jeremyjh perhaps, but as you say, Update: An ES Module aware runtime must ensure that all ES Modules are executed in strict mode if it wants to say that it directly supports ES Module syntax. SystemJS does just that. |
I'm going to close this; it is not really a Typescript issue, even though Typescript used to support a nice workaround for it. I still actually have not found any workaround other than putting "use strict"; at the top of every module file myself. Building my own .babelrc config with ["transform-es2015-modules-commonjs", { strict: true, allowTopLevelThis: true }], Did not resolve the issue for some reason. But I think its more properly a RN issue. |
Perhaps link the issue that you file with React Native. |
@aluanhaddad Actually I found they already had one - facebook/react-native#5316 . Basically they can't fix it, too many libraries out there won't compile under strict and all of your project's node_modules will get processed by the packager. I did get an override to work locally in project, and found I also had a couple of dependencies that don't support strict. So its notations at the top of all my files. |
That's frustrating, strict mode should be used in almost every situation, both for security and performance reasons. |
TypeScript Version: 2.2.2
Code
In a React Native project:
tsconfig.json
Expected behavior:
A run-time exception, because alwaysStrict: true.
Actual behavior:
Mutation is silently discarded unless "use strict;" is added to the top of the .ts file.
In #11806 it was identified that "use strict;" is superfluous when module=es2015.
I am using module=es2015 in a React Native and would like "use strict" to be applied to all of my files, but I'm not sure how to do this now. Setting module to commonjs will bring back "use strict" but breaks RN. Setting target=es5 does not enable "use strict";.
The text was updated successfully, but these errors were encountered: