-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Strict mode support #217
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
Strict mode support #217
Conversation
Making allowReservedWords parameter of parseEntityName non-optional.
Give a semantic error on with statements
@@ -99,6 +99,7 @@ module ts { | |||
A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context." }, | |||
A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, | |||
A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, | |||
Object_literal_cannot_contain_more_than_one_property_with_the_same_name_in_the_strict_mode: { code: 1114, category: DiagnosticCategory.Error, key: "Object literal cannot contain more than one property with the same name in the strict mode." }, |
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.
don't say "in the strict mode". that sounds wrong.
Allow reserved words in type queries.
Linux test fixes
…processes like mocha
@CyrusNajmabadi any other comments? |
if (isPrologueDirective(element)) { | ||
if (isUseStrictPrologueDirective(element)) { | ||
isInStrictMode = true; | ||
checkForStrictMode = false; |
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.
I don't think it's correct to set the checkForStrictMode
flag here. See http://www.ecma-international.org/ecma-262/5.1/#sec-14.1 -- the directive prologue consists of all the leading string literal expression statements, of which any might be "use strict"
e.g. this code snippet is strict mode and should error:
function foo() {
"extra awesome";
"use strict";
var static = 0;
}
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.
@RyanCavanaugh and it will error. checkForStrictMode
just denotes whether element needs to be tested to be directive. Code will iterate through all directives, once 'use strict'
is found - global isInStrictMode
flag will be set to true
and checkForStrictMode
- to false
to skip checking other elements
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.
Misread the else
structure. 👍
Sourcemap failures are likely newline related. You may need to re-base against master to get the Linux related test fixes? |
fixes #129 and #130