Skip to content

target=e6 with module=commonjs need "use strict" in the output #6105

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

Closed
3n-mb opened this issue Dec 15, 2015 · 1 comment
Closed

target=e6 with module=commonjs need "use strict" in the output #6105

3n-mb opened this issue Dec 15, 2015 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@3n-mb
Copy link

3n-mb commented Dec 15, 2015

tsc -v 1.7.5
When compiling for es6 target, with let, const, etc., and using commonjs module, browser (Chrome) complains about let and co. used outside of "strict mode" zone. Adding "use strict" at the beginning of commonjs module should fix this.

Note:

  • spec for es6, 10.2.1 Strict Mode Code says that "Module code is always strict mode code". This assumes that es6 modules are used, while commonjs' require()'s look differently.
  • it does not seem to be a problem with node, as it probably relaxes this rule.
  • Babel's transform-es2015-modules-commonjs inserts "use strict" at the start of the file, satisfying browser's desire to stick to the standard's rule, and it all just works. Unfortunately, this requires a babel step in the build :(
@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Dec 15, 2015
@DanielRosenwasser
Copy link
Member

Hey @3n-mb, this seems to be a duplicate of #3576. You can give our nightlies a try by installing npm install -g typescript@next and seeing the new behavior there.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants