From b363a459ff8325d110b2614f9ede154def494a55 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 31 Mar 2015 14:12:35 -0700 Subject: [PATCH] Add support for semicolons in class bodies --- src/compiler/binder.ts | 1 - src/compiler/emitter.ts | 14 +- src/compiler/parser.ts | 13 +- src/compiler/types.ts | 6 + .../baselines/reference/APISample_compile.js | 106 +++++++-------- .../reference/APISample_compile.types | 112 ++++++++-------- tests/baselines/reference/APISample_linter.js | 122 +++++++++--------- .../reference/APISample_linter.types | 112 ++++++++-------- .../reference/APISample_transform.js | 106 +++++++-------- .../reference/APISample_transform.types | 112 ++++++++-------- .../baselines/reference/APISample_watcher.js | 106 +++++++-------- .../reference/APISample_watcher.types | 112 ++++++++-------- .../classWithSemicolonClassElement1.js | 12 ++ .../classWithSemicolonClassElement1.types | 6 + .../classWithSemicolonClassElement2.js | 14 ++ .../classWithSemicolonClassElement2.types | 7 + .../classWithSemicolonClassElementES61.js | 9 ++ .../classWithSemicolonClassElementES61.types | 6 + .../classWithSemicolonClassElementES62.js | 11 ++ .../classWithSemicolonClassElementES62.types | 7 + .../reference/es6ClassTest3.errors.txt | 23 ---- tests/baselines/reference/es6ClassTest3.js | 2 + tests/baselines/reference/es6ClassTest3.types | 37 ++++++ .../reference/exportDeclareClass1.errors.txt | 12 +- .../reference/parser0_004152.errors.txt | 5 +- tests/baselines/reference/parser0_004152.js | 1 + .../parserErrantSemicolonInClass1.errors.txt | 17 ++- .../parserErrantSemicolonInClass1.js | 1 + ...sWhenHittingUnexpectedSemicolon.errors.txt | 11 -- ...sRecoversWhenHittingUnexpectedSemicolon.js | 1 + ...coversWhenHittingUnexpectedSemicolon.types | 11 ++ .../reference/primitiveMembers.errors.txt | 8 +- tests/baselines/reference/primitiveMembers.js | 2 + .../classWithSemicolonClassElement1.ts | 3 + .../classWithSemicolonClassElement2.ts | 4 + .../classWithSemicolonClassElementES61.ts | 4 + .../classWithSemicolonClassElementES62.ts | 5 + 37 files changed, 666 insertions(+), 475 deletions(-) create mode 100644 tests/baselines/reference/classWithSemicolonClassElement1.js create mode 100644 tests/baselines/reference/classWithSemicolonClassElement1.types create mode 100644 tests/baselines/reference/classWithSemicolonClassElement2.js create mode 100644 tests/baselines/reference/classWithSemicolonClassElement2.types create mode 100644 tests/baselines/reference/classWithSemicolonClassElementES61.js create mode 100644 tests/baselines/reference/classWithSemicolonClassElementES61.types create mode 100644 tests/baselines/reference/classWithSemicolonClassElementES62.js create mode 100644 tests/baselines/reference/classWithSemicolonClassElementES62.types delete mode 100644 tests/baselines/reference/es6ClassTest3.errors.txt create mode 100644 tests/baselines/reference/es6ClassTest3.types delete mode 100644 tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.errors.txt create mode 100644 tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.types create mode 100644 tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement1.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement2.ts create mode 100644 tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES61.ts create mode 100644 tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES62.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d3dafb61e76..0ae33d08fd6 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -126,7 +126,6 @@ module ts { return (node).isExportEquals ? "export=" : "default"; case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: return node.flags & NodeFlags.Default ? "default" : undefined; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 60a09fb20ef..dc532972b43 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3219,7 +3219,11 @@ module ts { function emitMemberFunctionsForES5AndLower(node: ClassLikeDeclaration) { forEach(node.members, member => { - if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) { + if (member.kind === SyntaxKind.SemicolonClassElement) { + writeLine(); + write(";"); + } + else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) { if (!(member).body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -3292,7 +3296,9 @@ module ts { if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(member).body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) { + else if (member.kind === SyntaxKind.MethodDeclaration || + member.kind === SyntaxKind.GetAccessor || + member.kind === SyntaxKind.SetAccessor) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -3311,6 +3317,10 @@ module ts { emitEnd(member); emitTrailingComments(member); } + else if (member.kind === SyntaxKind.SemicolonClassElement) { + writeLine(); + write(";"); + } } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f728536e72a..2972fba3979 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1609,7 +1609,11 @@ module ts { case ParsingContext.TypeMembers: return isStartOfTypeMember(); case ParsingContext.ClassMembers: - return lookAhead(isClassMemberStart); + // We allow semicolons as class elements (as specified by ES6) as long as we're + // not in error recovery. If we're in error recovery, we don't want an errant + // semicolon to be treated as a class member (since they're almost always used + // for statements. + return lookAhead(isClassMemberStart) || (token === SyntaxKind.SemicolonToken && !inErrorRecovery); case ParsingContext.EnumMembers: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. @@ -1996,6 +2000,7 @@ module ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.PropertyDeclaration: + case SyntaxKind.SemicolonClassElement: return true; } } @@ -4692,6 +4697,12 @@ module ts { } function parseClassElement(): ClassElement { + if (token === SyntaxKind.SemicolonToken) { + let result = createNode(SyntaxKind.SemicolonClassElement); + nextToken(); + return finishNode(result); + } + let fullStart = getNodePos(); let decorators = parseDecorators(); let modifiers = parseModifiers(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 08c8985b144..82af3dfde08 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -208,6 +208,7 @@ module ts { // Misc TemplateSpan, HeritageClauseElement, + SemicolonClassElement, // Element Block, VariableStatement, @@ -538,6 +539,11 @@ module ts { body?: Block; } + // For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. + export interface SemicolonClassElement extends ClassElement { + _semicolonClassElementBrand: any; + } + // See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a // ClassElement and an ObjectLiteralElement. export interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 9bbd1bb1af4..3d49f246132 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -237,57 +237,58 @@ declare module "typescript" { OmittedExpression = 175, TemplateSpan = 176, HeritageClauseElement = 177, - Block = 178, - VariableStatement = 179, - EmptyStatement = 180, - ExpressionStatement = 181, - IfStatement = 182, - DoStatement = 183, - WhileStatement = 184, - ForStatement = 185, - ForInStatement = 186, - ForOfStatement = 187, - ContinueStatement = 188, - BreakStatement = 189, - ReturnStatement = 190, - WithStatement = 191, - SwitchStatement = 192, - LabeledStatement = 193, - ThrowStatement = 194, - TryStatement = 195, - DebuggerStatement = 196, - VariableDeclaration = 197, - VariableDeclarationList = 198, - FunctionDeclaration = 199, - ClassDeclaration = 200, - InterfaceDeclaration = 201, - TypeAliasDeclaration = 202, - EnumDeclaration = 203, - ModuleDeclaration = 204, - ModuleBlock = 205, - CaseBlock = 206, - ImportEqualsDeclaration = 207, - ImportDeclaration = 208, - ImportClause = 209, - NamespaceImport = 210, - NamedImports = 211, - ImportSpecifier = 212, - ExportAssignment = 213, - ExportDeclaration = 214, - NamedExports = 215, - ExportSpecifier = 216, - MissingDeclaration = 217, - ExternalModuleReference = 218, - CaseClause = 219, - DefaultClause = 220, - HeritageClause = 221, - CatchClause = 222, - PropertyAssignment = 223, - ShorthandPropertyAssignment = 224, - EnumMember = 225, - SourceFile = 226, - SyntaxList = 227, - Count = 228, + SemicolonClassElement = 178, + Block = 179, + VariableStatement = 180, + EmptyStatement = 181, + ExpressionStatement = 182, + IfStatement = 183, + DoStatement = 184, + WhileStatement = 185, + ForStatement = 186, + ForInStatement = 187, + ForOfStatement = 188, + ContinueStatement = 189, + BreakStatement = 190, + ReturnStatement = 191, + WithStatement = 192, + SwitchStatement = 193, + LabeledStatement = 194, + ThrowStatement = 195, + TryStatement = 196, + DebuggerStatement = 197, + VariableDeclaration = 198, + VariableDeclarationList = 199, + FunctionDeclaration = 200, + ClassDeclaration = 201, + InterfaceDeclaration = 202, + TypeAliasDeclaration = 203, + EnumDeclaration = 204, + ModuleDeclaration = 205, + ModuleBlock = 206, + CaseBlock = 207, + ImportEqualsDeclaration = 208, + ImportDeclaration = 209, + ImportClause = 210, + NamespaceImport = 211, + NamedImports = 212, + ImportSpecifier = 213, + ExportAssignment = 214, + ExportDeclaration = 215, + NamedExports = 216, + ExportSpecifier = 217, + MissingDeclaration = 218, + ExternalModuleReference = 219, + CaseClause = 220, + DefaultClause = 221, + HeritageClause = 222, + CatchClause = 223, + PropertyAssignment = 224, + ShorthandPropertyAssignment = 225, + EnumMember = 226, + SourceFile = 227, + SyntaxList = 228, + Count = 229, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, @@ -471,6 +472,9 @@ declare module "typescript" { interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { body?: Block; } + interface SemicolonClassElement extends ClassElement { + _semicolonClassElementBrand: any; + } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { _accessorDeclarationBrand: any; body: Block; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index ca965a9161d..2f25a4a588a 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -729,157 +729,160 @@ declare module "typescript" { HeritageClauseElement = 177, >HeritageClauseElement : SyntaxKind - Block = 178, + SemicolonClassElement = 178, +>SemicolonClassElement : SyntaxKind + + Block = 179, >Block : SyntaxKind - VariableStatement = 179, + VariableStatement = 180, >VariableStatement : SyntaxKind - EmptyStatement = 180, + EmptyStatement = 181, >EmptyStatement : SyntaxKind - ExpressionStatement = 181, + ExpressionStatement = 182, >ExpressionStatement : SyntaxKind - IfStatement = 182, + IfStatement = 183, >IfStatement : SyntaxKind - DoStatement = 183, + DoStatement = 184, >DoStatement : SyntaxKind - WhileStatement = 184, + WhileStatement = 185, >WhileStatement : SyntaxKind - ForStatement = 185, + ForStatement = 186, >ForStatement : SyntaxKind - ForInStatement = 186, + ForInStatement = 187, >ForInStatement : SyntaxKind - ForOfStatement = 187, + ForOfStatement = 188, >ForOfStatement : SyntaxKind - ContinueStatement = 188, + ContinueStatement = 189, >ContinueStatement : SyntaxKind - BreakStatement = 189, + BreakStatement = 190, >BreakStatement : SyntaxKind - ReturnStatement = 190, + ReturnStatement = 191, >ReturnStatement : SyntaxKind - WithStatement = 191, + WithStatement = 192, >WithStatement : SyntaxKind - SwitchStatement = 192, + SwitchStatement = 193, >SwitchStatement : SyntaxKind - LabeledStatement = 193, + LabeledStatement = 194, >LabeledStatement : SyntaxKind - ThrowStatement = 194, + ThrowStatement = 195, >ThrowStatement : SyntaxKind - TryStatement = 195, + TryStatement = 196, >TryStatement : SyntaxKind - DebuggerStatement = 196, + DebuggerStatement = 197, >DebuggerStatement : SyntaxKind - VariableDeclaration = 197, + VariableDeclaration = 198, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 198, + VariableDeclarationList = 199, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 199, + FunctionDeclaration = 200, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 200, + ClassDeclaration = 201, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 201, + InterfaceDeclaration = 202, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 202, + TypeAliasDeclaration = 203, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 203, + EnumDeclaration = 204, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 204, + ModuleDeclaration = 205, >ModuleDeclaration : SyntaxKind - ModuleBlock = 205, + ModuleBlock = 206, >ModuleBlock : SyntaxKind - CaseBlock = 206, + CaseBlock = 207, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 207, + ImportEqualsDeclaration = 208, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 208, + ImportDeclaration = 209, >ImportDeclaration : SyntaxKind - ImportClause = 209, + ImportClause = 210, >ImportClause : SyntaxKind - NamespaceImport = 210, + NamespaceImport = 211, >NamespaceImport : SyntaxKind - NamedImports = 211, + NamedImports = 212, >NamedImports : SyntaxKind - ImportSpecifier = 212, + ImportSpecifier = 213, >ImportSpecifier : SyntaxKind - ExportAssignment = 213, + ExportAssignment = 214, >ExportAssignment : SyntaxKind - ExportDeclaration = 214, + ExportDeclaration = 215, >ExportDeclaration : SyntaxKind - NamedExports = 215, + NamedExports = 216, >NamedExports : SyntaxKind - ExportSpecifier = 216, + ExportSpecifier = 217, >ExportSpecifier : SyntaxKind - MissingDeclaration = 217, + MissingDeclaration = 218, >MissingDeclaration : SyntaxKind - ExternalModuleReference = 218, + ExternalModuleReference = 219, >ExternalModuleReference : SyntaxKind - CaseClause = 219, + CaseClause = 220, >CaseClause : SyntaxKind - DefaultClause = 220, + DefaultClause = 221, >DefaultClause : SyntaxKind - HeritageClause = 221, + HeritageClause = 222, >HeritageClause : SyntaxKind - CatchClause = 222, + CatchClause = 223, >CatchClause : SyntaxKind - PropertyAssignment = 223, + PropertyAssignment = 224, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 224, + ShorthandPropertyAssignment = 225, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 225, + EnumMember = 226, >EnumMember : SyntaxKind - SourceFile = 226, + SourceFile = 227, >SourceFile : SyntaxKind - SyntaxList = 227, + SyntaxList = 228, >SyntaxList : SyntaxKind - Count = 228, + Count = 229, >Count : SyntaxKind FirstAssignment = 53, @@ -1436,6 +1439,13 @@ declare module "typescript" { body?: Block; >body : Block >Block : Block + } + interface SemicolonClassElement extends ClassElement { +>SemicolonClassElement : SemicolonClassElement +>ClassElement : ClassElement + + _semicolonClassElementBrand: any; +>_semicolonClassElementBrand : any } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { >AccessorDeclaration : AccessorDeclaration diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index d7d3ece0c86..71e67ebec6b 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -268,57 +268,58 @@ declare module "typescript" { OmittedExpression = 175, TemplateSpan = 176, HeritageClauseElement = 177, - Block = 178, - VariableStatement = 179, - EmptyStatement = 180, - ExpressionStatement = 181, - IfStatement = 182, - DoStatement = 183, - WhileStatement = 184, - ForStatement = 185, - ForInStatement = 186, - ForOfStatement = 187, - ContinueStatement = 188, - BreakStatement = 189, - ReturnStatement = 190, - WithStatement = 191, - SwitchStatement = 192, - LabeledStatement = 193, - ThrowStatement = 194, - TryStatement = 195, - DebuggerStatement = 196, - VariableDeclaration = 197, - VariableDeclarationList = 198, - FunctionDeclaration = 199, - ClassDeclaration = 200, - InterfaceDeclaration = 201, - TypeAliasDeclaration = 202, - EnumDeclaration = 203, - ModuleDeclaration = 204, - ModuleBlock = 205, - CaseBlock = 206, - ImportEqualsDeclaration = 207, - ImportDeclaration = 208, - ImportClause = 209, - NamespaceImport = 210, - NamedImports = 211, - ImportSpecifier = 212, - ExportAssignment = 213, - ExportDeclaration = 214, - NamedExports = 215, - ExportSpecifier = 216, - MissingDeclaration = 217, - ExternalModuleReference = 218, - CaseClause = 219, - DefaultClause = 220, - HeritageClause = 221, - CatchClause = 222, - PropertyAssignment = 223, - ShorthandPropertyAssignment = 224, - EnumMember = 225, - SourceFile = 226, - SyntaxList = 227, - Count = 228, + SemicolonClassElement = 178, + Block = 179, + VariableStatement = 180, + EmptyStatement = 181, + ExpressionStatement = 182, + IfStatement = 183, + DoStatement = 184, + WhileStatement = 185, + ForStatement = 186, + ForInStatement = 187, + ForOfStatement = 188, + ContinueStatement = 189, + BreakStatement = 190, + ReturnStatement = 191, + WithStatement = 192, + SwitchStatement = 193, + LabeledStatement = 194, + ThrowStatement = 195, + TryStatement = 196, + DebuggerStatement = 197, + VariableDeclaration = 198, + VariableDeclarationList = 199, + FunctionDeclaration = 200, + ClassDeclaration = 201, + InterfaceDeclaration = 202, + TypeAliasDeclaration = 203, + EnumDeclaration = 204, + ModuleDeclaration = 205, + ModuleBlock = 206, + CaseBlock = 207, + ImportEqualsDeclaration = 208, + ImportDeclaration = 209, + ImportClause = 210, + NamespaceImport = 211, + NamedImports = 212, + ImportSpecifier = 213, + ExportAssignment = 214, + ExportDeclaration = 215, + NamedExports = 216, + ExportSpecifier = 217, + MissingDeclaration = 218, + ExternalModuleReference = 219, + CaseClause = 220, + DefaultClause = 221, + HeritageClause = 222, + CatchClause = 223, + PropertyAssignment = 224, + ShorthandPropertyAssignment = 225, + EnumMember = 226, + SourceFile = 227, + SyntaxList = 228, + Count = 229, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, @@ -502,6 +503,9 @@ declare module "typescript" { interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { body?: Block; } + interface SemicolonClassElement extends ClassElement { + _semicolonClassElementBrand: any; + } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { _accessorDeclarationBrand: any; body: Block; @@ -2052,21 +2056,21 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 185 /* ForStatement */: - case 186 /* ForInStatement */: - case 184 /* WhileStatement */: - case 183 /* DoStatement */: - if (node.statement.kind !== 178 /* Block */) { + case 186 /* ForStatement */: + case 187 /* ForInStatement */: + case 185 /* WhileStatement */: + case 184 /* DoStatement */: + if (node.statement.kind !== 179 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 182 /* IfStatement */: + case 183 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 178 /* Block */) { + if (ifStatement.thenStatement.kind !== 179 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 178 /* Block */ && ifStatement.elseStatement.kind !== 182 /* IfStatement */) { + ifStatement.elseStatement.kind !== 179 /* Block */ && ifStatement.elseStatement.kind !== 183 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index e68910b26e6..eb4a2f8a02e 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -875,157 +875,160 @@ declare module "typescript" { HeritageClauseElement = 177, >HeritageClauseElement : SyntaxKind - Block = 178, + SemicolonClassElement = 178, +>SemicolonClassElement : SyntaxKind + + Block = 179, >Block : SyntaxKind - VariableStatement = 179, + VariableStatement = 180, >VariableStatement : SyntaxKind - EmptyStatement = 180, + EmptyStatement = 181, >EmptyStatement : SyntaxKind - ExpressionStatement = 181, + ExpressionStatement = 182, >ExpressionStatement : SyntaxKind - IfStatement = 182, + IfStatement = 183, >IfStatement : SyntaxKind - DoStatement = 183, + DoStatement = 184, >DoStatement : SyntaxKind - WhileStatement = 184, + WhileStatement = 185, >WhileStatement : SyntaxKind - ForStatement = 185, + ForStatement = 186, >ForStatement : SyntaxKind - ForInStatement = 186, + ForInStatement = 187, >ForInStatement : SyntaxKind - ForOfStatement = 187, + ForOfStatement = 188, >ForOfStatement : SyntaxKind - ContinueStatement = 188, + ContinueStatement = 189, >ContinueStatement : SyntaxKind - BreakStatement = 189, + BreakStatement = 190, >BreakStatement : SyntaxKind - ReturnStatement = 190, + ReturnStatement = 191, >ReturnStatement : SyntaxKind - WithStatement = 191, + WithStatement = 192, >WithStatement : SyntaxKind - SwitchStatement = 192, + SwitchStatement = 193, >SwitchStatement : SyntaxKind - LabeledStatement = 193, + LabeledStatement = 194, >LabeledStatement : SyntaxKind - ThrowStatement = 194, + ThrowStatement = 195, >ThrowStatement : SyntaxKind - TryStatement = 195, + TryStatement = 196, >TryStatement : SyntaxKind - DebuggerStatement = 196, + DebuggerStatement = 197, >DebuggerStatement : SyntaxKind - VariableDeclaration = 197, + VariableDeclaration = 198, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 198, + VariableDeclarationList = 199, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 199, + FunctionDeclaration = 200, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 200, + ClassDeclaration = 201, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 201, + InterfaceDeclaration = 202, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 202, + TypeAliasDeclaration = 203, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 203, + EnumDeclaration = 204, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 204, + ModuleDeclaration = 205, >ModuleDeclaration : SyntaxKind - ModuleBlock = 205, + ModuleBlock = 206, >ModuleBlock : SyntaxKind - CaseBlock = 206, + CaseBlock = 207, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 207, + ImportEqualsDeclaration = 208, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 208, + ImportDeclaration = 209, >ImportDeclaration : SyntaxKind - ImportClause = 209, + ImportClause = 210, >ImportClause : SyntaxKind - NamespaceImport = 210, + NamespaceImport = 211, >NamespaceImport : SyntaxKind - NamedImports = 211, + NamedImports = 212, >NamedImports : SyntaxKind - ImportSpecifier = 212, + ImportSpecifier = 213, >ImportSpecifier : SyntaxKind - ExportAssignment = 213, + ExportAssignment = 214, >ExportAssignment : SyntaxKind - ExportDeclaration = 214, + ExportDeclaration = 215, >ExportDeclaration : SyntaxKind - NamedExports = 215, + NamedExports = 216, >NamedExports : SyntaxKind - ExportSpecifier = 216, + ExportSpecifier = 217, >ExportSpecifier : SyntaxKind - MissingDeclaration = 217, + MissingDeclaration = 218, >MissingDeclaration : SyntaxKind - ExternalModuleReference = 218, + ExternalModuleReference = 219, >ExternalModuleReference : SyntaxKind - CaseClause = 219, + CaseClause = 220, >CaseClause : SyntaxKind - DefaultClause = 220, + DefaultClause = 221, >DefaultClause : SyntaxKind - HeritageClause = 221, + HeritageClause = 222, >HeritageClause : SyntaxKind - CatchClause = 222, + CatchClause = 223, >CatchClause : SyntaxKind - PropertyAssignment = 223, + PropertyAssignment = 224, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 224, + ShorthandPropertyAssignment = 225, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 225, + EnumMember = 226, >EnumMember : SyntaxKind - SourceFile = 226, + SourceFile = 227, >SourceFile : SyntaxKind - SyntaxList = 227, + SyntaxList = 228, >SyntaxList : SyntaxKind - Count = 228, + Count = 229, >Count : SyntaxKind FirstAssignment = 53, @@ -1582,6 +1585,13 @@ declare module "typescript" { body?: Block; >body : Block >Block : Block + } + interface SemicolonClassElement extends ClassElement { +>SemicolonClassElement : SemicolonClassElement +>ClassElement : ClassElement + + _semicolonClassElementBrand: any; +>_semicolonClassElementBrand : any } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { >AccessorDeclaration : AccessorDeclaration diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index aac968cade7..cacd6bed772 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -269,57 +269,58 @@ declare module "typescript" { OmittedExpression = 175, TemplateSpan = 176, HeritageClauseElement = 177, - Block = 178, - VariableStatement = 179, - EmptyStatement = 180, - ExpressionStatement = 181, - IfStatement = 182, - DoStatement = 183, - WhileStatement = 184, - ForStatement = 185, - ForInStatement = 186, - ForOfStatement = 187, - ContinueStatement = 188, - BreakStatement = 189, - ReturnStatement = 190, - WithStatement = 191, - SwitchStatement = 192, - LabeledStatement = 193, - ThrowStatement = 194, - TryStatement = 195, - DebuggerStatement = 196, - VariableDeclaration = 197, - VariableDeclarationList = 198, - FunctionDeclaration = 199, - ClassDeclaration = 200, - InterfaceDeclaration = 201, - TypeAliasDeclaration = 202, - EnumDeclaration = 203, - ModuleDeclaration = 204, - ModuleBlock = 205, - CaseBlock = 206, - ImportEqualsDeclaration = 207, - ImportDeclaration = 208, - ImportClause = 209, - NamespaceImport = 210, - NamedImports = 211, - ImportSpecifier = 212, - ExportAssignment = 213, - ExportDeclaration = 214, - NamedExports = 215, - ExportSpecifier = 216, - MissingDeclaration = 217, - ExternalModuleReference = 218, - CaseClause = 219, - DefaultClause = 220, - HeritageClause = 221, - CatchClause = 222, - PropertyAssignment = 223, - ShorthandPropertyAssignment = 224, - EnumMember = 225, - SourceFile = 226, - SyntaxList = 227, - Count = 228, + SemicolonClassElement = 178, + Block = 179, + VariableStatement = 180, + EmptyStatement = 181, + ExpressionStatement = 182, + IfStatement = 183, + DoStatement = 184, + WhileStatement = 185, + ForStatement = 186, + ForInStatement = 187, + ForOfStatement = 188, + ContinueStatement = 189, + BreakStatement = 190, + ReturnStatement = 191, + WithStatement = 192, + SwitchStatement = 193, + LabeledStatement = 194, + ThrowStatement = 195, + TryStatement = 196, + DebuggerStatement = 197, + VariableDeclaration = 198, + VariableDeclarationList = 199, + FunctionDeclaration = 200, + ClassDeclaration = 201, + InterfaceDeclaration = 202, + TypeAliasDeclaration = 203, + EnumDeclaration = 204, + ModuleDeclaration = 205, + ModuleBlock = 206, + CaseBlock = 207, + ImportEqualsDeclaration = 208, + ImportDeclaration = 209, + ImportClause = 210, + NamespaceImport = 211, + NamedImports = 212, + ImportSpecifier = 213, + ExportAssignment = 214, + ExportDeclaration = 215, + NamedExports = 216, + ExportSpecifier = 217, + MissingDeclaration = 218, + ExternalModuleReference = 219, + CaseClause = 220, + DefaultClause = 221, + HeritageClause = 222, + CatchClause = 223, + PropertyAssignment = 224, + ShorthandPropertyAssignment = 225, + EnumMember = 226, + SourceFile = 227, + SyntaxList = 228, + Count = 229, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, @@ -503,6 +504,9 @@ declare module "typescript" { interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { body?: Block; } + interface SemicolonClassElement extends ClassElement { + _semicolonClassElementBrand: any; + } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { _accessorDeclarationBrand: any; body: Block; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 9c546b8c828..284588b13f9 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -825,157 +825,160 @@ declare module "typescript" { HeritageClauseElement = 177, >HeritageClauseElement : SyntaxKind - Block = 178, + SemicolonClassElement = 178, +>SemicolonClassElement : SyntaxKind + + Block = 179, >Block : SyntaxKind - VariableStatement = 179, + VariableStatement = 180, >VariableStatement : SyntaxKind - EmptyStatement = 180, + EmptyStatement = 181, >EmptyStatement : SyntaxKind - ExpressionStatement = 181, + ExpressionStatement = 182, >ExpressionStatement : SyntaxKind - IfStatement = 182, + IfStatement = 183, >IfStatement : SyntaxKind - DoStatement = 183, + DoStatement = 184, >DoStatement : SyntaxKind - WhileStatement = 184, + WhileStatement = 185, >WhileStatement : SyntaxKind - ForStatement = 185, + ForStatement = 186, >ForStatement : SyntaxKind - ForInStatement = 186, + ForInStatement = 187, >ForInStatement : SyntaxKind - ForOfStatement = 187, + ForOfStatement = 188, >ForOfStatement : SyntaxKind - ContinueStatement = 188, + ContinueStatement = 189, >ContinueStatement : SyntaxKind - BreakStatement = 189, + BreakStatement = 190, >BreakStatement : SyntaxKind - ReturnStatement = 190, + ReturnStatement = 191, >ReturnStatement : SyntaxKind - WithStatement = 191, + WithStatement = 192, >WithStatement : SyntaxKind - SwitchStatement = 192, + SwitchStatement = 193, >SwitchStatement : SyntaxKind - LabeledStatement = 193, + LabeledStatement = 194, >LabeledStatement : SyntaxKind - ThrowStatement = 194, + ThrowStatement = 195, >ThrowStatement : SyntaxKind - TryStatement = 195, + TryStatement = 196, >TryStatement : SyntaxKind - DebuggerStatement = 196, + DebuggerStatement = 197, >DebuggerStatement : SyntaxKind - VariableDeclaration = 197, + VariableDeclaration = 198, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 198, + VariableDeclarationList = 199, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 199, + FunctionDeclaration = 200, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 200, + ClassDeclaration = 201, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 201, + InterfaceDeclaration = 202, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 202, + TypeAliasDeclaration = 203, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 203, + EnumDeclaration = 204, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 204, + ModuleDeclaration = 205, >ModuleDeclaration : SyntaxKind - ModuleBlock = 205, + ModuleBlock = 206, >ModuleBlock : SyntaxKind - CaseBlock = 206, + CaseBlock = 207, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 207, + ImportEqualsDeclaration = 208, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 208, + ImportDeclaration = 209, >ImportDeclaration : SyntaxKind - ImportClause = 209, + ImportClause = 210, >ImportClause : SyntaxKind - NamespaceImport = 210, + NamespaceImport = 211, >NamespaceImport : SyntaxKind - NamedImports = 211, + NamedImports = 212, >NamedImports : SyntaxKind - ImportSpecifier = 212, + ImportSpecifier = 213, >ImportSpecifier : SyntaxKind - ExportAssignment = 213, + ExportAssignment = 214, >ExportAssignment : SyntaxKind - ExportDeclaration = 214, + ExportDeclaration = 215, >ExportDeclaration : SyntaxKind - NamedExports = 215, + NamedExports = 216, >NamedExports : SyntaxKind - ExportSpecifier = 216, + ExportSpecifier = 217, >ExportSpecifier : SyntaxKind - MissingDeclaration = 217, + MissingDeclaration = 218, >MissingDeclaration : SyntaxKind - ExternalModuleReference = 218, + ExternalModuleReference = 219, >ExternalModuleReference : SyntaxKind - CaseClause = 219, + CaseClause = 220, >CaseClause : SyntaxKind - DefaultClause = 220, + DefaultClause = 221, >DefaultClause : SyntaxKind - HeritageClause = 221, + HeritageClause = 222, >HeritageClause : SyntaxKind - CatchClause = 222, + CatchClause = 223, >CatchClause : SyntaxKind - PropertyAssignment = 223, + PropertyAssignment = 224, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 224, + ShorthandPropertyAssignment = 225, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 225, + EnumMember = 226, >EnumMember : SyntaxKind - SourceFile = 226, + SourceFile = 227, >SourceFile : SyntaxKind - SyntaxList = 227, + SyntaxList = 228, >SyntaxList : SyntaxKind - Count = 228, + Count = 229, >Count : SyntaxKind FirstAssignment = 53, @@ -1532,6 +1535,13 @@ declare module "typescript" { body?: Block; >body : Block >Block : Block + } + interface SemicolonClassElement extends ClassElement { +>SemicolonClassElement : SemicolonClassElement +>ClassElement : ClassElement + + _semicolonClassElementBrand: any; +>_semicolonClassElementBrand : any } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { >AccessorDeclaration : AccessorDeclaration diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index e3280bfb2cf..5b04b7cff17 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -306,57 +306,58 @@ declare module "typescript" { OmittedExpression = 175, TemplateSpan = 176, HeritageClauseElement = 177, - Block = 178, - VariableStatement = 179, - EmptyStatement = 180, - ExpressionStatement = 181, - IfStatement = 182, - DoStatement = 183, - WhileStatement = 184, - ForStatement = 185, - ForInStatement = 186, - ForOfStatement = 187, - ContinueStatement = 188, - BreakStatement = 189, - ReturnStatement = 190, - WithStatement = 191, - SwitchStatement = 192, - LabeledStatement = 193, - ThrowStatement = 194, - TryStatement = 195, - DebuggerStatement = 196, - VariableDeclaration = 197, - VariableDeclarationList = 198, - FunctionDeclaration = 199, - ClassDeclaration = 200, - InterfaceDeclaration = 201, - TypeAliasDeclaration = 202, - EnumDeclaration = 203, - ModuleDeclaration = 204, - ModuleBlock = 205, - CaseBlock = 206, - ImportEqualsDeclaration = 207, - ImportDeclaration = 208, - ImportClause = 209, - NamespaceImport = 210, - NamedImports = 211, - ImportSpecifier = 212, - ExportAssignment = 213, - ExportDeclaration = 214, - NamedExports = 215, - ExportSpecifier = 216, - MissingDeclaration = 217, - ExternalModuleReference = 218, - CaseClause = 219, - DefaultClause = 220, - HeritageClause = 221, - CatchClause = 222, - PropertyAssignment = 223, - ShorthandPropertyAssignment = 224, - EnumMember = 225, - SourceFile = 226, - SyntaxList = 227, - Count = 228, + SemicolonClassElement = 178, + Block = 179, + VariableStatement = 180, + EmptyStatement = 181, + ExpressionStatement = 182, + IfStatement = 183, + DoStatement = 184, + WhileStatement = 185, + ForStatement = 186, + ForInStatement = 187, + ForOfStatement = 188, + ContinueStatement = 189, + BreakStatement = 190, + ReturnStatement = 191, + WithStatement = 192, + SwitchStatement = 193, + LabeledStatement = 194, + ThrowStatement = 195, + TryStatement = 196, + DebuggerStatement = 197, + VariableDeclaration = 198, + VariableDeclarationList = 199, + FunctionDeclaration = 200, + ClassDeclaration = 201, + InterfaceDeclaration = 202, + TypeAliasDeclaration = 203, + EnumDeclaration = 204, + ModuleDeclaration = 205, + ModuleBlock = 206, + CaseBlock = 207, + ImportEqualsDeclaration = 208, + ImportDeclaration = 209, + ImportClause = 210, + NamespaceImport = 211, + NamedImports = 212, + ImportSpecifier = 213, + ExportAssignment = 214, + ExportDeclaration = 215, + NamedExports = 216, + ExportSpecifier = 217, + MissingDeclaration = 218, + ExternalModuleReference = 219, + CaseClause = 220, + DefaultClause = 221, + HeritageClause = 222, + CatchClause = 223, + PropertyAssignment = 224, + ShorthandPropertyAssignment = 225, + EnumMember = 226, + SourceFile = 227, + SyntaxList = 228, + Count = 229, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, @@ -540,6 +541,9 @@ declare module "typescript" { interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { body?: Block; } + interface SemicolonClassElement extends ClassElement { + _semicolonClassElementBrand: any; + } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { _accessorDeclarationBrand: any; body: Block; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 6507fa41e23..077d5fb8c66 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -998,157 +998,160 @@ declare module "typescript" { HeritageClauseElement = 177, >HeritageClauseElement : SyntaxKind - Block = 178, + SemicolonClassElement = 178, +>SemicolonClassElement : SyntaxKind + + Block = 179, >Block : SyntaxKind - VariableStatement = 179, + VariableStatement = 180, >VariableStatement : SyntaxKind - EmptyStatement = 180, + EmptyStatement = 181, >EmptyStatement : SyntaxKind - ExpressionStatement = 181, + ExpressionStatement = 182, >ExpressionStatement : SyntaxKind - IfStatement = 182, + IfStatement = 183, >IfStatement : SyntaxKind - DoStatement = 183, + DoStatement = 184, >DoStatement : SyntaxKind - WhileStatement = 184, + WhileStatement = 185, >WhileStatement : SyntaxKind - ForStatement = 185, + ForStatement = 186, >ForStatement : SyntaxKind - ForInStatement = 186, + ForInStatement = 187, >ForInStatement : SyntaxKind - ForOfStatement = 187, + ForOfStatement = 188, >ForOfStatement : SyntaxKind - ContinueStatement = 188, + ContinueStatement = 189, >ContinueStatement : SyntaxKind - BreakStatement = 189, + BreakStatement = 190, >BreakStatement : SyntaxKind - ReturnStatement = 190, + ReturnStatement = 191, >ReturnStatement : SyntaxKind - WithStatement = 191, + WithStatement = 192, >WithStatement : SyntaxKind - SwitchStatement = 192, + SwitchStatement = 193, >SwitchStatement : SyntaxKind - LabeledStatement = 193, + LabeledStatement = 194, >LabeledStatement : SyntaxKind - ThrowStatement = 194, + ThrowStatement = 195, >ThrowStatement : SyntaxKind - TryStatement = 195, + TryStatement = 196, >TryStatement : SyntaxKind - DebuggerStatement = 196, + DebuggerStatement = 197, >DebuggerStatement : SyntaxKind - VariableDeclaration = 197, + VariableDeclaration = 198, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 198, + VariableDeclarationList = 199, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 199, + FunctionDeclaration = 200, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 200, + ClassDeclaration = 201, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 201, + InterfaceDeclaration = 202, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 202, + TypeAliasDeclaration = 203, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 203, + EnumDeclaration = 204, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 204, + ModuleDeclaration = 205, >ModuleDeclaration : SyntaxKind - ModuleBlock = 205, + ModuleBlock = 206, >ModuleBlock : SyntaxKind - CaseBlock = 206, + CaseBlock = 207, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 207, + ImportEqualsDeclaration = 208, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 208, + ImportDeclaration = 209, >ImportDeclaration : SyntaxKind - ImportClause = 209, + ImportClause = 210, >ImportClause : SyntaxKind - NamespaceImport = 210, + NamespaceImport = 211, >NamespaceImport : SyntaxKind - NamedImports = 211, + NamedImports = 212, >NamedImports : SyntaxKind - ImportSpecifier = 212, + ImportSpecifier = 213, >ImportSpecifier : SyntaxKind - ExportAssignment = 213, + ExportAssignment = 214, >ExportAssignment : SyntaxKind - ExportDeclaration = 214, + ExportDeclaration = 215, >ExportDeclaration : SyntaxKind - NamedExports = 215, + NamedExports = 216, >NamedExports : SyntaxKind - ExportSpecifier = 216, + ExportSpecifier = 217, >ExportSpecifier : SyntaxKind - MissingDeclaration = 217, + MissingDeclaration = 218, >MissingDeclaration : SyntaxKind - ExternalModuleReference = 218, + ExternalModuleReference = 219, >ExternalModuleReference : SyntaxKind - CaseClause = 219, + CaseClause = 220, >CaseClause : SyntaxKind - DefaultClause = 220, + DefaultClause = 221, >DefaultClause : SyntaxKind - HeritageClause = 221, + HeritageClause = 222, >HeritageClause : SyntaxKind - CatchClause = 222, + CatchClause = 223, >CatchClause : SyntaxKind - PropertyAssignment = 223, + PropertyAssignment = 224, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 224, + ShorthandPropertyAssignment = 225, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 225, + EnumMember = 226, >EnumMember : SyntaxKind - SourceFile = 226, + SourceFile = 227, >SourceFile : SyntaxKind - SyntaxList = 227, + SyntaxList = 228, >SyntaxList : SyntaxKind - Count = 228, + Count = 229, >Count : SyntaxKind FirstAssignment = 53, @@ -1705,6 +1708,13 @@ declare module "typescript" { body?: Block; >body : Block >Block : Block + } + interface SemicolonClassElement extends ClassElement { +>SemicolonClassElement : SemicolonClassElement +>ClassElement : ClassElement + + _semicolonClassElementBrand: any; +>_semicolonClassElementBrand : any } interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { >AccessorDeclaration : AccessorDeclaration diff --git a/tests/baselines/reference/classWithSemicolonClassElement1.js b/tests/baselines/reference/classWithSemicolonClassElement1.js new file mode 100644 index 00000000000..3838316e113 --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElement1.js @@ -0,0 +1,12 @@ +//// [classWithSemicolonClassElement1.ts] +class C { + ; +} + +//// [classWithSemicolonClassElement1.js] +var C = (function () { + function C() { + } + ; + return C; +})(); diff --git a/tests/baselines/reference/classWithSemicolonClassElement1.types b/tests/baselines/reference/classWithSemicolonClassElement1.types new file mode 100644 index 00000000000..d3315c4cd03 --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElement1.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement1.ts === +class C { +>C : C + + ; +} diff --git a/tests/baselines/reference/classWithSemicolonClassElement2.js b/tests/baselines/reference/classWithSemicolonClassElement2.js new file mode 100644 index 00000000000..77af51bce60 --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElement2.js @@ -0,0 +1,14 @@ +//// [classWithSemicolonClassElement2.ts] +class C { + ; + ; +} + +//// [classWithSemicolonClassElement2.js] +var C = (function () { + function C() { + } + ; + ; + return C; +})(); diff --git a/tests/baselines/reference/classWithSemicolonClassElement2.types b/tests/baselines/reference/classWithSemicolonClassElement2.types new file mode 100644 index 00000000000..ce638e79fc0 --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElement2.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement2.ts === +class C { +>C : C + + ; + ; +} diff --git a/tests/baselines/reference/classWithSemicolonClassElementES61.js b/tests/baselines/reference/classWithSemicolonClassElementES61.js new file mode 100644 index 00000000000..27f020257f5 --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElementES61.js @@ -0,0 +1,9 @@ +//// [classWithSemicolonClassElementES61.ts] +class C { + ; +} + +//// [classWithSemicolonClassElementES61.js] +class C { + ; +} diff --git a/tests/baselines/reference/classWithSemicolonClassElementES61.types b/tests/baselines/reference/classWithSemicolonClassElementES61.types new file mode 100644 index 00000000000..974f269d33c --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElementES61.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES61.ts === +class C { +>C : C + + ; +} diff --git a/tests/baselines/reference/classWithSemicolonClassElementES62.js b/tests/baselines/reference/classWithSemicolonClassElementES62.js new file mode 100644 index 00000000000..068286c25ce --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElementES62.js @@ -0,0 +1,11 @@ +//// [classWithSemicolonClassElementES62.ts] +class C { + ; + ; +} + +//// [classWithSemicolonClassElementES62.js] +class C { + ; + ; +} diff --git a/tests/baselines/reference/classWithSemicolonClassElementES62.types b/tests/baselines/reference/classWithSemicolonClassElementES62.types new file mode 100644 index 00000000000..9f96fbb5ebd --- /dev/null +++ b/tests/baselines/reference/classWithSemicolonClassElementES62.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES62.ts === +class C { +>C : C + + ; + ; +} diff --git a/tests/baselines/reference/es6ClassTest3.errors.txt b/tests/baselines/reference/es6ClassTest3.errors.txt deleted file mode 100644 index 5eb310f338d..00000000000 --- a/tests/baselines/reference/es6ClassTest3.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/compiler/es6ClassTest3.ts(3,22): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/compiler/es6ClassTest3.ts(4,23): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. - - -==== tests/cases/compiler/es6ClassTest3.ts (2 errors) ==== - module M { - class Visibility { - public foo() { }; - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. - private bar() { }; - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. - private x: number; - public y: number; - public z: number; - - constructor() { - this.x = 1; - this.y = 2; - } - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6ClassTest3.js b/tests/baselines/reference/es6ClassTest3.js index dc9f1c67154..572bd079636 100644 --- a/tests/baselines/reference/es6ClassTest3.js +++ b/tests/baselines/reference/es6ClassTest3.js @@ -23,7 +23,9 @@ var M; this.y = 2; } Visibility.prototype.foo = function () { }; + ; Visibility.prototype.bar = function () { }; + ; return Visibility; })(); })(M || (M = {})); diff --git a/tests/baselines/reference/es6ClassTest3.types b/tests/baselines/reference/es6ClassTest3.types new file mode 100644 index 00000000000..ba0f2036f0e --- /dev/null +++ b/tests/baselines/reference/es6ClassTest3.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/es6ClassTest3.ts === +module M { +>M : typeof M + + class Visibility { +>Visibility : Visibility + + public foo() { }; +>foo : () => void + + private bar() { }; +>bar : () => void + + private x: number; +>x : number + + public y: number; +>y : number + + public z: number; +>z : number + + constructor() { + this.x = 1; +>this.x = 1 : number +>this.x : number +>this : Visibility +>x : number + + this.y = 2; +>this.y = 2 : number +>this.y : number +>this : Visibility +>y : number + } + } +} diff --git a/tests/baselines/reference/exportDeclareClass1.errors.txt b/tests/baselines/reference/exportDeclareClass1.errors.txt index c93dc5d0b01..247b0511ed1 100644 --- a/tests/baselines/reference/exportDeclareClass1.errors.txt +++ b/tests/baselines/reference/exportDeclareClass1.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/exportDeclareClass1.ts(2,24): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/compiler/exportDeclareClass1.ts(3,34): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/compiler/exportDeclareClass1.ts(2,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/exportDeclareClass1.ts(3,31): error TS1184: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/exportDeclareClass1.ts (2 errors) ==== export declare class eaC { static tF() { }; - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. static tsF(param:any) { }; - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. }; export declare class eaC2 { diff --git a/tests/baselines/reference/parser0_004152.errors.txt b/tests/baselines/reference/parser0_004152.errors.txt index 97b9bfe34a6..43a8945ffea 100644 --- a/tests/baselines/reference/parser0_004152.errors.txt +++ b/tests/baselines/reference/parser0_004152.errors.txt @@ -32,11 +32,10 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,86): error T tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,94): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,96): error TS2300: Duplicate identifier '0'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,97): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,98): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error TS2304: Cannot find name 'SeedCoords'. -==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (36 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (35 errors) ==== export class Game { ~~~~ !!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. @@ -107,8 +106,6 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error T !!! error TS2300: Duplicate identifier '0'. ~ !!! error TS1005: ';' expected. - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. private prevConfig: SeedCoords[][]; ~~~~~~~~~~ !!! error TS2304: Cannot find name 'SeedCoords'. diff --git a/tests/baselines/reference/parser0_004152.js b/tests/baselines/reference/parser0_004152.js index cce49f68fcc..cd6a20742a8 100644 --- a/tests/baselines/reference/parser0_004152.js +++ b/tests/baselines/reference/parser0_004152.js @@ -9,6 +9,7 @@ var Game = (function () { function Game() { this.position = new DisplayPosition([]); } + ; return Game; })(); exports.Game = Game; diff --git a/tests/baselines/reference/parserErrantSemicolonInClass1.errors.txt b/tests/baselines/reference/parserErrantSemicolonInClass1.errors.txt index 7e71ec8fc61..aec80ad934d 100644 --- a/tests/baselines/reference/parserErrantSemicolonInClass1.errors.txt +++ b/tests/baselines/reference/parserErrantSemicolonInClass1.errors.txt @@ -1,7 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(9,21): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(18,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(24,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts (4 errors) ==== class a { //constructor (); constructor (n: number); @@ -11,23 +14,29 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonIn } public pgF() { }; - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. public pv; public get d() { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return 30; } public set d() { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. } public static get p2() { + ~~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return { x: 30, y: 40 }; } private static d2() { } private static get p3() { + ~~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return "string"; } private pv3; diff --git a/tests/baselines/reference/parserErrantSemicolonInClass1.js b/tests/baselines/reference/parserErrantSemicolonInClass1.js index f761b04ca78..f3834da7e78 100644 --- a/tests/baselines/reference/parserErrantSemicolonInClass1.js +++ b/tests/baselines/reference/parserErrantSemicolonInClass1.js @@ -40,6 +40,7 @@ var a = (function () { function a(ns) { } a.prototype.pgF = function () { }; + ; Object.defineProperty(a.prototype, "d", { get: function () { return 30; diff --git a/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.errors.txt b/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.errors.txt deleted file mode 100644 index 09eabb5b588..00000000000 --- a/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/parsingClassRecoversWhenHittingUnexpectedSemicolon.ts(2,19): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. - - -==== tests/cases/compiler/parsingClassRecoversWhenHittingUnexpectedSemicolon.ts (1 errors) ==== - class C { - public f() { }; - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. - private m; - } - \ No newline at end of file diff --git a/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.js b/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.js index 8b197fd35a4..59129f91b97 100644 --- a/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.js +++ b/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.js @@ -10,5 +10,6 @@ var C = (function () { function C() { } C.prototype.f = function () { }; + ; return C; })(); diff --git a/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.types b/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.types new file mode 100644 index 00000000000..6fdfccfa7fd --- /dev/null +++ b/tests/baselines/reference/parsingClassRecoversWhenHittingUnexpectedSemicolon.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/parsingClassRecoversWhenHittingUnexpectedSemicolon.ts === +class C { +>C : C + + public f() { }; +>f : () => void + + private m; +>m : any +} + diff --git a/tests/baselines/reference/primitiveMembers.errors.txt b/tests/baselines/reference/primitiveMembers.errors.txt index 801d3fac45c..da8b75f9bc5 100644 --- a/tests/baselines/reference/primitiveMembers.errors.txt +++ b/tests/baselines/reference/primitiveMembers.errors.txt @@ -1,10 +1,8 @@ tests/cases/compiler/primitiveMembers.ts(5,3): error TS2339: Property 'toBAZ' does not exist on type 'number'. tests/cases/compiler/primitiveMembers.ts(11,1): error TS2322: Type 'Number' is not assignable to type 'number'. -tests/cases/compiler/primitiveMembers.ts(24,35): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/compiler/primitiveMembers.ts(25,56): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -==== tests/cases/compiler/primitiveMembers.ts (4 errors) ==== +==== tests/cases/compiler/primitiveMembers.ts (2 errors) ==== var x = 5; var r = /yo/; r.source; @@ -33,11 +31,7 @@ tests/cases/compiler/primitiveMembers.ts(25,56): error TS1068: Unexpected token. class baz { public bar(): void { }; } - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. class foo extends baz { public bar(){ return undefined}; } - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. diff --git a/tests/baselines/reference/primitiveMembers.js b/tests/baselines/reference/primitiveMembers.js index bf3f1a17105..629d55ed0f7 100644 --- a/tests/baselines/reference/primitiveMembers.js +++ b/tests/baselines/reference/primitiveMembers.js @@ -58,6 +58,7 @@ var baz = (function () { function baz() { } baz.prototype.bar = function () { }; + ; return baz; })(); var foo = (function (_super) { @@ -66,5 +67,6 @@ var foo = (function (_super) { _super.apply(this, arguments); } foo.prototype.bar = function () { return undefined; }; + ; return foo; })(baz); diff --git a/tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement1.ts b/tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement1.ts new file mode 100644 index 00000000000..6571258d9d1 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement1.ts @@ -0,0 +1,3 @@ +class C { + ; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement2.ts b/tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement2.ts new file mode 100644 index 00000000000..716c8b58aeb --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classWithSemicolonClassElement2.ts @@ -0,0 +1,4 @@ +class C { + ; + ; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES61.ts b/tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES61.ts new file mode 100644 index 00000000000..e1c31c16ad3 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES61.ts @@ -0,0 +1,4 @@ +//@target: es6 +class C { + ; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES62.ts b/tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES62.ts new file mode 100644 index 00000000000..d83200da627 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/classWithSemicolonClassElementES62.ts @@ -0,0 +1,5 @@ +//@target: es6 +class C { + ; + ; +} \ No newline at end of file