Rename parameter static -> isStatic, fixes 'static is a reserved identif...#3011
Conversation
…tifier' error when running in strict mode (microsoft#3006)
|
Hi @frankwallis, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
|
Thanks! i wounded what is the best way to make sure this does not happen again without adding "use strict"... Ideas? |
Rename parameter static -> isStatic, fixes 'static is a reserved identif...
|
So it looks like the compilation would have failed if this code was part of a class, as classes are automatically put into strict mode: I don't know the reason why non-classes are currently excluded from this sort of check, maybe it's a back-compatibility feature? |
|
As per the ES6 spec, classes and modules are parsed in strict mode. This is not the case for other constructs. These are only parsed in strict mode iff the contains scope contains a "use strict" directive. Ideally we would put "use strict" everywhere, except that it has perf impact as engines can not make norml optimizatios all the time. I guess we need a parseStrict flag that makes the compiler always in strict mode. |
Why not just add "use strict" to the top of all our files? There's no reason we'd want our code to be doing things that wouldn't work in strict mode.
This seems fishy to me. "use strict" gives you a subset of javascript, with some bad stuff disallowed. I would be very surprised if we saw any perf hit at all from using 'use strict'.
This seems like vast overkill. If you want strict mode, then use "use strict". That's what it's there for. I don't think we need another compiler option for such an esoteric use case that is already handled fine with an existing language construct. |
...ier' error when running in strict mode (#3006)