Migrate strict mode check#2684
Conversation
There was a problem hiding this comment.
this reads oddly. Perhaps if this was .isKeywordInStrictMode instead?
There was a problem hiding this comment.
This won't work for modules. For example, if you have:
"use strict";
module public.whatever {
}(make sure to add a test for this).
There was a problem hiding this comment.
This also won't work for a variable with a binding pattern. For example:
"use strict";
var { public, private };There was a problem hiding this comment.
Good catch remembering to check this. Is there a test for this as well?
There was a problem hiding this comment.
can you simplify this to "return (node.parseContextFlags & ParserContextFlags.StrictMode) !== 0 && ..."
There was a problem hiding this comment.
this should probably be |=
|
With this change, Such code compiles with 1.5 alpha with no issue. |
Move strict mode check into type checker so we can give better error messages. This will be useful particularly when class declaration and ES6 module become strict mode code. One thing worth pointing out is that strict mode is a grammar check which means that if there is any parsing error, strict mode error will not get reported.