10000 enabled strict mode · wheercool/TypeScript@9112a0e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9112a0e

Browse files
committed
enabled strict mode
1 parent 64ab02e commit 9112a0e

38 files changed

+249
-213
lines changed

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module ts {
9999
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." },
100100
A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." },
101101
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." },
102+
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." },
102103
Duplicate_identifier_0: { code: 2000, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
103104
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 2068, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
104105
Multiple_constructor_implementations_are_not_allowed: { code: 2070, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." },

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,10 @@
388388
"category": "Error",
389389
"code": 1113
390390
},
391-
391+
"Object literal cannot contain more than one property with the same name in the strict mode.": {
392+
"category": "Error",
393+
"code": 1114
394+
},
392395
"Duplicate identifier '{0}'.": {
393396
"category": "Error",
394397
"code": 2000

src/compiler/emitter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,8 +1669,7 @@ module ts {
16691669

16701670
function emitDirectivePrologues(statements: Statement[], startWithNewLine: boolean): number {
16711671
for (var i = 0; i < statements.length; ++i) {
1672-
if (statements[i].kind === SyntaxKind.ExpressionStatement &&
1673-
(<ExpressionStatement>statements[i]).expression.kind === SyntaxKind.StringLiteral) {
1672+
if (isPrologueDirective(statements[i])) {
16741673
if (startWithNewLine || i > 0) {
16751674
writeLine();
16761675
}

src/compiler/parser.ts

Lines changed: 143 additions & 19 deletions
Large diffs are not rendered by default.

src/compiler/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ module ts {
215215
FirstReservedWord = BreakKeyword,
216216
LastReservedWord = WithKeyword,
217217
FirstKeyword = BreakKeyword,
218-
LastKeyword = StringKeyword
218+
LastKeyword = StringKeyword,
219+
FirstFutureReservedWord = ImplementsKeyword,
220+
LastFutureReservedWord = YieldKeyword
219221
}
220222

221223
export enum NodeFlags {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
==== tests/cases/compiler/constructorStaticParamNameErrors.ts (1 errors) ====
2+
'use strict'
3+
// static as constructor parameter name should give error if 'use strict'
4+
class test {
5+
constructor (static) { }
6+
~~~~~~
7+
!!! Identifier expected.
8+
}

tests/baselines/reference/constructorStaticParamNameErrors.js

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
==== tests/cases/compiler/duplicatePropertiesInStrictMode.ts (2 errors) ====
2+
"use strict";
3+
var x = {
4+
x: 1,
5+
x: 2
6+
~
7+
!!! Object literal cannot contain more than one property with the same name in the strict mode.
8+
~
9+
!!! Duplicate identifier 'x'.
10+
}

tests/baselines/reference/parser10.1.1-8gs.errors.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (1 errors) ====
1+
==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (4 errors) ====
22
/// Copyright (c) 2012 Ecma International. All rights reserved.
33
/// Ecma International makes this code available under the terms and conditions set
44
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
@@ -18,4 +18,10 @@
1818
~~~~~~~~~~~~~
1919
!!! Cannot find name 'NotEarlyError'.
2020
var public = 1;
21+
~~~~~~
22+
!!! Variable declaration expected.
23+
~
24+
!!! Variable declaration expected.
25+
~
26+
!!! Variable declaration expected.
2127

tests/baselines/reference/parser10.1.1-8gs.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0