Merge pull request #2684 from Microsoft/migrateStrictModeCheck

Migrate strict mode check
This commit is contained in:
Yui
2015-04-11 21:59:12 -07:00
88 changed files with 1422 additions and 667 deletions

View File

@@ -7284,7 +7284,7 @@ module ts {
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
// Grammar checking
let hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
let hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node);
if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) {
checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node);
}
@@ -7944,6 +7944,7 @@ module ts {
}
function checkExpression(node: Expression, contextualMapper?: TypeMapper): Type {
checkGrammarIdentifierInStrictMode(node);
return checkExpressionOrQualifiedName(node, contextualMapper);
}
@@ -8059,6 +8060,8 @@ module ts {
// DECLARATION AND STATEMENT TYPE CHECKING
function checkTypeParameter(node: TypeParameterDeclaration) {
checkGrammarDeclarationNameInStrictMode(node);
// Grammar Checking
if (node.expression) {
grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected);
@@ -8327,10 +8330,13 @@ module ts {
}
function checkTypeReferenceNode(node: TypeReferenceNode) {
checkGrammarTypeReferenceInStrictMode(node.typeName);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkHeritageClauseElement(node: HeritageClauseElement) {
checkGrammarHeritageClauseElementInStrictMode(<PropertyAccessExpression>node.expression);
return checkTypeReferenceOrHeritageClauseElement(node);
}
@@ -8861,6 +8867,7 @@ module ts {
}
function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void {
checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSignatureDeclaration(node);
@@ -9144,6 +9151,7 @@ module ts {
// Check variable, parameter, or property declaration
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSourceElement(node.type);
// For a computed property, just check the initializer and exit
@@ -9870,6 +9878,7 @@ module ts {
}
function checkClassDeclaration(node: ClassDeclaration) {
checkGrammarDeclarationNameInStrictMode(node);
// Grammar checking
if (node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) {
grammarErrorOnNode(node, Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
@@ -10096,7 +10105,7 @@ module ts {
function checkInterfaceDeclaration(node: InterfaceDeclaration) {
// Grammar checking
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
if (produceDiagnostics) {
@@ -10321,7 +10330,7 @@ module ts {
}
// Grammar checking
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
@@ -10391,7 +10400,7 @@ module ts {
function checkModuleDeclaration(node: ModuleDeclaration) {
if (produceDiagnostics) {
// Grammar checking
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) {
grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
@@ -10495,7 +10504,7 @@ module ts {
}
function checkImportDeclaration(node: ImportDeclaration) {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
}
if (checkExternalImportOrExportDeclaration(node)) {
@@ -10517,7 +10526,7 @@ module ts {
}
function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) {
checkGrammarDecorators(node) || checkGrammarModifiers(node);
checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node);
if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
if (node.flags & NodeFlags.Export) {
@@ -11896,8 +11905,155 @@ module ts {
anyArrayType = createArrayType(anyType);
}
// GRAMMAR CHECKING
function isReservedwordInStrictMode(node: Identifier): boolean {
// Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word
return (node.parserContextFlags & ParserContextFlags.StrictMode) &&
(node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord);
}
function reportStrictModeGrammarErrorInClassDeclaration(identifier: Identifier, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
// We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
// if so, we would like to give more explicit invalid usage error.
if (getAncestor(identifier, SyntaxKind.ClassDeclaration) || getAncestor(identifier, SyntaxKind.ClassExpression)) {
return grammarErrorOnNode(identifier, message, arg0);
}
return false;
}
function checkGrammarImportDeclarationNameInStrictMode(node: ImportDeclaration): boolean {
// Check if the import declaration used strict-mode reserved word in its names bindings
if (node.importClause) {
let impotClause = node.importClause;
if (impotClause.namedBindings) {
let nameBindings = impotClause.namedBindings;
if (nameBindings.kind === SyntaxKind.NamespaceImport) {
let name = <Identifier>(<NamespaceImport>nameBindings).name;
if (name.originalKeywordKind) {
let nameText = declarationNameToString(name);
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
}
}
else if (nameBindings.kind === SyntaxKind.NamedImports) {
let reportError = false;
for (let element of (<NamedImports>nameBindings).elements) {
let name = element.name;
if (name.originalKeywordKind) {
let nameText = declarationNameToString(name);
reportError = reportError || grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
}
}
return reportError;
}
}
}
return false;
}
function checkGrammarDeclarationNameInStrictMode(node: Declaration): boolean {
let name = node.name;
if (name && name.kind === SyntaxKind.Identifier && isReservedwordInStrictMode(<Identifier>name)) {
let nameText = declarationNameToString(name);
switch (node.kind) {
case SyntaxKind.Parameter:
case SyntaxKind.VariableDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.TypeParameter:
case SyntaxKind.BindingElement:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.EnumDeclaration:
return checkGrammarIdentifierInStrictMode(<Identifier>name);
case SyntaxKind.ClassDeclaration:
// Report an error if the class declaration uses strict-mode reserved word.
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText);
case SyntaxKind.ModuleDeclaration:
// Report an error if the module declaration uses strict-mode reserved word.
// TODO(yuisu): fix this when having external module in strict mode
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
case SyntaxKind.ImportEqualsDeclaration:
// TODO(yuisu): fix this when having external module in strict mode
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
}
}
return false;
}
function checkGrammarTypeReferenceInStrictMode(typeName: Identifier | QualifiedName) {
// Check if the type reference is using strict mode keyword
// Example:
// class C {
// foo(x: public){} // Error.
// }
if (typeName.kind === SyntaxKind.Identifier) {
checkGrammarTypeNameInStrictMode(<Identifier>typeName);
}
// Report an error for each identifier in QualifiedName
// Example:
// foo (x: B.private.bar) // error at private
// foo (x: public.private.package) // error at public, private, and package
else if (typeName.kind === SyntaxKind.QualifiedName) {
// Walk from right to left and report a possible error at each Identifier in QualifiedName
// Example:
// x1: public.private.package // error at public and private
checkGrammarTypeNameInStrictMode((<QualifiedName>typeName).right);
checkGrammarTypeReferenceInStrictMode((<QualifiedName>typeName).left);
}
}
// This function will report an error for every identifier in property access expression
// whether it violates strict mode reserved words.
// Example:
// public // error at public
// public.private.package // error at public
// B.private.B // no error
function checkGrammarHeritageClauseElementInStrictMode(expression: Expression) {
// Example:
// class C extends public // error at public
if (expression && expression.kind === SyntaxKind.Identifier) {
return checkGrammarIdentifierInStrictMode(expression);
}
else if (expression && expression.kind === SyntaxKind.PropertyAccessExpression) {
// Walk from left to right in PropertyAccessExpression until we are at the left most expression
// in PropertyAccessExpression. According to grammar production of MemberExpression,
// the left component expression is a PrimaryExpression (i.e. Identifier) while the other
// component after dots can be IdentifierName.
checkGrammarHeritageClauseElementInStrictMode((<PropertyAccessExpression>expression).expression);
}
}
// The function takes an identifier itself or an expression which has SyntaxKind.Identifier.
function checkGrammarIdentifierInStrictMode(node: Expression | Identifier, nameText?: string): boolean {
if (node && node.kind === SyntaxKind.Identifier && isReservedwordInStrictMode(<Identifier>node)) {
if (!nameText) {
nameText = declarationNameToString(<Identifier>node);
}
// TODO (yuisu): Fix when module is a strict mode
let errorReport = reportStrictModeGrammarErrorInClassDeclaration(<Identifier>node, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText)||
grammarErrorOnNode(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
return errorReport;
}
return false;
}
// The function takes an identifier when uses as a typeName in TypeReferenceNode
function checkGrammarTypeNameInStrictMode(node: Identifier): boolean {
if (node && node.kind === SyntaxKind.Identifier && isReservedwordInStrictMode(<Identifier>node)) {
let nameText = declarationNameToString(<Identifier>node);
// TODO (yuisu): Fix when module is a strict mode
let errorReport = reportStrictModeGrammarErrorInClassDeclaration(<Identifier>node, Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
grammarErrorOnNode(node, Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText);
return errorReport;
}
return false;
}
function checkGrammarDecorators(node: Node): boolean {
if (!node.decorators) {
return false;
@@ -12758,15 +12914,14 @@ module ts {
if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) {
let nameText = declarationNameToString(identifier);
// We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
// if so, we would like to give more explicit invalid usage error.
// This will be particularly helpful in the case of "arguments" as such case is very common mistake.
if (getAncestor(name, SyntaxKind.ClassDeclaration) || getAncestor(name, SyntaxKind.ClassExpression)) {
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
}
else {
// We check first if the name is inside class declaration or class expression; if so give explicit message
// otherwise report generic error message.
// reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise
let reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
if (!reportErrorInClassDeclaration){
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
}
return reportErrorInClassDeclaration;
}
}
}

View File

@@ -169,6 +169,12 @@ module ts {
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." },
Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },

View File

@@ -657,12 +657,36 @@
},
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
"category": "Error",
"code": 1210
"code": 1210
},
"A class declaration without the 'default' modifier must have a name": {
"category": "Error",
"code": 1211
},
"Identifier expected. '{0}' is a reserved word in strict mode": {
"category": "Error",
"code": 1212
},
"Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode.": {
"category": "Error",
"code": 1213
},
"Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode.": {
"category": "Error",
"code": 1214
},
"Type expected. '{0}' is a reserved word in strict mode": {
"category": "Error",
"code": 1215
},
"Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode.": {
"category": "Error",
"code": 1216
},
"Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode.": {
"category": "Error",
"code": 1217
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300

View File

@@ -1349,6 +1349,7 @@ module ts {
return speculationHelper(callback, /*isLookAhead:*/ false);
}
// Ignore strict mode flag because we will report an error in type checker instead.
function isIdentifier(): boolean {
if (token === SyntaxKind.Identifier) {
return true;
@@ -1360,7 +1361,7 @@ module ts {
return false;
}
return inStrictModeContext() ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord;
return token > SyntaxKind.LastReservedWord;
}
function parseExpected(kind: SyntaxKind, diagnosticMessage?: DiagnosticMessage): boolean {
@@ -1484,6 +1485,11 @@ module ts {
identifierCount++;
if (isIdentifier) {
let node = <Identifier>createNode(SyntaxKind.Identifier);
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
if (token !== SyntaxKind.Identifier) {
node.originalKeywordKind = token;
}
node.text = internIdentifier(scanner.getTokenValue());
nextToken();
return finishNode(node);
@@ -4599,6 +4605,18 @@ module ts {
return finishNode(node);
}
function isClassMemberModifier(idToken: SyntaxKind) {
switch (idToken) {
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
return true;
default:
return false;
}
}
function isClassMemberStart(): boolean {
let idToken: SyntaxKind;
@@ -4609,6 +4627,16 @@ module ts {
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
while (isModifier(token)) {
idToken = token;
// If the idToken is a class modifier (protected, private, public, and static), it is
// certain that we are starting to parse class member. This allows better error recovery
// Example:
// public foo() ... // true
// public @dec blah ... // true; we will then report an error later
// export public ... // true; we will then report an error later
if (isClassMemberModifier(idToken)) {
return true;
}
nextToken();
}

View File

@@ -388,7 +388,8 @@ module ts {
}
export interface Identifier extends PrimaryExpression {
text: string; // Text of identifier (with escapes converted to characters)
text: string; // Text of identifier (with escapes converted to characters)
originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later
}
export interface QualifiedName extends Node {

View File

@@ -13,12 +13,14 @@ tests/cases/compiler/classUpdateTests.ts(95,1): error TS1128: Declaration or sta
tests/cases/compiler/classUpdateTests.ts(99,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(101,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(105,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(105,15): error TS2339: Property 'p1' does not exist on type 'Q'.
tests/cases/compiler/classUpdateTests.ts(105,14): error TS1005: ';' expected.
tests/cases/compiler/classUpdateTests.ts(107,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(111,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' does not exist on type 'R'.
tests/cases/compiler/classUpdateTests.ts(111,15): error TS1005: ';' expected.
tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or statement expected.
==== tests/cases/compiler/classUpdateTests.ts (16 errors) ====
==== tests/cases/compiler/classUpdateTests.ts (18 errors) ====
//
// test codegen for instance properties
//
@@ -158,17 +160,21 @@ tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' do
public this.p1 = 0; // ERROR
~~~~~~
!!! error TS1129: Statement expected.
~~
!!! error TS2339: Property 'p1' does not exist on type 'Q'.
~
!!! error TS1005: ';' expected.
}
}
~
!!! error TS1128: Declaration or statement expected.
class R {
constructor() {
private this.p1 = 0; // ERROR
~~~~~~~
!!! error TS1129: Statement expected.
~~
!!! error TS2339: Property 'p1' does not exist on type 'R'.
~
!!! error TS1005: ';' expected.
}
}
}
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -1,4 +1,4 @@
tests/cases/compiler/constructorStaticParamName.ts(4,18): error TS1003: Identifier expected.
tests/cases/compiler/constructorStaticParamName.ts(4,18): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
==== tests/cases/compiler/constructorStaticParamName.ts (1 errors) ====
@@ -7,6 +7,6 @@ tests/cases/compiler/constructorStaticParamName.ts(4,18): error TS1003: Identifi
class test {
constructor (static) { }
~~~~~~
!!! error TS1003: Identifier expected.
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}

View File

@@ -9,7 +9,7 @@ class test {
//// [constructorStaticParamName.js]
// static as constructor parameter name should only give error if 'use strict'
var test = (function () {
function test() {
function test(static) {
}
return test;
})();

View File

@@ -1,4 +1,4 @@
tests/cases/compiler/constructorStaticParamNameErrors.ts(4,18): error TS1003: Identifier expected.
tests/cases/compiler/constructorStaticParamNameErrors.ts(4,18): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
==== tests/cases/compiler/constructorStaticParamNameErrors.ts (1 errors) ====
@@ -7,5 +7,5 @@ tests/cases/compiler/constructorStaticParamNameErrors.ts(4,18): error TS1003: Id
class test {
constructor (static) { }
~~~~~~
!!! error TS1003: Identifier expected.
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}

View File

@@ -9,7 +9,7 @@ class test {
'use strict';
// static as constructor parameter name should give error if 'use strict'
var test = (function () {
function test() {
function test(static) {
}
return test;
})();

View File

@@ -21,45 +21,23 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(47,17): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(49,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(53,13): error TS2304: Cannot find name 'console'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(58,5): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(65,29): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(69,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(72,37): error TS1127: Invalid character.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(81,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(89,23): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(94,17): error TS1134: Variable declaration expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(95,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(105,29): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(106,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,24): error TS2304: Cannot find name 'any'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,30): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,37): error TS2304: Cannot find name 'declare'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,47): error TS2304: Cannot find name 'constructor'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,61): error TS2304: Cannot find name 'get'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,67): error TS2304: Cannot find name 'implements'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(111,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,9): error TS2304: Cannot find name 'STATEMENTS'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,21): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,30): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,39): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,24): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(138,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(141,32): error TS1005: '{' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(143,13): error TS1005: 'try' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,16): error TS2304: Cannot find name 'TYPES'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,23): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,32): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,24): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,30): error TS1005: '(' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,31): error TS2304: Cannot find name 'Property'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(166,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,16): error TS2304: Cannot find name 'OPERATOR'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,26): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,35): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(205,28): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(210,5): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(213,16): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(223,23): error TS2304: Cannot find name 'bool'.
@@ -69,6 +47,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,9): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,16): error TS2304: Cannot find name 'method1'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,24): error TS2304: Cannot find name 'val'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,27): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,28): error TS2304: Cannot find name 'number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,36): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS2304: Cannot find name 'method2'.
@@ -83,23 +62,27 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,9): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,16): error TS2304: Cannot find name 'Overloads'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,26): error TS2304: Cannot find name 'value'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,31): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,33): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,16): error TS2304: Cannot find name 'Overloads'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,27): error TS1135: Argument expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,33): error TS1005: '(' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,35): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,43): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,52): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,60): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,65): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,9): error TS2304: Cannot find name 'public'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS2304: Cannot find name 'DefaultValue'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error TS2304: Cannot find name 'value'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,35): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2322: Type 'string' is not assignable to type 'boolean'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected.
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (99 errors) ====
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (82 errors) ====
declare module "fs" {
export class File {
constructor(filename: string);
@@ -214,8 +197,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
/// </summary>
/// <returns></returns>
public VARIABLES(): number {
~~~~~~
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
var local = Number.MAX_VALUE;
var min = Number.MIN_VALUE;
var inf = Number.NEGATIVE_INFINITY -
@@ -255,11 +236,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
var constructor = 0;
var get = 0;
var implements = 0;
~~~~~~~~~~
!!! error TS1134: Variable declaration expected.
var interface = 0;
~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
var let = 0;
var module = 0;
var number = 0;
@@ -277,23 +254,11 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS1109: Expression expected.
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
~~~
!!! error TS2304: Cannot find name 'any'.
~~~~
!!! error TS2304: Cannot find name 'bool'.
~~~~~~~
!!! error TS2304: Cannot find name 'declare'.
~~~~~~~~~~~
!!! error TS2304: Cannot find name 'constructor'.
~~~
!!! error TS2304: Cannot find name 'get'.
~~~~~~~~~~
!!! error TS2304: Cannot find name 'implements'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
return 0;
}
~
!!! error TS1128: Declaration or statement expected.
/// <summary>
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
@@ -301,14 +266,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
/// <param name="i"></param>
/// <returns></returns>
STATEMENTS(i: number): number {
~~~~~~~~~~
!!! error TS2304: Cannot find name 'STATEMENTS'.
~
!!! error TS1005: ',' expected.
~
!!! error TS1005: ';' expected.
~
!!! error TS1005: ';' expected.
var retVal = 0;
if (i == 1)
retVal = 1;
@@ -352,14 +309,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
/// </summary>
/// <returns></returns>
public TYPES(): number {
~~~~~~
!!! error TS1128: Declaration or statement expected.
~~~~~
!!! error TS2304: Cannot find name 'TYPES'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1005: ';' expected.
var retVal = 0;
var c = new CLASS();
var xx: IF = c;
@@ -389,14 +338,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
///// </summary>
///// <returns></returns>
public OPERATOR(): number {
~~~~~~
!!! error TS1128: Declaration or statement expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'OPERATOR'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1005: ';' expected.
var a: number[] = [1, 2, 3, 4, 5, ];/*[] bug*/ // YES []
var i = a[1];/*[]*/
i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/
@@ -435,8 +376,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
}
}
~
!!! error TS1128: Declaration or statement expected.
interface IF {
Foo(): bool;
@@ -480,6 +419,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS2304: Cannot find name 'val'.
~
!!! error TS1005: ',' expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
~
!!! error TS1005: ';' expected.
return val;
@@ -529,6 +470,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS2304: Cannot find name 'value'.
~
!!! error TS1005: ',' expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
public Overloads( while : string, ...rest: string[]) { &
~~~~~~
!!! error TS1128: Declaration or statement expected.
@@ -538,14 +481,20 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS1135: Argument expression expected.
~
!!! error TS1005: '(' expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
~~~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1109: Expression expected.
public DefaultValue(value?: string = "Hello") { }
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~~~~~~~~~~~~
!!! error TS1005: ';' expected.
~~~~~~~~~~~~
@@ -555,7 +504,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
!!! error TS2304: Cannot find name 'string'.
~
!!! error TS1005: ';' expected.
}

View File

@@ -342,7 +342,6 @@ var TypeScriptAllInOne;
})(TypeScriptAllInOne || (TypeScriptAllInOne = {}));
var BasicFeatures = (function () {
function BasicFeatures() {
this.implements = 0;
}
/// <summary>
/// Test various of variables. Including nullable,key world as variable,special format
@@ -375,115 +374,117 @@ var BasicFeatures = (function () {
var declare = 0;
var constructor = 0;
var get = 0;
var ;
var implements = 0;
var interface = 0;
var let = 0;
var module = 0;
var number = 0;
var package = 0;
var private = 0;
var protected = 0;
var public = 0;
var set = 0;
var static = 0;
var string = 0 / >
;
var yield = 0;
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
return 0;
};
/// <summary>
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
BasicFeatures.prototype.STATEMENTS = function (i) {
var retVal = 0;
if (i == 1)
retVal = 1;
else
retVal = 0;
switch (i) {
case 2:
retVal = 1;
break;
case 3:
retVal = 1;
break;
default:
break;
}
for (var x in { x: 0, y: 1 }) {
!;
try {
throw null;
}
catch (Exception) { }
}
try {
}
finally {
try { }
catch (Exception) { }
}
return retVal;
};
/// <summary>
/// Test types in ts language. Including class,struct,interface,delegate,anonymous type
/// </summary>
/// <returns></returns>
BasicFeatures.prototype.TYPES = function () {
var retVal = 0;
var c = new CLASS();
var xx = c;
retVal += ;
try { }
catch () { }
Property;
retVal += c.Member();
retVal += xx.Foo() ? 0 : 1;
//anonymous type
var anony = { a: new CLASS() };
retVal += anony.a.d();
return retVal;
};
///// <summary>
///// Test different operators
///// </summary>
///// <returns></returns>
BasicFeatures.prototype.OPERATOR = function () {
var a = [1, 2, 3, 4, 5,]; /*[] bug*/ // YES []
var i = a[1]; /*[]*/
i = i + i - i * i / i % i & i | i ^ i; /*+ - * / % & | ^*/
var b = true && false || true ^ false; /*& | ^*/
b = !b; /*!*/
i = ~i; /*~i*/
b = i < (i - 1) && (i + 1) > i; /*< && >*/
var f = true ? 1 : 0; /*? :*/ // YES :
i++; /*++*/
i--; /*--*/
b = true && false || true; /*&& ||*/
i = i << 5; /*<<*/
i = i >> 5; /*>>*/
var j = i;
b = i == j && i != j && i <= j && i >= j; /*= == && != <= >=*/
i += 5.0; /*+=*/
i -= i; /*-=*/
i *= i; /**=*/
if (i == 0)
i++;
i /= i; /*/=*/
i %= i; /*%=*/
i &= i; /*&=*/
i |= i; /*|=*/
i ^= i; /*^=*/
i <<= i; /*<<=*/
i >>= i; /*>>=*/
if (i == 0 && != b && f == 1)
return 0;
else
return 1;
};
return BasicFeatures;
})();
var interface = 0;
var let = 0;
var module = 0;
var number = 0;
var package = 0;
var private = 0;
var protected = 0;
var public = 0;
var set = 0;
var static = 0;
var string = 0 / >
;
var yield = 0;
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
return 0;
/// <summary>
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
STATEMENTS(i, number);
number;
{
var retVal = 0;
if (i == 1)
retVal = 1;
else
retVal = 0;
switch (i) {
case 2:
retVal = 1;
break;
case 3:
retVal = 1;
break;
default:
break;
}
for (var x in { x: 0, y: 1 }) {
!;
try {
throw null;
}
catch (Exception) { }
}
try {
}
finally {
try { }
catch (Exception) { }
}
return retVal;
}
TYPES();
number;
{
var retVal = 0;
var c = new CLASS();
var xx = c;
retVal += ;
try { }
catch () { }
Property;
retVal += c.Member();
retVal += xx.Foo() ? 0 : 1;
//anonymous type
var anony = { a: new CLASS() };
retVal += anony.a.d();
return retVal;
}
OPERATOR();
number;
{
var a = [1, 2, 3, 4, 5,]; /*[] bug*/ // YES []
var i = a[1]; /*[]*/
i = i + i - i * i / i % i & i | i ^ i; /*+ - * / % & | ^*/
var b = true && false || true ^ false; /*& | ^*/
b = !b; /*!*/
i = ~i; /*~i*/
b = i < (i - 1) && (i + 1) > i; /*< && >*/
var f = true ? 1 : 0; /*? :*/ // YES :
i++; /*++*/
i--; /*--*/
b = true && false || true; /*&& ||*/
i = i << 5; /*<<*/
i = i >> 5; /*>>*/
var j = i;
b = i == j && i != j && i <= j && i >= j; /*= == && != <= >=*/
i += 5.0; /*+=*/
i -= i; /*-=*/
i *= i; /**=*/
if (i == 0)
i++;
i /= i; /*/=*/
i %= i; /*%=*/
i &= i; /*&=*/
i |= i; /*|=*/
i ^= i; /*^=*/
i <<= i; /*<<=*/
i >>= i; /*>>=*/
if (i == 0 && != b && f == 1)
return 0;
else
return 1;
}
var CLASS = (function () {
function CLASS() {
this.d = function () { yield 0; };

View File

@@ -1,21 +1,15 @@
tests/cases/compiler/convertKeywordsYes.ts(293,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(293,21): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(294,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(296,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(296,19): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(297,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(297,19): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(298,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(298,21): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(299,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(299,18): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(301,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(301,18): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(303,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(303,17): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(292,11): error TS1213: Identifier expected. 'implements' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(293,11): error TS1213: Identifier expected. 'interface' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(294,11): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(296,11): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(297,11): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(298,11): error TS1213: Identifier expected. 'protected' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(299,11): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(301,11): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/convertKeywordsYes.ts(303,11): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode.
==== tests/cases/compiler/convertKeywordsYes.ts (15 errors) ====
==== tests/cases/compiler/convertKeywordsYes.ts (9 errors) ====
// reserved ES5 future in strict mode
var constructor = 0;
@@ -308,46 +302,34 @@ tests/cases/compiler/convertKeywordsYes.ts(303,17): error TS1005: ';' expected.
module bigModule {
class constructor { }
class implements { }
~~~~~~~~~~
!!! error TS1213: Identifier expected. 'implements' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class interface { }
~~~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
!!! error TS1213: Identifier expected. 'interface' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class let { }
~~~
!!! error TS1005: '{' expected.
!!! error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class module { }
class package { }
~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
!!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class private { }
~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
!!! error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class protected { }
~~~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
!!! error TS1213: Identifier expected. 'protected' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class public { }
~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class set { }
class static { }
~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class get { }
class yield { }
~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
!!! error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class declare { }
}

View File

@@ -505,81 +505,66 @@ var bigModule;
}
return constructor;
})();
var default_1 = (function () {
function default_1() {
var implements = (function () {
function implements() {
}
return default_1;
return implements;
})();
var default_2 = (function () {
function default_2() {
var interface = (function () {
function interface() {
}
return default_2;
return interface;
})();
interface;
{ }
var default_3 = (function () {
function default_3() {
var let = (function () {
function let() {
}
return default_3;
return let;
})();
var _a = void 0;
var module = (function () {
function module() {
}
return module;
})();
var default_4 = (function () {
function default_4() {
var package = (function () {
function package() {
}
return default_4;
return package;
})();
package;
{ }
var default_5 = (function () {
function default_5() {
var private = (function () {
function private() {
}
return default_5;
return private;
})();
private;
{ }
var default_6 = (function () {
function default_6() {
var protected = (function () {
function protected() {
}
return default_6;
return protected;
})();
protected;
{ }
var default_7 = (function () {
function default_7() {
var public = (function () {
function public() {
}
return default_7;
return public;
})();
public;
{ }
var set = (function () {
function set() {
}
return set;
})();
var default_8 = (function () {
function default_8() {
var static = (function () {
function static() {
}
return default_8;
return static;
})();
static;
{ }
var get = (function () {
function get() {
}
return get;
})();
var default_9 = (function () {
function default_9() {
var yield = (function () {
function yield() {
}
return default_9;
return yield;
})();
yield;
{ }
var declare = (function () {
function declare() {
}

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1005: ';' expected.
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (1 errors) ====
@@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4
class C {
public @dec get accessor() { return 1; }
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1005: ';' expected.
}

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1005: ';' expected.
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (1 errors) ====
@@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4
class C {
public @dec set accessor(value: number) { }
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1005: ';' expected.
}

View File

@@ -1,14 +1,11 @@
tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts(4,17): error TS1003: Identifier expected.
tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts(4,24): error TS1005: ',' expected.
==== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts (2 errors) ====
==== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts (1 errors) ====
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {
constructor(public @dec p: number) {}
~~~~~~
!!! error TS1003: Identifier expected.
~
!!! error TS1005: ',' expected.
}

View File

@@ -15,7 +15,7 @@ var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.deco
};
var __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };
var C = (function () {
function C(, p) {
function C(public, p) {
}
C = __decorate([
__param(1, dec)

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1005: ';' expected.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (1 errors) ====
@@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5):
class C {
public @dec method() {}
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1005: ';' expected.
}

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1005: ';' expected.
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (1 errors) ====
@@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4
class C {
public @dec prop;
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1005: ';' expected.
}

View File

@@ -0,0 +1,25 @@
tests/cases/compiler/errorRecoveryInClassDeclaration.ts(3,17): error TS2304: Cannot find name 'foo'.
tests/cases/compiler/errorRecoveryInClassDeclaration.ts(4,13): error TS2304: Cannot find name 'public'.
tests/cases/compiler/errorRecoveryInClassDeclaration.ts(4,20): error TS1005: ',' expected.
tests/cases/compiler/errorRecoveryInClassDeclaration.ts(4,20): error TS2304: Cannot find name 'blaz'.
tests/cases/compiler/errorRecoveryInClassDeclaration.ts(4,27): error TS1005: ',' expected.
==== tests/cases/compiler/errorRecoveryInClassDeclaration.ts (5 errors) ====
class C {
public bar() {
var v = foo(
~~~
!!! error TS2304: Cannot find name 'foo'.
public blaz() {}
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~~~~
!!! error TS1005: ',' expected.
~~~~
!!! error TS2304: Cannot find name 'blaz'.
~
!!! error TS1005: ',' expected.
);
}
}

View File

@@ -0,0 +1,18 @@
//// [errorRecoveryInClassDeclaration.ts]
class C {
public bar() {
var v = foo(
public blaz() {}
);
}
}
//// [errorRecoveryInClassDeclaration.js]
var C = (function () {
function C() {
}
C.prototype.bar = function () {
var v = foo(public, blaz(), {});
};
return C;
})();

View File

@@ -1,21 +1,12 @@
tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,5): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,9): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,11): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(3,5): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,5): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,7): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(6,1): error TS2300: Duplicate identifier 'a'.
==== tests/cases/compiler/letAsIdentifierInStrictMode.ts (7 errors) ====
==== tests/cases/compiler/letAsIdentifierInStrictMode.ts (4 errors) ====
"use strict";
var let = 10;
~~~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1134: Variable declaration expected.
~~
!!! error TS1134: Variable declaration expected.
var a = 10;
~
!!! error TS2300: Duplicate identifier 'a'.

View File

@@ -8,9 +8,7 @@ a;
//// [letAsIdentifierInStrictMode.js]
"use strict";
var ;
var ;
10;
var let = 10;
var a = 10;
var ;
30;

View File

@@ -1,10 +1,8 @@
tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(16,7): error TS2304: Cannot find name 'NotEarlyError'.
tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,5): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,12): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,14): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,5): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (4 errors) ====
==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (2 errors) ====
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
@@ -25,9 +23,5 @@ tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,14): error TS1
!!! error TS2304: Cannot find name 'NotEarlyError'.
var public = 1;
~~~~~~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1134: Variable declaration expected.
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode

View File

@@ -33,5 +33,4 @@ var public = 1;
"use strict";
"use strict";
throw NotEarlyError;
var ;
1;
var public = 1;

View File

@@ -1,13 +1,10 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts(3,16): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts(3,23): error TS1005: ',' expected.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts (1 errors) ====
class Foo3 {
// Doesn't work, but should
constructor (public ...args: string[]) { }
~~~~~~
!!! error TS1003: Identifier expected.
~~~
!!! error TS1005: ',' expected.
}

View File

@@ -7,7 +7,7 @@ class Foo3 {
//// [parser509668.js]
var Foo3 = (function () {
// Doesn't work, but should
function Foo3() {
function Foo3(public) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];

View File

@@ -1,12 +1,15 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS1110: Type expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS2304: Cannot find name 'public'.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts (2 errors) ====
class Foo {
constructor() { }
public banana (x: public) { }
~~~~~~
!!! error TS1110: Type expected.
!!! error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
}
class Bar {

View File

@@ -12,7 +12,7 @@ class Bar {
var Foo = (function () {
function Foo() {
}
Foo.prototype.banana = function (x, ) { };
Foo.prototype.banana = function (x) { };
return Foo;
})();
var Bar = (function () {

View File

@@ -1,10 +1,10 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts(2,18): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts(2,18): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts (1 errors) ====
class test {
constructor (static) { }
~~~~~~
!!! error TS1003: Identifier expected.
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}

View File

@@ -6,7 +6,7 @@ class test {
//// [parser642331.js]
var test = (function () {
function test() {
function test(static) {
}
return test;
})();

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331_1.ts(4,18): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331_1.ts(4,18): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331_1.ts (1 errors) ====
@@ -7,6 +7,6 @@ tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331_1.ts(4,1
class test {
constructor (static) { }
~~~~~~
!!! error TS1003: Identifier expected.
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}

View File

@@ -9,7 +9,7 @@ class test {
//// [parser642331_1.js]
"use strict";
var test = (function () {
function test() {
function test(static) {
}
return test;
})();

View File

@@ -1,15 +1,15 @@
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS2304: Cannot find name 'public'.
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts (3 errors) ====
class C {
[public ]: string;
~~~~~~~~~
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
~~~~~~
!!! error TS1109: Expression expected.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
}

View File

@@ -1,21 +1,12 @@
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,6): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,12): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,16): error TS1005: '=>' expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(3,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,6): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,6): error TS2304: Cannot find name 'public'.
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (5 errors) ====
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (2 errors) ====
class C {
[public]() { }
~~~~~~
!!! error TS1109: Expression expected.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1005: '=>' expected.
}
~
!!! error TS1128: Declaration or statement expected.
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
}

View File

@@ -5,5 +5,5 @@ class C {
//// [parserComputedPropertyName38.js]
class C {
[public]() { }
}
(() => { });

View File

@@ -1,22 +1,13 @@
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts(3,6): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts(3,12): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts(3,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts(3,16): error TS1005: '=>' expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts(4,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts(3,6): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts(3,6): error TS2304: Cannot find name 'public'.
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts (5 errors) ====
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts (2 errors) ====
"use strict";
class C {
[public]() { }
~~~~~~
!!! error TS1109: Expression expected.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1005: '=>' expected.
}
~
!!! error TS1128: Declaration or statement expected.
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
}

View File

@@ -7,5 +7,5 @@ class C {
//// [parserComputedPropertyName39.js]
"use strict";
class C {
[public]() { }
}
(() => { });

View File

@@ -1,8 +1,8 @@
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(2,1): error TS2304: Cannot find name 'foo1'.
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(3,1): error TS2304: Cannot find name 'foo1'.
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(4,1): error TS2304: Cannot find name 'foo1'.
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(5,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(5,8): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(5,1): error TS1212: Identifier expected. 'static' is a reserved word in strict mode
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(5,1): error TS2304: Cannot find name 'static'.
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts (5 errors) ====
@@ -18,6 +18,6 @@ tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts(5,8):
!!! error TS2304: Cannot find name 'foo1'.
static();
~~~~~~
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1109: Expression expected.
!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode
~~~~~~
!!! error TS2304: Cannot find name 'static'.

View File

@@ -10,4 +10,4 @@ static();
foo1();
foo1();
foo1();
();
static();

View File

@@ -0,0 +1,85 @@
tests/cases/compiler/reservedWords2.ts(1,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
tests/cases/compiler/reservedWords2.ts(1,8): error TS1109: Expression expected.
tests/cases/compiler/reservedWords2.ts(1,14): error TS1005: '(' expected.
tests/cases/compiler/reservedWords2.ts(1,16): error TS2304: Cannot find name 'require'.
tests/cases/compiler/reservedWords2.ts(1,31): error TS1005: ')' expected.
tests/cases/compiler/reservedWords2.ts(2,12): error TS2300: Duplicate identifier '(Missing)'.
tests/cases/compiler/reservedWords2.ts(2,14): error TS1003: Identifier expected.
tests/cases/compiler/reservedWords2.ts(2,20): error TS1005: '(' expected.
tests/cases/compiler/reservedWords2.ts(2,20): error TS2304: Cannot find name 'from'.
tests/cases/compiler/reservedWords2.ts(2,25): error TS1005: ')' expected.
tests/cases/compiler/reservedWords2.ts(4,5): error TS1134: Variable declaration expected.
tests/cases/compiler/reservedWords2.ts(4,12): error TS1109: Expression expected.
tests/cases/compiler/reservedWords2.ts(5,9): error TS2300: Duplicate identifier '(Missing)'.
tests/cases/compiler/reservedWords2.ts(5,10): error TS1003: Identifier expected.
tests/cases/compiler/reservedWords2.ts(5,18): error TS1005: '=>' expected.
tests/cases/compiler/reservedWords2.ts(6,7): error TS2300: Duplicate identifier '(Missing)'.
tests/cases/compiler/reservedWords2.ts(6,8): error TS1003: Identifier expected.
tests/cases/compiler/reservedWords2.ts(9,6): error TS1181: Array element destructuring pattern expected.
tests/cases/compiler/reservedWords2.ts(9,14): error TS1005: ';' expected.
tests/cases/compiler/reservedWords2.ts(9,18): error TS1005: '(' expected.
tests/cases/compiler/reservedWords2.ts(9,20): error TS1128: Declaration or statement expected.
tests/cases/compiler/reservedWords2.ts(10,5): error TS2300: Duplicate identifier '(Missing)'.
tests/cases/compiler/reservedWords2.ts(10,6): error TS1003: Identifier expected.
==== tests/cases/compiler/reservedWords2.ts (23 errors) ====
import while = require("dfdf");
~~~~~~
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
~~~~~
!!! error TS1109: Expression expected.
~
!!! error TS1005: '(' expected.
~~~~~~~
!!! error TS2304: Cannot find name 'require'.
~
!!! error TS1005: ')' expected.
import * as while from "foo"
!!! error TS2300: Duplicate identifier '(Missing)'.
~~~~~
!!! error TS1003: Identifier expected.
~~~~
!!! error TS1005: '(' expected.
~~~~
!!! error TS2304: Cannot find name 'from'.
~~~~~
!!! error TS1005: ')' expected.
var typeof = 10;
~~~~~~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1109: Expression expected.
function throw() {}
!!! error TS2300: Duplicate identifier '(Missing)'.
~~~~~
!!! error TS1003: Identifier expected.
~
!!! error TS1005: '=>' expected.
module void {}
!!! error TS2300: Duplicate identifier '(Missing)'.
~~~~
!!! error TS1003: Identifier expected.
var {while, return} = { while: 1, return: 2 };
var {this, switch: { continue} } = { this: 1, switch: { continue: 2 }};
var [debugger, if] = [1, 2];
~~~~~~~~
!!! error TS1181: Array element destructuring pattern expected.
~
!!! error TS1005: ';' expected.
~
!!! error TS1005: '(' expected.
~
!!! error TS1128: Declaration or statement expected.
enum void {}
!!! error TS2300: Duplicate identifier '(Missing)'.
~~~~
!!! error TS1003: Identifier expected.

View File

@@ -0,0 +1,37 @@
//// [reservedWords2.ts]
import while = require("dfdf");
import * as while from "foo"
var typeof = 10;
function throw() {}
module void {}
var {while, return} = { while: 1, return: 2 };
var {this, switch: { continue} } = { this: 1, switch: { continue: 2 }};
var [debugger, if] = [1, 2];
enum void {}
//// [reservedWords2.js]
require();
while ( = require("dfdf"))
;
while (from)
"foo";
var ;
typeof ;
10;
throw function () { };
void {};
var _a = { while: 1, return: 2 }, while = _a.while, return = _a.return;
var _b = { this: 1, switch: { continue: 2 } }, this = _b.this, continue = _b.switch.continue;
var _c = void 0;
debugger;
if ()
;
[1, 2];
var ;
(function () {
})( || ( = {}));
void {};

View File

@@ -1,10 +1,8 @@
tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(16,7): error TS2304: Cannot find name 'NotEarlyError'.
tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,5): error TS1134: Variable declaration expected.
tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,12): error TS1134: Variable declaration expected.
tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,14): error TS1134: Variable declaration expected.
tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,5): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (4 errors) ====
==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (2 errors) ====
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
@@ -25,9 +23,5 @@ tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,14): error T
!!! error TS2304: Cannot find name 'NotEarlyError'.
var public = 1;
~~~~~~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1134: Variable declaration expected.
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode

View File

@@ -33,5 +33,4 @@ var public = 1;
"use strict";
"use strict";
throw NotEarlyError;
var ;
1;
var public = 1;

View File

@@ -1,25 +0,0 @@
//// [strictMode1.ts]
"use strict";
class A {}
class B extends A {}
//// [strictMode1.js]
"use strict";
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var A = (function () {
function A() {
}
return A;
})();
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
})(A);

View File

@@ -1,9 +0,0 @@
=== tests/cases/compiler/strictMode1.ts ===
"use strict";
class A {}
>A : A
class B extends A {}
>B : B
>A : A

View File

@@ -1,13 +0,0 @@
//// [strictMode2.ts]
"use strict";
function foo() {
return 30;
}
//// [strictMode2.js]
"use strict";
function foo() {
return 30;
}

View File

@@ -1,8 +0,0 @@
=== tests/cases/compiler/strictMode2.ts ===
"use strict";
function foo() {
>foo : () => number
return 30;
}

View File

@@ -1,36 +0,0 @@
//// [strictMode3.ts]
"use strict";
class A {
}
class B extends A {
}
function foo() {
return this.window;
}
//// [strictMode3.js]
"use strict";
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var A = (function () {
function A() {
}
return A;
})();
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
})(A);
function foo() {
return this.window;
}

View File

@@ -1,20 +0,0 @@
=== tests/cases/compiler/strictMode3.ts ===
"use strict";
class A {
>A : A
}
class B extends A {
>B : B
>A : A
}
function foo() {
>foo : () => any
return this.window;
>this.window : any
>this : any
>window : any
}

View File

@@ -1,14 +0,0 @@
//// [strictMode4.ts]
"use strict";
class A {
}
//// [strictMode4.js]
"use strict";
var A = (function () {
function A() {
}
return A;
})();

View File

@@ -1,7 +0,0 @@
=== tests/cases/compiler/strictMode4.ts ===
"use strict";
class A {
>A : A
}

View File

@@ -1,45 +0,0 @@
//// [strictMode5.ts]
function foo(...args) {
"use strict"
}
class A {
m() {
"use strict"
var v = () => {
return this.n();
};
}
n() {}
}
function bar(x: number = 10) {
"use strict"
}
//// [strictMode5.js]
function foo() {
"use strict";
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
var A = (function () {
function A() {
}
A.prototype.m = function () {
"use strict";
var _this = this;
var v = function () {
return _this.n();
};
};
A.prototype.n = function () { };
return A;
})();
function bar(x) {
"use strict";
if (x === void 0) { x = 10; }
}

View File

@@ -1,38 +0,0 @@
=== tests/cases/compiler/strictMode5.ts ===
function foo(...args) {
>foo : (...args: any[]) => void
>args : any[]
"use strict"
}
class A {
>A : A
m() {
>m : () => void
"use strict"
var v = () => {
>v : () => void
>() => { return this.n(); } : () => void
return this.n();
>this.n() : void
>this.n : () => void
>this : A
>n : () => void
};
}
n() {}
>n : () => void
}
function bar(x: number = 10) {
>bar : (x?: number) => void
>x : number
"use strict"
}

View File

@@ -0,0 +1,147 @@
tests/cases/compiler/strictModeReservedWord.ts(5,9): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(6,9): error TS1212: Identifier expected. 'static' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(7,9): error TS1212: Identifier expected. 'let' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(8,9): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(8,9): error TS2300: Duplicate identifier 'package'.
tests/cases/compiler/strictModeReservedWord.ts(9,14): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(9,14): error TS2300: Duplicate identifier 'package'.
tests/cases/compiler/strictModeReservedWord.ts(10,18): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(10,27): error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(10,39): error TS1212: Identifier expected. 'let' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(11,18): error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(11,30): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(12,24): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(12,33): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(12,41): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(13,11): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(13,20): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(13,28): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(15,25): error TS9003: 'class' expressions are not currently supported.
tests/cases/compiler/strictModeReservedWord.ts(17,9): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS1215: Type expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS2304: Cannot find name 'public'.
tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS1215: Type expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS2304: Cannot find name 'private'.
tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS1215: Type expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS2304: Cannot find name 'private'.
tests/cases/compiler/strictModeReservedWord.ts(20,30): error TS1215: Type expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS1215: Type expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS2304: Cannot find name 'private'.
tests/cases/compiler/strictModeReservedWord.ts(21,30): error TS1215: Type expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,38): error TS1215: Type expected. 'protected' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,9): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS1215: Type expected. 'interface' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS2304: Cannot find name 'interface'.
tests/cases/compiler/strictModeReservedWord.ts(22,22): error TS1215: Type expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,30): error TS1215: Type expected. 'implements' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(23,5): error TS2304: Cannot find name 'ublic'.
tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS1212: Identifier expected. 'static' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invoke an expression whose type lacks a call signature.
==== tests/cases/compiler/strictModeReservedWord.ts (39 errors) ====
let let = 10;
function foo() {
"use strict"
var public = 10;
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
var static = "hi";
~~~~~~
!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode
let let = "blah";
~~~
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode
var package = "hello"
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
~~~~~~~
!!! error TS2300: Duplicate identifier 'package'.
function package() { }
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
~~~~~~~
!!! error TS2300: Duplicate identifier 'package'.
function bar(private, implements, let) { }
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~~~~~~
!!! error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
~~~
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode
function baz<implements, protected>() { }
~~~~~~~~~~
!!! error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
~~~~~~~~~
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
function barn(cb: (private, public, package) => void) { }
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
barn((private, public, package) => { });
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
var myClass = class package extends public {}
~~~~~~~
!!! error TS9003: 'class' expressions are not currently supported.
var b: public.bar;
~
!!! error TS2300: Duplicate identifier 'b'.
~~~~~~
!!! error TS1215: Type expected. 'public' is a reserved word in strict mode
~~~~~~
!!! error TS2304: Cannot find name 'public'.
function foo(x: private.x) { }
~~~~~~~
!!! error TS1215: Type expected. 'private' is a reserved word in strict mode
~~~~~~~
!!! error TS2304: Cannot find name 'private'.
function foo1(x: private.package.x) { }
~~~~~~~
!!! error TS1215: Type expected. 'private' is a reserved word in strict mode
~~~~~~~
!!! error TS2304: Cannot find name 'private'.
~~~~~~~
!!! error TS1215: Type expected. 'package' is a reserved word in strict mode
function foo2(x: private.package.protected) { }
~~~~~~~
!!! error TS1215: Type expected. 'private' is a reserved word in strict mode
~~~~~~~
!!! error TS2304: Cannot find name 'private'.
~~~~~~~
!!! error TS1215: Type expected. 'package' is a reserved word in strict mode
~~~~~~~~~
!!! error TS1215: Type expected. 'protected' is a reserved word in strict mode
let b: interface.package.implements.B;
~
!!! error TS2300: Duplicate identifier 'b'.
~~~~~~~~~
!!! error TS1215: Type expected. 'interface' is a reserved word in strict mode
~~~~~~~~~
!!! error TS2304: Cannot find name 'interface'.
~~~~~~~
!!! error TS1215: Type expected. 'package' is a reserved word in strict mode
~~~~~~~~~~
!!! error TS1215: Type expected. 'implements' is a reserved word in strict mode
ublic();
~~~~~
!!! error TS2304: Cannot find name 'ublic'.
static();
~~~~~~
!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode
~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
}

View File

@@ -0,0 +1,57 @@
//// [strictModeReservedWord.ts]
let let = 10;
function foo() {
"use strict"
var public = 10;
var static = "hi";
let let = "blah";
var package = "hello"
function package() { }
function bar(private, implements, let) { }
function baz<implements, protected>() { }
function barn(cb: (private, public, package) => void) { }
barn((private, public, package) => { });
var myClass = class package extends public {}
var b: public.bar;
function foo(x: private.x) { }
function foo1(x: private.package.x) { }
function foo2(x: private.package.protected) { }
let b: interface.package.implements.B;
ublic();
static();
}
//// [strictModeReservedWord.js]
var let = 10;
function foo() {
"use strict";
var public = 10;
var static = "hi";
var let = "blah";
var package = "hello";
function package() { }
function bar(private, implements, let) { }
function baz() { }
function barn(cb) { }
barn(function (private, public, package) { });
var myClass = (function (_super) {
__extends(package, _super);
function package() {
_super.apply(this, arguments);
}
return package;
})(public);
var b;
function foo(x) { }
function foo1(x) { }
function foo2(x) { }
var b;
ublic();
static();
}

View File

@@ -0,0 +1,45 @@
tests/cases/compiler/strictModeReservedWord2.ts(2,11): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord2.ts(3,11): error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord2.ts(4,9): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord2.ts(4,18): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord2.ts(6,6): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord2.ts(13,12): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
==== tests/cases/compiler/strictModeReservedWord2.ts (6 errors) ====
"use strict"
interface public { }
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
interface implements {
~~~~~~~~~~
!!! error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
foo(package, protected);
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
~~~~~~~~~
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
}
enum package { }
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
enum foo {
public,
private,
pacakge
}
const enum private {
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
public,
private,
pacakge
}
const enum bar {
public,
private,
pacakge
}

View File

@@ -0,0 +1,37 @@
//// [strictModeReservedWord2.ts]
"use strict"
interface public { }
interface implements {
foo(package, protected);
}
enum package { }
enum foo {
public,
private,
pacakge
}
const enum private {
public,
private,
pacakge
}
const enum bar {
public,
private,
pacakge
}
//// [strictModeReservedWord2.js]
"use strict";
var package;
(function (package) {
})(package || (package = {}));
var foo;
(function (foo) {
foo[foo["public"] = 0] = "public";
foo[foo["private"] = 1] = "private";
foo[foo["pacakge"] = 2] = "pacakge";
})(foo || (foo = {}));

View File

@@ -0,0 +1,103 @@
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(4,17): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(4,26): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(4,34): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(5,9): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(5,19): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(5,28): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(7,22): error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(11,24): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(11,32): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(13,10): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(13,19): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(13,27): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(14,18): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,9): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,17): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(23,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2304: Cannot find name 'public'.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2304: Cannot find name 'public'.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS2304: Cannot find name 'package'.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS2304: Cannot find name 'package'.
==== tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts (24 errors) ====
interface public { }
class Foo {
constructor(private, public, static) {
~~~~~~~
!!! error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
private = public = static;
~~~~~~~
!!! error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}
public banana(x: public) { }
~~~~~~
!!! error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}
class C {
constructor(public public, let) {
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~
!!! error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}
foo1(private, static, public) {
~~~~~~~
!!! error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
function let() { }
~~~
!!! error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
var z = function let() { };
}
public pulbic() { } // No Error;
}
class D<public, private>{ }
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~~
!!! error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class E implements public { }
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
class F implements public.private.B { }
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
class F1 implements public.private.implements { }
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
class G extends package { }
~~~~~~~
!!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~~
!!! error TS2304: Cannot find name 'package'.
class H extends package.A { }
~~~~~~~
!!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~~
!!! error TS2304: Cannot find name 'package'.

View File

@@ -0,0 +1,89 @@
//// [strictModeReservedWordInClassDeclaration.ts]
interface public { }
class Foo {
constructor(private, public, static) {
private = public = static;
}
public banana(x: public) { }
}
class C {
constructor(public public, let) {
}
foo1(private, static, public) {
function let() { }
var z = function let() { };
}
public pulbic() { } // No Error;
}
class D<public, private>{ }
class E implements public { }
class F implements public.private.B { }
class F1 implements public.private.implements { }
class G extends package { }
class H extends package.A { }
//// [strictModeReservedWordInClassDeclaration.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Foo = (function () {
function Foo(private, public, static) {
private = public = static;
}
Foo.prototype.banana = function (x) { };
return Foo;
})();
var C = (function () {
function C(public, let) {
this.public = public;
}
C.prototype.foo1 = function (private, static, public) {
function let() { }
var z = function let() { };
};
C.prototype.pulbic = function () { }; // No Error;
return C;
})();
var D = (function () {
function D() {
}
return D;
})();
var E = (function () {
function E() {
}
return E;
})();
var F = (function () {
function F() {
}
return F;
})();
var F1 = (function () {
function F1() {
}
return F1;
})();
var G = (function (_super) {
__extends(G, _super);
function G() {
_super.apply(this, arguments);
}
return G;
})(package);
var H = (function (_super) {
__extends(H, _super);
function H() {
_super.apply(this, arguments);
}
return H;
})(package.A);

View File

@@ -0,0 +1,30 @@
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(2,6): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(3,10): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(4,7): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(5,15): error TS1212: Identifier expected. 'static' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(5,38): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,6): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,14): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
==== tests/cases/compiler/strictModeReservedWordInDestructuring.ts (7 errors) ====
"use strict"
var [public] = [1];
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
var { x: public } = { x: 1 };
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
var [[private]] = [["hello"]];
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
~~~~~~
!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
var {public, protected} = { public: 1, protected: 2 };
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
~~~~~~~~~
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode

View File

@@ -0,0 +1,15 @@
//// [strictModeReservedWordInDestructuring.ts]
"use strict"
var [public] = [1];
var { x: public } = { x: 1 };
var [[private]] = [["hello"]];
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
var {public, protected} = { public: 1, protected: 2 };
//// [strictModeReservedWordInDestructuring.js]
"use strict";
var public = ([1])[0];
var public = ({ x: 1 }).x;
var private = ([["hello"]])[0][0];
var _a = { y: { s: 1 }, z: { o: { p: 'h' } } }, static = _a.y.s, package = _a.z.o.p;
var _b = { public: 1, protected: 2 }, public = _b.public, protected = _b.protected;

View File

@@ -0,0 +1,12 @@
tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,8): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,25): error TS2307: Cannot find external module '1'.
==== tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts (2 errors) ====
"use strict"
import public = require("1");
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
~~~
!!! error TS2307: Cannot find external module '1'.

View File

@@ -0,0 +1,7 @@
//// [strictModeReservedWordInImportEqualDeclaration.ts]
"use strict"
import public = require("1");
//// [strictModeReservedWordInImportEqualDeclaration.js]
"use strict";

View File

@@ -0,0 +1,24 @@
tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts(2,8): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts(3,8): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts(4,8): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts(6,8): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts(6,16): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
==== tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts (5 errors) ====
"use strict"
module public { }
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
module private { }
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
module public.whatever {
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
}
module private.public.foo { }
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode

View File

@@ -0,0 +1,10 @@
//// [strictModeReservedWordInModuleDeclaration.ts]
"use strict"
module public { }
module private { }
module public.whatever {
}
module private.public.foo { }
//// [strictModeReservedWordInModuleDeclaration.js]
"use strict";

View File

@@ -0,0 +1,13 @@
//// [strictModeWordInExportDeclaration.ts]
"use strict"
var x = 1;
export { x as foo }
export { x as implements }
export { x as while }
//// [strictModeWordInExportDeclaration.js]
"use strict";
var x = 1;
export { x as foo };
export { x as implements };
export { x as while };

View File

@@ -0,0 +1,17 @@
=== tests/cases/compiler/strictModeWordInExportDeclaration.ts ===
"use strict"
var x = 1;
>x : number
export { x as foo }
>x : number
>foo : number
export { x as implements }
>x : number
>implements : number
export { x as while }
>x : number
>while : number

View File

@@ -0,0 +1,22 @@
tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,26): error TS2307: Cannot find external module './1'.
tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,16): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,30): error TS2307: Cannot find external module './1'.
tests/cases/compiler/strictModeWordInImportDeclaration.ts(4,20): error TS2307: Cannot find external module './1'.
==== tests/cases/compiler/strictModeWordInImportDeclaration.ts (5 errors) ====
"use strict"
import * as package from "./1"
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
~~~~~
!!! error TS2307: Cannot find external module './1'.
import {foo as private} from "./1"
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~
!!! error TS2307: Cannot find external module './1'.
import public from "./1"
~~~~~
!!! error TS2307: Cannot find external module './1'.

View File

@@ -0,0 +1,8 @@
//// [strictModeWordInImportDeclaration.ts]
"use strict"
import * as package from "./1"
import {foo as private} from "./1"
import public from "./1"
//// [strictModeWordInImportDeclaration.js]
"use strict";

View File

@@ -1,8 +1,7 @@
tests/cases/compiler/varArgConstructorMemberParameter.ts(10,18): error TS1003: Identifier expected.
tests/cases/compiler/varArgConstructorMemberParameter.ts(10,25): error TS1005: ',' expected.
==== tests/cases/compiler/varArgConstructorMemberParameter.ts (2 errors) ====
==== tests/cases/compiler/varArgConstructorMemberParameter.ts (1 errors) ====
class Foo1 {
constructor (...args: string[]) { }
}
@@ -13,8 +12,6 @@ tests/cases/compiler/varArgConstructorMemberParameter.ts(10,25): error TS1005: '
class Foo3 {
constructor (public ...args: string[]) { }
~~~~~~
!!! error TS1003: Identifier expected.
~~~
!!! error TS1005: ',' expected.
}

View File

@@ -29,7 +29,7 @@ var Foo2 = (function () {
return Foo2;
})();
var Foo3 = (function () {
function Foo3() {
function Foo3(public) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];

View File

@@ -0,0 +1,7 @@
class C {
public bar() {
var v = foo(
public blaz() {}
);
}
}

View File

@@ -0,0 +1,12 @@
import while = require("dfdf");
import * as while from "foo"
var typeof = 10;
function throw() {}
module void {}
var {while, return} = { while: 1, return: 2 };
var {this, switch: { continue} } = { this: 1, switch: { continue: 2 }};
var [debugger, if] = [1, 2];
enum void {}

View File

@@ -1,3 +0,0 @@
"use strict";
class A {}
class B extends A {}

View File

@@ -1,6 +0,0 @@
"use strict";
function foo() {
return 30;
}

View File

@@ -1,11 +0,0 @@
"use strict";
class A {
}
class B extends A {
}
function foo() {
return this.window;
}

View File

@@ -1,4 +0,0 @@
"use strict";
class A {
}

View File

@@ -1,18 +0,0 @@
function foo(...args) {
"use strict"
}
class A {
m() {
"use strict"
var v = () => {
return this.n();
};
}
n() {}
}
function bar(x: number = 10) {
"use strict"
}

View File

@@ -0,0 +1,26 @@
let let = 10;
function foo() {
"use strict"
var public = 10;
var static = "hi";
let let = "blah";
var package = "hello"
function package() { }
function bar(private, implements, let) { }
function baz<implements, protected>() { }
function barn(cb: (private, public, package) => void) { }
barn((private, public, package) => { });
var myClass = class package extends public {}
var b: public.bar;
function foo(x: private.x) { }
function foo1(x: private.package.x) { }
function foo2(x: private.package.protected) { }
let b: interface.package.implements.B;
ublic();
static();
}

View File

@@ -0,0 +1,23 @@
"use strict"
interface public { }
interface implements {
foo(package, protected);
}
enum package { }
enum foo {
public,
private,
pacakge
}
const enum private {
public,
private,
pacakge
}
const enum bar {
public,
private,
pacakge
}

View File

@@ -0,0 +1,28 @@
interface public { }
class Foo {
constructor(private, public, static) {
private = public = static;
}
public banana(x: public) { }
}
class C {
constructor(public public, let) {
}
foo1(private, static, public) {
function let() { }
var z = function let() { };
}
public pulbic() { } // No Error;
}
class D<public, private>{ }
class E implements public { }
class F implements public.private.B { }
class F1 implements public.private.implements { }
class G extends package { }
class H extends package.A { }

View File

@@ -0,0 +1,6 @@
"use strict"
var [public] = [1];
var { x: public } = { x: 1 };
var [[private]] = [["hello"]];
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
var {public, protected} = { public: 1, protected: 2 };

View File

@@ -0,0 +1,4 @@
// @module: commonjs
"use strict"
import public = require("1");

View File

@@ -0,0 +1,6 @@
"use strict"
module public { }
module private { }
module public.whatever {
}
module private.public.foo { }

View File

@@ -0,0 +1,6 @@
// @target: ES6
"use strict"
var x = 1;
export { x as foo }
export { x as implements }
export { x as while }

View File

@@ -0,0 +1,5 @@
// @target: ES6
"use strict"
import * as package from "./1"
import {foo as private} from "./1"
import public from "./1"