From dbc48d222ff897ad0e78e8d6014e6b2add4ced56 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 12 Nov 2014 12:00:46 -0800 Subject: [PATCH 01/12] Parse computed property names --- computed.txt | 12 ++++++ src/compiler/parser.ts | 86 +++++++++++++++++++++++++++++++++--------- src/compiler/types.ts | 7 +++- 3 files changed, 86 insertions(+), 19 deletions(-) create mode 100644 computed.txt diff --git a/computed.txt b/computed.txt new file mode 100644 index 00000000000..a8869ad7d9d --- /dev/null +++ b/computed.txt @@ -0,0 +1,12 @@ +Parse computed expressions and add tests +Disallow computed expressions in class instance properties +Disallow computed expressions in object literal properties, methods, or accessors +Disallow in interfaces + +Emit computed properties for classes and object literals +Discuss down level support for computed properties + +Tests that need to move: +tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature4.ts +tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature5.ts +tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature11.ts \ No newline at end of file diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4dd85715852..0ba246b62e6 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1242,30 +1242,41 @@ module ts { return createIdentifier(token >= SyntaxKind.Identifier); } - function isPropertyName(): boolean { + function isLiteralPropertyName(): boolean { return token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral; } - function parsePropertyName(): Identifier { + function parsePropertyName(): DeclarationName { if (token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral) { return parseLiteralNode(/*internName:*/ true); } + if (token === SyntaxKind.OpenBracketToken) { + return parseComputedPropertyName(); + } return parseIdentifierName(); } + function parseComputedPropertyName(): ComputedPropertyName { + var node = createNode(SyntaxKind.ComputedPropertyName); + parseExpected(SyntaxKind.OpenBracketToken); + node.expression = parseAssignmentExpression(/*noIn*/ false); + parseExpected(SyntaxKind.CloseBracketToken); + return finishNode(node); + } + function parseContextualModifier(t: SyntaxKind): boolean { return token === t && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || isPropertyName(); + return token === SyntaxKind.OpenBracketToken || isLiteralPropertyName(); }); } function parseAnyContextualModifier(): boolean { return isModifier(token) && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isPropertyName(); + return token === SyntaxKind.OpenBracketToken || isPropertyName(); }); } @@ -1285,9 +1296,11 @@ module ts { case ParsingContext.ClassMembers: return lookAhead(isClassMemberStart); case ParsingContext.EnumMembers: - return isPropertyName(); + // Include open bracket computed properties. This technically also lets in indexers, + // which would be a candidate for improved error reporting. + return token === SyntaxKind.OpenBracketToken || isLiteralPropertyName(); case ParsingContext.ObjectLiteralMembers: - return token === SyntaxKind.AsteriskToken || isPropertyName(); + return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isLiteralPropertyName(); case ParsingContext.BaseTypeReferences: return isIdentifier() && ((token !== SyntaxKind.ExtendsKeyword && token !== SyntaxKind.ImplementsKeyword) || !lookAhead(() => (nextToken(), isIdentifier()))); case ParsingContext.VariableDeclarations: @@ -1774,6 +1787,42 @@ module ts { return finishNode(node); } + function isIndexSignature(): boolean { + if (token !== SyntaxKind.OpenBracketToken) { + return false; + } + + return lookAhead(() => { + // The only allowed sequence is: + // + // [id: + // + // However, for error recovery, we also check the following cases: + // + // [... + // [id, + // [public id + // [private id + // [protected id + // [] + // + if (nextToken() === SyntaxKind.DotDotDotToken + || token === SyntaxKind.CloseBracketToken + || token === SyntaxKind.PublicKeyword + || token === SyntaxKind.PrivateKeyword + || token === SyntaxKind.ProtectedKeyword) { + + return true; + } + + if (!isIdentifier()) { + return false; + } + + return nextToken() === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken; + }); + } + function parseIndexSignatureMember(fullStart: number, modifiers: ModifiersArray): SignatureDeclaration { var node = createNode(SyntaxKind.IndexSignature, fullStart); setModifiers(node, modifiers); @@ -1817,10 +1866,10 @@ module ts { switch (token) { case SyntaxKind.OpenParenToken: case SyntaxKind.LessThanToken: - case SyntaxKind.OpenBracketToken: + case SyntaxKind.OpenBracketToken: // Both for indexers and computed properties return true; default: - return isPropertyName() && lookAhead(() => nextToken() === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken || token === SyntaxKind.QuestionToken || + return isLiteralPropertyName() && lookAhead(() => nextToken() === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken || token === SyntaxKind.QuestionToken || token === SyntaxKind.ColonToken || canParseSemicolon()); } } @@ -1831,7 +1880,8 @@ module ts { case SyntaxKind.LessThanToken: return parseSignatureMember(SyntaxKind.CallSignature, SyntaxKind.ColonToken); case SyntaxKind.OpenBracketToken: - return parseIndexSignatureMember(scanner.getStartPos(), /*modifiers:*/ undefined); + // Indexer or computed property + return isIndexSignature() ? parseIndexSignatureMember(scanner.getStartPos(), /*modifiers:*/ undefined) : parsePropertyOrMethod(); case SyntaxKind.NewKeyword: if (lookAhead(() => nextToken() === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken)) { return parseSignatureMember(SyntaxKind.ConstructSignature, SyntaxKind.ColonToken); @@ -3368,12 +3418,12 @@ module ts { // Try to get the first property-like token following all modifiers. // This can either be an identifier or the 'get' or 'set' keywords. - if (isPropertyName()) { + if (isLiteralPropertyName()) { idToken = token; nextToken(); } - // Index signatures are class members; we can parse. + // Index signatures and computed properties are class members; we can parse. if (token === SyntaxKind.OpenBracketToken) { return true; } @@ -3442,12 +3492,15 @@ module ts { if (token === SyntaxKind.ConstructorKeyword) { return parseConstructorDeclaration(fullStart, modifiers); } - if (token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || token === SyntaxKind.AsteriskToken) { - return parsePropertyMemberDeclaration(fullStart, modifiers); - } - if (token === SyntaxKind.OpenBracketToken) { + if (isIndexSignature()) { return parseIndexSignatureMember(fullStart, modifiers); } + // It is very important that we check this *after* checking indexers because + // the [ token can start an index signature or a computed property name + if (token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || + token === SyntaxKind.AsteriskToken || token === SyntaxKind.OpenBracketToken) { + return parsePropertyMemberDeclaration(fullStart, modifiers); + } // 'isClassMemberStart' should have hinted not to attempt parsing. Debug.fail("Should not have attempted to parse class member declaration."); @@ -4438,8 +4491,7 @@ module ts { for (var i = 0, n = node.properties.length; i < n; i++) { var prop = node.properties[i]; - // TODO(jfreeman): continue if we have a computed property - if (prop.kind === SyntaxKind.OmittedExpression) { + if (prop.kind === SyntaxKind.OmittedExpression || p.name.kind === SyntaxKind.ComputedPropertyName) { continue; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1cfcf8036cd..108e00e48b4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -141,6 +141,7 @@ module ts { Missing, // Names QualifiedName, + ComputedPropertyName, // Signature elements TypeParameter, Parameter, @@ -632,7 +633,9 @@ module ts { } export interface EnumMember extends Declaration { - name: Identifier | LiteralExpression; + // This does include ComputedPropertyName, but the parser will give an error + // if it parses a ComputedPropertyName in an EnumMember + name: DeclarationName; initializer?: Expression; } @@ -1255,7 +1258,7 @@ module ts { export interface CommandLineOption { name: string; type: string | Map; // "string", "number", "boolean", or an object literal mapping named values to actual values - shortName?: string; // A short pneumonic for convenience - for instance, 'h' can be used in place of 'help'. + shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'. description?: DiagnosticMessage; // The message describing what the command line switch does paramName?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter. error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'. From 9d5c86a11d1b532c98371449f65936123a9106e7 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 12 Nov 2014 18:02:40 -0800 Subject: [PATCH 02/12] Add grammar errors for computed property names --- .../diagnosticInformationMap.generated.ts | 7 +- src/compiler/diagnosticMessages.json | 20 +++++ src/compiler/parser.ts | 79 ++++++++++++++++--- 3 files changed, 96 insertions(+), 10 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index dbc77bb95b7..c8156dff138 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -124,8 +124,13 @@ module ts { Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, + An_object_member_cannot_be_declared_optional: { code: 1160, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, + Computed_property_names_are_not_allowed_in_interfaces_or_type_literals: { code: 1161, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces or type literals." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1162, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1163, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." }, + Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4a5ce8f6f70..5784a427224 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -488,6 +488,14 @@ "code": 1161 }, "An object member cannot be declared optional.": { + "category": "Error", + "code": 1160 + }, + "Computed property names are not allowed in interfaces or type literals.": { + "category": "Error", + "code": 1161 + }, + "Computed property names are not allowed in enums.": { "category": "Error", "code": 1162 }, @@ -495,6 +503,18 @@ "category": "Error", "code": 1163 }, + "Computed property names are not allowed in an ambient context.": { + "category": "Error", + "code": 1163 + }, + "Computed property names are not allowed in class property declarations.": { + "category": "Error", + "code": 1164 + }, + "Computed property names are only available when targeting ECMAScript 6 and higher.": { + "category": "Error", + "code": 1165 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0ba246b62e6..d884aef808c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1261,7 +1261,7 @@ module ts { function parseComputedPropertyName(): ComputedPropertyName { var node = createNode(SyntaxKind.ComputedPropertyName); parseExpected(SyntaxKind.OpenBracketToken); - node.expression = parseAssignmentExpression(/*noIn*/ false); + node.expression = allowInAnd(parseAssignmentExpression); parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); } @@ -1276,7 +1276,7 @@ module ts { function parseAnyContextualModifier(): boolean { return isModifier(token) && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || isPropertyName(); + return token === SyntaxKind.OpenBracketToken || isLiteralPropertyName(); }); } @@ -1801,6 +1801,9 @@ module ts { // // [... // [id, + // [id?, + // [id?: + // [id?] // [public id // [private id // [protected id @@ -1819,7 +1822,22 @@ module ts { return false; } - return nextToken() === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken; + // A colon signifies a well formed indexer + // A comma should be a badly formed indexer because comma expressions are not allowed + // in computed properties. + if (nextToken() === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken) { + return true; + } + + // Question mark could be an indexer with an optional property, + // or it could be a conditional expression in a computed property. + if (token !== SyntaxKind.QuestionToken) { + return false; + } + + // If any of the following tokens are after the question mark, it cannot + // be a conditional expression, so treat it as an indexer. + return nextToken() === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBracketToken; }); } @@ -3991,6 +4009,7 @@ module ts { case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); case SyntaxKind.CatchBlock: return checkCatchBlock(node); case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); + case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); case SyntaxKind.Constructor: return checkConstructor(node); case SyntaxKind.ExportAssignment: return checkExportAssignment(node); case SyntaxKind.ForInStatement: return checkForInStatement(node); @@ -4278,13 +4297,17 @@ module ts { var enumIsConst = (enumDecl.flags & NodeFlags.Const) !== 0; var hasError = false; + // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. if (!enumIsConst) { var inConstantEnumMemberSection = true; for (var i = 0, n = enumDecl.members.length; i < n; i++) { var node = enumDecl.members[i]; - if (inAmbientContext) { + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + hasError = grammarErrorOnNode(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (inAmbientContext) { if (node.initializer && !isIntegerLiteral(node.initializer)) { hasError = grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; } @@ -4438,10 +4461,25 @@ module ts { } function checkMethod(node: MethodDeclaration) { - return checkAnyParsedSignature(node) || + if (checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, /*isConstructor:*/ false) || - (node.parent.kind === SyntaxKind.ClassDeclaration && checkForInvalidQuestionMark(node, Diagnostics.A_class_member_cannot_be_declared_optional)) || - checkForGenerator(node); + checkForGenerator(node)) { + return true; + } + if (node.parent.kind === SyntaxKind.ClassDeclaration) { + if (checkForInvalidQuestionMark(node, Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + // Technically, computed properties in ambient contexts is disallowed + // for property declarations and accessors too, not just methods. + // However, property declarations disallow computed names in general, + // and accessors are not allowed in ambient contexts in general, + // so this error only really matters for methods. + return inAmbientContext && checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + } + else if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral) { + return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces_or_type_literals); + } } function checkForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean { @@ -4775,8 +4813,31 @@ module ts { } function checkProperty(node: PropertyDeclaration) { - return (node.parent.kind === SyntaxKind.ClassDeclaration && checkForInvalidQuestionMark(node, Diagnostics.A_class_member_cannot_be_declared_optional)) || - checkForInitializerInAmbientContext(node); + if (node.parent.kind === SyntaxKind.ClassDeclaration) { + if (checkForInvalidQuestionMark(node, Diagnostics.A_class_member_cannot_be_declared_optional) || + checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { + return true; + } + } + else if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral) { + if (checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces_or_type_literals)) { + return true; + } + } + + checkForInitializerInAmbientContext(node); + } + + function checkComputedPropertyName(node: ComputedPropertyName) { + if (languageVersion < ScriptTarget.ES6) { + return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + } + + function checkForDisallowedComputedProperty(node: DeclarationName, message: DiagnosticMessage) { + if (node.kind === SyntaxKind.ComputedPropertyName) { + return grammarErrorOnNode(node, message); + } } function checkForInitializerInAmbientContext(node: PropertyDeclaration) { From cf4f34c224d2904202c76a8784e38657ee00dbfd Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 17 Nov 2014 14:38:35 -0800 Subject: [PATCH 03/12] Add parser tests for computed properties --- src/compiler/parser.ts | 18 ++++--- tests/baselines/reference/giant.errors.txt | 48 +++++++++---------- ...SignatureMustHaveTypeAnnotation.errors.txt | 12 ++--- .../indexSignatureWithInitializer.errors.txt | 20 +++----- .../indexWithoutParamType2.errors.txt | 6 +-- ...objectTypeWithOptionalProperty1.errors.txt | 4 +- ...jectTypesWithOptionalProperties.errors.txt | 4 +- .../parserComputedPropertyName1.errors.txt | 7 +++ .../parserComputedPropertyName10.errors.txt | 9 ++++ .../parserComputedPropertyName11.errors.txt | 9 ++++ .../parserComputedPropertyName13.errors.txt | 7 +++ .../parserComputedPropertyName14.errors.txt | 7 +++ .../parserComputedPropertyName15.errors.txt | 7 +++ .../parserComputedPropertyName16.errors.txt | 9 ++++ .../parserComputedPropertyName18.errors.txt | 7 +++ .../parserComputedPropertyName19.errors.txt | 7 +++ .../parserComputedPropertyName20.errors.txt | 9 ++++ .../parserComputedPropertyName21.errors.txt | 9 ++++ .../parserComputedPropertyName22.errors.txt | 9 ++++ .../parserComputedPropertyName23.errors.txt | 9 ++++ .../parserComputedPropertyName25.errors.txt | 14 ++++++ .../parserComputedPropertyName26.errors.txt | 14 ++++++ .../parserComputedPropertyName27.errors.txt | 14 ++++++ .../parserComputedPropertyName28.errors.txt | 13 +++++ .../parserComputedPropertyName29.errors.txt | 17 +++++++ .../parserComputedPropertyName30.errors.txt | 14 ++++++ .../parserComputedPropertyName31.errors.txt | 14 ++++++ .../parserComputedPropertyName32.errors.txt | 9 ++++ .../parserComputedPropertyName33.errors.txt | 17 +++++++ .../parserComputedPropertyName34.errors.txt | 17 +++++++ .../parserComputedPropertyName5.errors.txt | 19 ++++++++ .../parserComputedPropertyName7.errors.txt | 9 ++++ .../parserComputedPropertyName8.errors.txt | 9 ++++ .../parserComputedPropertyName9.errors.txt | 12 +++++ .../parserES5ComputedPropertyName1.errors.txt | 9 ++++ ...parserES5ComputedPropertyName10.errors.txt | 9 ++++ ...parserES5ComputedPropertyName11.errors.txt | 12 +++++ .../parserES5ComputedPropertyName2.errors.txt | 7 +++ .../parserES5ComputedPropertyName3.errors.txt | 7 +++ .../parserES5ComputedPropertyName4.errors.txt | 7 +++ .../parserES5ComputedPropertyName5.errors.txt | 9 ++++ .../parserES5ComputedPropertyName6.errors.txt | 9 ++++ .../parserES5ComputedPropertyName7.errors.txt | 9 ++++ .../parserES5ComputedPropertyName8.errors.txt | 7 +++ .../parserES5ComputedPropertyName9.errors.txt | 12 +++++ .../parserIndexSignature11.errors.txt | 6 +-- .../parserIndexSignature4.errors.txt | 11 ++--- .../parserIndexSignature5.errors.txt | 6 +-- .../reference/propertyAssignment.errors.txt | 6 +-- ...uestionMarkInPropertyAssignment.errors.txt | 4 +- .../parserES5ComputedPropertyName1.ts | 4 ++ .../parserES5ComputedPropertyName10.ts | 4 ++ .../parserES5ComputedPropertyName11.ts | 4 ++ .../parserES5ComputedPropertyName2.ts | 2 + .../parserES5ComputedPropertyName3.ts | 2 + .../parserES5ComputedPropertyName4.ts | 2 + .../parserES5ComputedPropertyName5.ts | 4 ++ .../parserES5ComputedPropertyName6.ts | 4 ++ .../parserES5ComputedPropertyName7.ts | 4 ++ .../parserES5ComputedPropertyName8.ts | 2 + .../parserES5ComputedPropertyName9.ts | 4 ++ .../parserComputedPropertyName1.ts | 2 + .../parserComputedPropertyName10.ts | 4 ++ .../parserComputedPropertyName11.ts | 4 ++ .../parserComputedPropertyName12.ts | 4 ++ .../parserComputedPropertyName13.ts | 2 + .../parserComputedPropertyName14.ts | 2 + .../parserComputedPropertyName15.ts | 2 + .../parserComputedPropertyName16.ts | 4 ++ .../parserComputedPropertyName17.ts | 2 + .../parserComputedPropertyName18.ts | 2 + .../parserComputedPropertyName19.ts | 2 + .../parserComputedPropertyName2.ts | 2 + .../parserComputedPropertyName20.ts | 4 ++ .../parserComputedPropertyName21.ts | 4 ++ .../parserComputedPropertyName22.ts | 4 ++ .../parserComputedPropertyName23.ts | 4 ++ .../parserComputedPropertyName24.ts | 4 ++ .../parserComputedPropertyName25.ts | 6 +++ .../parserComputedPropertyName26.ts | 6 +++ .../parserComputedPropertyName27.ts | 6 +++ .../parserComputedPropertyName28.ts | 5 ++ .../parserComputedPropertyName29.ts | 6 +++ .../parserComputedPropertyName3.ts | 2 + .../parserComputedPropertyName30.ts | 6 +++ .../parserComputedPropertyName31.ts | 6 +++ .../parserComputedPropertyName32.ts | 4 ++ .../parserComputedPropertyName33.ts | 6 +++ .../parserComputedPropertyName34.ts | 6 +++ .../parserComputedPropertyName4.ts | 2 + .../parserComputedPropertyName5.ts | 2 + .../parserComputedPropertyName6.ts | 2 + .../parserComputedPropertyName7.ts | 4 ++ .../parserComputedPropertyName8.ts | 4 ++ .../parserComputedPropertyName9.ts | 4 ++ 95 files changed, 626 insertions(+), 78 deletions(-) create mode 100644 tests/baselines/reference/parserComputedPropertyName1.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName10.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName11.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName13.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName14.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName15.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName16.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName18.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName19.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName20.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName21.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName22.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName23.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName25.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName26.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName27.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName28.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName29.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName30.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName31.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName32.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName33.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName34.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName5.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName7.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName8.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName9.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt create mode 100644 tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d884aef808c..99bb1f6f85d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4528,14 +4528,12 @@ module ts { var inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0; for (var i = 0, n = node.properties.length; i < n; i++) { - var prop = node.properties[i]; - if (prop.kind === SyntaxKind.OmittedExpression || p.name.kind === SyntaxKind.ComputedPropertyName) { + var prop = node.properties[i]; + var name = prop.name; + if (prop.kind === SyntaxKind.OmittedExpression || name.kind === SyntaxKind.ComputedPropertyName) { continue; } - var p = prop; - var name = p.name; - // ECMA-262 11.1.5 Object Initialiser // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and @@ -4545,20 +4543,20 @@ module ts { // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind: number; - if (p.kind === SyntaxKind.PropertyAssignment) { + if (prop.kind === SyntaxKind.PropertyAssignment) { currentKind = Property; } - else if (p.kind === SyntaxKind.ShorthandPropertyAssignment) { + else if (prop.kind === SyntaxKind.ShorthandPropertyAssignment) { currentKind = Property; } - else if (p.kind === SyntaxKind.GetAccessor) { + else if (prop.kind === SyntaxKind.GetAccessor) { currentKind = GetAccessor; } - else if (p.kind === SyntaxKind.SetAccessor) { + else if (prop.kind === SyntaxKind.SetAccessor) { currentKind = SetAccesor; } else { - Debug.fail("Unexpected syntax kind:" + p.kind); + Debug.fail("Unexpected syntax kind:" + prop.kind); } if (!hasProperty(seen, name.text)) { diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index 767c419952c..5bc00b7cd28 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/giant.ts(28,17): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(30,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(34,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(61,6): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(61,5): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(88,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -13,7 +13,7 @@ tests/cases/compiler/giant.ts(92,21): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(94,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(98,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(100,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(125,10): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(125,9): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(154,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -23,7 +23,7 @@ tests/cases/compiler/giant.ts(171,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(173,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(177,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(179,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(204,10): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(204,9): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(233,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -54,7 +54,7 @@ tests/cases/compiler/giant.ts(286,17): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(288,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(292,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(294,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(319,6): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(319,5): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(346,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -63,7 +63,7 @@ tests/cases/compiler/giant.ts(350,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(352,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(356,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(358,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(383,10): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(383,9): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(412,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -73,7 +73,7 @@ tests/cases/compiler/giant.ts(429,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(431,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(435,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(437,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(462,10): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(462,9): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(491,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -120,7 +120,7 @@ tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(561,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(563,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(587,10): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(587,9): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(606,22): error TS1037: A function implementation cannot be declared in an ambient context. @@ -137,7 +137,7 @@ tests/cases/compiler/giant.ts(621,29): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(623,24): error TS1111: A constructor implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(626,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(628,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(653,10): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/giant.ts(653,9): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(672,22): error TS1037: A function implementation cannot be declared in an ambient context. @@ -360,8 +360,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -468,8 +468,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -593,8 +593,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -820,8 +820,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -928,8 +928,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1053,8 +1053,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1322,8 +1322,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1424,8 +1424,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index e7437fcb056..c76acf795ac 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,6): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,6): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1164: Computed property names are not allowed in class property declarations. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021: An index signature must have a type annotation. ==== tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts (4 errors) ==== interface I { [x]: string; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [x: string]; ~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -16,8 +16,8 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021 class C { [x]: string - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. } diff --git a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt index 9eeff2c5781..414bcdfb84c 100644 --- a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt +++ b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt @@ -1,22 +1,16 @@ -tests/cases/compiler/indexSignatureWithInitializer.ts(2,6): error TS1020: An index signature parameter cannot have an initializer. -tests/cases/compiler/indexSignatureWithInitializer.ts(6,6): error TS1020: An index signature parameter cannot have an initializer. -tests/cases/compiler/indexSignatureWithInitializer.ts(2,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/compiler/indexSignatureWithInitializer.ts(6,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/compiler/indexSignatureWithInitializer.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/indexSignatureWithInitializer.ts(6,5): error TS1164: Computed property names are not allowed in class property declarations. -==== tests/cases/compiler/indexSignatureWithInitializer.ts (4 errors) ==== +==== tests/cases/compiler/indexSignatureWithInitializer.ts (2 errors) ==== interface I { [x = '']: string; - ~ -!!! error TS1020: An index signature parameter cannot have an initializer. - ~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. } class C { [x = 0]: string - ~ -!!! error TS1020: An index signature parameter cannot have an initializer. - ~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/indexWithoutParamType2.errors.txt b/tests/baselines/reference/indexWithoutParamType2.errors.txt index 3e7b9b49223..f9ab6057546 100644 --- a/tests/baselines/reference/indexWithoutParamType2.errors.txt +++ b/tests/baselines/reference/indexWithoutParamType2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/indexWithoutParamType2.ts(2,6): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/indexWithoutParamType2.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. ==== tests/cases/compiler/indexWithoutParamType2.ts (1 errors) ==== class C { [x]: string - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt b/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt index e2e1c05ea1e..7e17563873a 100644 --- a/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt +++ b/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/objectTypeWithOptionalProperty1.ts(2,10): error TS1162: An object member cannot be declared optional. +tests/cases/compiler/objectTypeWithOptionalProperty1.ts(2,10): error TS1160: An object member cannot be declared optional. ==== tests/cases/compiler/objectTypeWithOptionalProperty1.ts (1 errors) ==== var b = { x?: 1 // error ~ -!!! error TS1162: An object member cannot be declared optional. +!!! error TS1160: An object member cannot be declared optional. } \ No newline at end of file diff --git a/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt b/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt index a2269c29d11..d33a5e35b63 100644 --- a/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt +++ b/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(12,6): error TS1112: A class member cannot be declared optional. tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(20,6): error TS1112: A class member cannot be declared optional. -tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1162: An object member cannot be declared optional. +tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1160: An object member cannot be declared optional. ==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts (3 errors) ==== @@ -33,5 +33,5 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWith var b = { x?: 1 // error ~ -!!! error TS1162: An object member cannot be declared optional. +!!! error TS1160: An object member cannot be declared optional. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName1.errors.txt b/tests/baselines/reference/parserComputedPropertyName1.errors.txt new file mode 100644 index 00000000000..508d06a915c --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName1.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts(1,15): error TS1005: ':' expected. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts (1 errors) ==== + var v = { [e] }; + ~ +!!! error TS1005: ':' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName10.errors.txt b/tests/baselines/reference/parserComputedPropertyName10.errors.txt new file mode 100644 index 00000000000..279750d21bd --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName10.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts (1 errors) ==== + class C { + [e] = 1 + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt new file mode 100644 index 00000000000..2d2edd2b841 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (1 errors) ==== + class C { + [e](); + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName13.errors.txt b/tests/baselines/reference/parserComputedPropertyName13.errors.txt new file mode 100644 index 00000000000..eb5eb57d902 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts (1 errors) ==== + var v: { [e]: number }; + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt new file mode 100644 index 00000000000..ac5fcfff3bd --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (1 errors) ==== + var v: { [e](): number }; + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName15.errors.txt b/tests/baselines/reference/parserComputedPropertyName15.errors.txt new file mode 100644 index 00000000000..e03c5c1f259 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts (1 errors) ==== + var v: { [e: number]: string; [e]: number }; + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName16.errors.txt b/tests/baselines/reference/parserComputedPropertyName16.errors.txt new file mode 100644 index 00000000000..8deb137f3af --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName16.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts(2,3): error TS1162: Computed property names are not allowed in enums. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts (1 errors) ==== + enum E { + [e] = 1 + ~~~ +!!! error TS1162: Computed property names are not allowed in enums. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt new file mode 100644 index 00000000000..1e09dae76aa --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (1 errors) ==== + var v: { [e]?(): number }; + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName19.errors.txt b/tests/baselines/reference/parserComputedPropertyName19.errors.txt new file mode 100644 index 00000000000..3ee3ed84d7b --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts (1 errors) ==== + var v: { [e]? }; + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt new file mode 100644 index 00000000000..2b77f033d9e --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts (1 errors) ==== + interface I { + [e](): number + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName21.errors.txt b/tests/baselines/reference/parserComputedPropertyName21.errors.txt new file mode 100644 index 00000000000..f472afd93ee --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts (1 errors) ==== + interface I { + [e]: number + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName22.errors.txt b/tests/baselines/reference/parserComputedPropertyName22.errors.txt new file mode 100644 index 00000000000..dae871108f0 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName22.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts (1 errors) ==== + declare class C { + [e]: number + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName23.errors.txt b/tests/baselines/reference/parserComputedPropertyName23.errors.txt new file mode 100644 index 00000000000..2018032ef94 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName23.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts(2,9): error TS1086: An accessor cannot be declared in an ambient context. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts (1 errors) ==== + declare class C { + get [e](): number + ~~~ +!!! error TS1086: An accessor cannot be declared in an ambient context. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName25.errors.txt b/tests/baselines/reference/parserComputedPropertyName25.errors.txt new file mode 100644 index 00000000000..7e0d3abdd37 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName25.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(4,6): error TS2304: Cannot find name 'e2'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts (2 errors) ==== + class C { + // No ASI + [e] = 0 + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + [e2] = 1 + ~~ +!!! error TS2304: Cannot find name 'e2'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName26.errors.txt b/tests/baselines/reference/parserComputedPropertyName26.errors.txt new file mode 100644 index 00000000000..85d0729e73f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName26.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts(3,5): error TS1162: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts(4,6): error TS2304: Cannot find name 'e2'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts (2 errors) ==== + enum E { + // No ASI + [e] = 0 + ~~~ +!!! error TS1162: Computed property names are not allowed in enums. + [e2] = 1 + ~~ +!!! error TS2304: Cannot find name 'e2'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName27.errors.txt b/tests/baselines/reference/parserComputedPropertyName27.errors.txt new file mode 100644 index 00000000000..ee13c5878c7 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName27.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts(4,9): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts(4,6): error TS2304: Cannot find name 'e2'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts (2 errors) ==== + class C { + // No ASI + [e]: number = 0 + [e2]: number + ~ +!!! error TS1005: ';' expected. + ~~ +!!! error TS2304: Cannot find name 'e2'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName28.errors.txt b/tests/baselines/reference/parserComputedPropertyName28.errors.txt new file mode 100644 index 00000000000..f36b15b61b6 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName28.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts (2 errors) ==== + class C { + [e]: number = 0; + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + [e2]: number + ~~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName29.errors.txt b/tests/baselines/reference/parserComputedPropertyName29.errors.txt new file mode 100644 index 00000000000..0b832d1b68f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,11): error TS2304: Cannot find name 'id'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts (3 errors) ==== + class C { + // yes ASI + [e] = id++ + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + ~~ +!!! error TS2304: Cannot find name 'id'. + [e2]: number + ~~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName30.errors.txt b/tests/baselines/reference/parserComputedPropertyName30.errors.txt new file mode 100644 index 00000000000..0058f0ef698 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName30.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(4,5): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(3,11): error TS2304: Cannot find name 'id'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts (2 errors) ==== + enum E { + // no ASI, comma expected + [e] = id++ + ~~ +!!! error TS2304: Cannot find name 'id'. + [e2] = 1 + ~ +!!! error TS1005: ',' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName31.errors.txt b/tests/baselines/reference/parserComputedPropertyName31.errors.txt new file mode 100644 index 00000000000..21f96dcbf5d --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName31.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts (2 errors) ==== + class C { + // yes ASI + [e]: number + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + [e2]: number + ~~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName32.errors.txt b/tests/baselines/reference/parserComputedPropertyName32.errors.txt new file mode 100644 index 00000000000..88d738421e2 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1163: Computed property names are not allowed in an ambient context. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts (1 errors) ==== + declare class C { + [e](): number + ~~~ +!!! error TS1163: Computed property names are not allowed in an ambient context. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName33.errors.txt b/tests/baselines/reference/parserComputedPropertyName33.errors.txt new file mode 100644 index 00000000000..bea498036f8 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName33.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(5,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,6): error TS2304: Cannot find name 'e2'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts (3 errors) ==== + class C { + // No ASI + [e] = 0 + [e2]() { } + ~ +!!! error TS1005: ';' expected. + ~~ +!!! error TS2304: Cannot find name 'e2'. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName34.errors.txt b/tests/baselines/reference/parserComputedPropertyName34.errors.txt new file mode 100644 index 00000000000..b1cc4b91533 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName34.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(3,5): error TS1162: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(4,5): error TS1162: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(3,11): error TS2304: Cannot find name 'id'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts (3 errors) ==== + enum E { + // no ASI, comma expected + [e] = id++, + ~~~ +!!! error TS1162: Computed property names are not allowed in enums. + ~~ +!!! error TS2304: Cannot find name 'id'. + [e2] = 1 + ~~~~ +!!! error TS1162: Computed property names are not allowed in enums. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName5.errors.txt b/tests/baselines/reference/parserComputedPropertyName5.errors.txt new file mode 100644 index 00000000000..149550c93ff --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName5.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,18): error TS1005: ':' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,28): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,32): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,18): error TS2304: Cannot find name 'get'. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,23): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts (5 errors) ==== + var v = { public get [e]() { } }; + ~~~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~ +!!! error TS2304: Cannot find name 'get'. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName7.errors.txt b/tests/baselines/reference/parserComputedPropertyName7.errors.txt new file mode 100644 index 00000000000..6c46fc343a8 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName7.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts (1 errors) ==== + class C { + [e] + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName8.errors.txt b/tests/baselines/reference/parserComputedPropertyName8.errors.txt new file mode 100644 index 00000000000..07f5ec5dee1 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName8.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts (1 errors) ==== + class C { + public [e] + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName9.errors.txt b/tests/baselines/reference/parserComputedPropertyName9.errors.txt new file mode 100644 index 00000000000..a93da2261c8 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName9.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts (2 errors) ==== + class C { + [e]: Type + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + ~~~~ +!!! error TS2304: Cannot find name 'Type'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt new file mode 100644 index 00000000000..75e5d505696 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts (1 errors) ==== + declare class C { + [e]: number + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt new file mode 100644 index 00000000000..c2e53b50818 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts (1 errors) ==== + class C { + [e] = 1 + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt new file mode 100644 index 00000000000..cfd2ba4c3f8 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts (2 errors) ==== + class C { + [e](); + ~~~ +!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt new file mode 100644 index 00000000000..9b2d920f53f --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,11): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts (1 errors) ==== + var v = { [e]: 1 }; + ~~~ +!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt new file mode 100644 index 00000000000..da346e98bae --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,11): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts (1 errors) ==== + var v = { [e]() { } }; + ~~~ +!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt new file mode 100644 index 00000000000..b99115f8d1e --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts (1 errors) ==== + var v = { get [e]() { } }; + ~~~ +!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt new file mode 100644 index 00000000000..fc7a67e729b --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts (1 errors) ==== + interface I { + [e]: number + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt new file mode 100644 index 00000000000..ce3592b08e0 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts(2,3): error TS1162: Computed property names are not allowed in enums. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts (1 errors) ==== + enum E { + [e] = 1 + ~~~ +!!! error TS1162: Computed property names are not allowed in enums. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt new file mode 100644 index 00000000000..5bc1a94da3b --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts (1 errors) ==== + class C { + [e] + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt new file mode 100644 index 00000000000..e5312829ab6 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts (1 errors) ==== + var v: { [e]: number }; + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt new file mode 100644 index 00000000000..af78dcc3e4e --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts (2 errors) ==== + class C { + [e]: Type + ~~~ +!!! error TS1164: Computed property names are not allowed in class property declarations. + ~~~~ +!!! error TS2304: Cannot find name 'Type'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature11.errors.txt b/tests/baselines/reference/parserIndexSignature11.errors.txt index 585e72a3516..427d3090e48 100644 --- a/tests/baselines/reference/parserIndexSignature11.errors.txt +++ b/tests/baselines/reference/parserIndexSignature11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,10): error TS1022: An index signature parameter must have a type annotation. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(3,9): error TS1021: An index signature must have a type annotation. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(4,10): error TS1096: An index signature must have exactly one parameter. @@ -6,8 +6,8 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1 ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts (3 errors) ==== interface I { [p]; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/parserIndexSignature4.errors.txt b/tests/baselines/reference/parserIndexSignature4.errors.txt index cf4bbad234b..f93d8aed249 100644 --- a/tests/baselines/reference/parserIndexSignature4.errors.txt +++ b/tests/baselines/reference/parserIndexSignature4.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,4): error TS1020: An index signature parameter cannot have an initializer. -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,4): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1161: Computed property names are not allowed in interfaces or type literals. -==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts (1 errors) ==== interface I { [a = 0] - ~ -!!! error TS1020: An index signature parameter cannot have an initializer. - ~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature5.errors.txt b/tests/baselines/reference/parserIndexSignature5.errors.txt index 5c33bb583b6..dc6bd18d773 100644 --- a/tests/baselines/reference/parserIndexSignature5.errors.txt +++ b/tests/baselines/reference/parserIndexSignature5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,4): error TS1022: An index signature parameter must have a type annotation. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1161: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts (1 errors) ==== interface I { [a] - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. } \ No newline at end of file diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index 20894f159e0..41bc7cb6065 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAssignment.ts(6,14): error TS1022: An index signature parameter must have a type annotation. +tests/cases/compiler/propertyAssignment.ts(6,13): error TS1161: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/propertyAssignment.ts(14,1): error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: number; }' is not assignable to type '() => void'. @@ -10,8 +10,8 @@ tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: numbe var bar1: { x : number; } var foo2: { [index]; } // should be an error - ~~~~~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~~~~~ +!!! error TS1161: Computed property names are not allowed in interfaces or type literals. var bar2: { x : number; } var foo3: { ():void; } diff --git a/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt b/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt index d51b97546d4..f89252523ef 100644 --- a/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt +++ b/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts(1,12): error TS1162: An object member cannot be declared optional. +tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts(1,12): error TS1160: An object member cannot be declared optional. ==== tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts (1 errors) ==== var x = {x ?: 1} // should not crash ~ -!!! error TS1162: An object member cannot be declared optional. \ No newline at end of file +!!! error TS1160: An object member cannot be declared optional. \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts new file mode 100644 index 00000000000..8316cdfbc0e --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts @@ -0,0 +1,4 @@ +//@target: ES5 +declare class C { + [e]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts new file mode 100644 index 00000000000..777c44e0185 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts @@ -0,0 +1,4 @@ +//@target: ES5 +class C { + [e] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts new file mode 100644 index 00000000000..b5e27ecc71b --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts @@ -0,0 +1,4 @@ +//@target: ES5 +class C { + [e](); +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts new file mode 100644 index 00000000000..2f37b0f2cad --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts @@ -0,0 +1,2 @@ +//@target: ES5 +var v = { [e]: 1 }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts new file mode 100644 index 00000000000..5091ee0b98c --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts @@ -0,0 +1,2 @@ +//@target: ES5 +var v = { [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts new file mode 100644 index 00000000000..67b97a6a0bb --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts @@ -0,0 +1,2 @@ +//@target: ES5 +var v = { get [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts new file mode 100644 index 00000000000..05072071410 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts @@ -0,0 +1,4 @@ +//@target: ES5 +interface I { + [e]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts new file mode 100644 index 00000000000..622bd43e465 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts @@ -0,0 +1,4 @@ +//@target: ES5 +enum E { + [e] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts new file mode 100644 index 00000000000..280dc1a5a0d --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts @@ -0,0 +1,4 @@ +//@target: ES5 +class C { + [e] +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts new file mode 100644 index 00000000000..48abbd6fe95 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts @@ -0,0 +1,2 @@ +//@target: ES5 +var v: { [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts new file mode 100644 index 00000000000..de00d6f8245 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts @@ -0,0 +1,4 @@ +//@target: ES5 +class C { + [e]: Type +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts new file mode 100644 index 00000000000..e6fbccb8e1f --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v = { [e] }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts new file mode 100644 index 00000000000..6f87e04e3f5 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [e] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts new file mode 100644 index 00000000000..17af42fcca3 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [e](); +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts new file mode 100644 index 00000000000..b9b870a9ec9 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [e]() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts new file mode 100644 index 00000000000..809e258d2d4 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v: { [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts new file mode 100644 index 00000000000..3d9fb800d70 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v: { [e](): number }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts new file mode 100644 index 00000000000..ba0a7b84b90 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v: { [e: number]: string; [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts new file mode 100644 index 00000000000..4da898ea68f --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts @@ -0,0 +1,4 @@ +//@target: ES6 +enum E { + [e] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts new file mode 100644 index 00000000000..6e6485ea85f --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v = { set [e](v) { } } \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts new file mode 100644 index 00000000000..dd05fcac482 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v: { [e]?(): number }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts new file mode 100644 index 00000000000..f190dadb92c --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v: { [e]? }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts new file mode 100644 index 00000000000..4efacefce9b --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v = { [e]: 1 }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts new file mode 100644 index 00000000000..148f07becc1 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts @@ -0,0 +1,4 @@ +//@target: ES6 +interface I { + [e](): number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts new file mode 100644 index 00000000000..f9ec2669ae3 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts @@ -0,0 +1,4 @@ +//@target: ES6 +interface I { + [e]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts new file mode 100644 index 00000000000..237a4f4e12c --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare class C { + [e]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts new file mode 100644 index 00000000000..633931ad368 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare class C { + get [e](): number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts new file mode 100644 index 00000000000..8ff0f753e1f --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + set [e](v) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts new file mode 100644 index 00000000000..3bf29e66bae --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts @@ -0,0 +1,6 @@ +//@target: ES6 +class C { + // No ASI + [e] = 0 + [e2] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts new file mode 100644 index 00000000000..e6eaa682b59 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts @@ -0,0 +1,6 @@ +//@target: ES6 +enum E { + // No ASI + [e] = 0 + [e2] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts new file mode 100644 index 00000000000..d52b7d43cfc --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts @@ -0,0 +1,6 @@ +//@target: ES6 +class C { + // No ASI + [e]: number = 0 + [e2]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts new file mode 100644 index 00000000000..2cae79f1934 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts @@ -0,0 +1,5 @@ +//@target: ES6 +class C { + [e]: number = 0; + [e2]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts new file mode 100644 index 00000000000..c3e42731ab9 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts @@ -0,0 +1,6 @@ +//@target: ES6 +class C { + // yes ASI + [e] = id++ + [e2]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts new file mode 100644 index 00000000000..0988e19a1ef --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v = { [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts new file mode 100644 index 00000000000..f7eb547332b --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts @@ -0,0 +1,6 @@ +//@target: ES6 +enum E { + // no ASI, comma expected + [e] = id++ + [e2] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts new file mode 100644 index 00000000000..30e511fa91b --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts @@ -0,0 +1,6 @@ +//@target: ES6 +class C { + // yes ASI + [e]: number + [e2]: number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts new file mode 100644 index 00000000000..f1a50fe108d --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare class C { + [e](): number +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts new file mode 100644 index 00000000000..2ca7ac84af7 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts @@ -0,0 +1,6 @@ +//@target: ES6 +class C { + // No ASI + [e] = 0 + [e2]() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts new file mode 100644 index 00000000000..c83710593a0 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts @@ -0,0 +1,6 @@ +//@target: ES6 +enum E { + // no ASI, comma expected + [e] = id++, + [e2] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts new file mode 100644 index 00000000000..e36773105fe --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v = { get [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts new file mode 100644 index 00000000000..869f340929b --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v = { public get [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts new file mode 100644 index 00000000000..aaf4131d158 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var v = { [e]: 1, [e + e]: 2 }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts new file mode 100644 index 00000000000..8f918c61160 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [e] +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts new file mode 100644 index 00000000000..6e55c04b7a1 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + public [e] +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts new file mode 100644 index 00000000000..0c60d35fb90 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [e]: Type +} \ No newline at end of file From 17a09d1d3642868de097b6bce1efa5fc9af7b287 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 17 Nov 2014 15:53:03 -0800 Subject: [PATCH 04/12] Emit for computed properties --- src/compiler/emitter.ts | 68 ++++++++++++++++++++++++++++------------- src/compiler/parser.ts | 2 ++ 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5cdf98aa63e..9896fa598e6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -277,24 +277,37 @@ module ts { var firstAccessor: AccessorDeclaration; var getAccessor: AccessorDeclaration; var setAccessor: AccessorDeclaration; - forEach(node.members, (member: Declaration) => { - // TODO(jfreeman): Handle computed names for accessor matching - if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) && - (member.name).text === (accessor.name).text && - (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) { - if (!firstAccessor) { - firstAccessor = member; - } - - if (member.kind === SyntaxKind.GetAccessor && !getAccessor) { - getAccessor = member; - } - - if (member.kind === SyntaxKind.SetAccessor && !setAccessor) { - setAccessor = member; - } + if (accessor.name.kind === SyntaxKind.ComputedPropertyName) { + firstAccessor = accessor; + if (accessor.kind === SyntaxKind.GetAccessor) { + getAccessor = accessor; } - }); + else if (accessor.kind === SyntaxKind.SetAccessor) { + setAccessor = accessor; + } + else { + Debug.fail("Accessor has wrong kind"); + } + } + else { + forEach(node.members,(member: Declaration) => { + if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) && + (member.name).text === (accessor.name).text && + (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) { + if (!firstAccessor) { + firstAccessor = member; + } + + if (member.kind === SyntaxKind.GetAccessor && !getAccessor) { + getAccessor = member; + } + + if (member.kind === SyntaxKind.SetAccessor && !setAccessor) { + setAccessor = member; + } + } + }); + } return { firstAccessor, getAccessor, @@ -2069,6 +2082,9 @@ module ts { if (node.kind === SyntaxKind.StringLiteral) { emitLiteral(node); } + else if (node.kind === SyntaxKind.ComputedPropertyName) { + emit((node).expression); + } else { write("\""); @@ -2189,6 +2205,12 @@ module ts { } } + function emitComputedPropertyName(node: ComputedPropertyName) { + write("["); + emit(node.expression); + write("]"); + } + function emitPropertyAssignment(node: PropertyDeclaration) { emitLeadingComments(node); emit(node.name); @@ -2864,13 +2886,15 @@ module ts { }); } - // TODO(jfreeman): Account for computed property name - function emitMemberAccess(memberName: DeclarationName) { + function emitMemberAccessForPropertyName(memberName: DeclarationName) { if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) { write("["); emitNode(memberName); write("]"); } + else if (memberName.kind === SyntaxKind.ComputedPropertyName) { + emitComputedPropertyName(memberName); + } else { write("."); emitNode(memberName); @@ -2890,7 +2914,7 @@ module ts { else { write("this"); } - emitMemberAccess((member).name); + emitMemberAccessForPropertyName((member).name); emitEnd((member).name); write(" = "); emit((member).initializer); @@ -2916,7 +2940,7 @@ module ts { if (!(member.flags & NodeFlags.Static)) { write(".prototype"); } - emitMemberAccess((member).name); + emitMemberAccessForPropertyName((member).name); emitEnd((member).name); write(" = "); emitStart(member); @@ -3453,6 +3477,8 @@ module ts { return emitPropertyAssignment(node); case SyntaxKind.ShorthandPropertyAssignment: return emitShortHandPropertyAssignment(node); + case SyntaxKind.ComputedPropertyName: + return emitComputedPropertyName(node); case SyntaxKind.PropertyAccess: return emitPropertyAccess(node); case SyntaxKind.IndexedAccess: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 99bb1f6f85d..ed85ba711d3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -383,6 +383,8 @@ module ts { return child((node).head) || children((node).templateSpans); case SyntaxKind.TemplateSpan: return child((node).expression) || child((node).literal); + case SyntaxKind.ComputedPropertyName: + return child((node).expression); } } From 0e864143deb02caaceed46331c8deb54726b0802 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 17 Nov 2014 16:36:30 -0800 Subject: [PATCH 05/12] Emit tests for computed properties --- .../reference/computedPropertyNames1.js | 14 ++++++ .../computedPropertyNames2.errors.txt | 19 ++++++++ .../reference/computedPropertyNames2.js | 48 +++++++++++++++++++ .../computedPropertyNames3.errors.txt | 18 +++++++ .../reference/computedPropertyNames3.js | 47 ++++++++++++++++++ .../reference/parserComputedPropertyName12.js | 13 +++++ .../reference/parserComputedPropertyName17.js | 6 +++ .../reference/parserComputedPropertyName2.js | 5 ++ .../reference/parserComputedPropertyName24.js | 17 +++++++ .../reference/parserComputedPropertyName3.js | 6 +++ .../reference/parserComputedPropertyName4.js | 6 +++ .../reference/parserComputedPropertyName6.js | 5 ++ .../computedPropertyNames1.ts | 5 ++ .../computedPropertyNames2.ts | 11 +++++ .../computedPropertyNames3.ts | 10 ++++ .../computedPropertyNamesOnOverloads.ts | 8 ++++ 16 files changed, 238 insertions(+) create mode 100644 tests/baselines/reference/computedPropertyNames1.js create mode 100644 tests/baselines/reference/computedPropertyNames2.errors.txt create mode 100644 tests/baselines/reference/computedPropertyNames2.js create mode 100644 tests/baselines/reference/computedPropertyNames3.errors.txt create mode 100644 tests/baselines/reference/computedPropertyNames3.js create mode 100644 tests/baselines/reference/parserComputedPropertyName12.js create mode 100644 tests/baselines/reference/parserComputedPropertyName17.js create mode 100644 tests/baselines/reference/parserComputedPropertyName2.js create mode 100644 tests/baselines/reference/parserComputedPropertyName24.js create mode 100644 tests/baselines/reference/parserComputedPropertyName3.js create mode 100644 tests/baselines/reference/parserComputedPropertyName4.js create mode 100644 tests/baselines/reference/parserComputedPropertyName6.js create mode 100644 tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts create mode 100644 tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts create mode 100644 tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts create mode 100644 tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts diff --git a/tests/baselines/reference/computedPropertyNames1.js b/tests/baselines/reference/computedPropertyNames1.js new file mode 100644 index 00000000000..d5e3f3e0392 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames1.js @@ -0,0 +1,14 @@ +//// [computedPropertyNames1.ts] +var v = { + get [0 + 1]() { return 0 }, + set [0 + 1](v) { } +} + +//// [computedPropertyNames1.js] +var v = { + get [0 + 1]() { + return 0; + }, + set [0 + 1](v) { + } +}; diff --git a/tests/baselines/reference/computedPropertyNames2.errors.txt b/tests/baselines/reference/computedPropertyNames2.errors.txt new file mode 100644 index 00000000000..d0fd1de4576 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames2.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + + +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (2 errors) ==== + var methodName = "method"; + var accessorName = "accessor"; + class C { + [methodName]() { } + static [methodName]() { } + get [accessorName]() { } + ~~~~~~~~~~~~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + set [accessorName](v) { } + static get [accessorName]() { } + ~~~~~~~~~~~~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + static set [accessorName](v) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames2.js b/tests/baselines/reference/computedPropertyNames2.js new file mode 100644 index 00000000000..78d53ef94fc --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames2.js @@ -0,0 +1,48 @@ +//// [computedPropertyNames2.ts] +var methodName = "method"; +var accessorName = "accessor"; +class C { + [methodName]() { } + static [methodName]() { } + get [accessorName]() { } + set [accessorName](v) { } + static get [accessorName]() { } + static set [accessorName](v) { } +} + +//// [computedPropertyNames2.js] +var methodName = "method"; +var accessorName = "accessor"; +var C = (function () { + function C() { + } + C.prototype[methodName] = function () { + }; + C[methodName] = function () { + }; + Object.defineProperty(C.prototype, accessorName, { + get: function () { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, accessorName, { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, accessorName, { + get: function () { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, accessorName, { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/computedPropertyNames3.errors.txt b/tests/baselines/reference/computedPropertyNames3.errors.txt new file mode 100644 index 00000000000..37a4ddaf1c0 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames3.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + + +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (2 errors) ==== + var id; + class C { + [0 + 1]() { } + static [() => { }]() { } + get [delete id]() { } + ~~~~~~~~~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + set [[0, 1]](v) { } + static get [""]() { } + ~~~~~~~~~~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + static set [id.toString()](v) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames3.js b/tests/baselines/reference/computedPropertyNames3.js new file mode 100644 index 00000000000..fbd76bf48fc --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames3.js @@ -0,0 +1,47 @@ +//// [computedPropertyNames3.ts] +var id; +class C { + [0 + 1]() { } + static [() => { }]() { } + get [delete id]() { } + set [[0, 1]](v) { } + static get [""]() { } + static set [id.toString()](v) { } +} + +//// [computedPropertyNames3.js] +var id; +var C = (function () { + function C() { + } + C.prototype[0 + 1] = function () { + }; + C[function () { + }] = function () { + }; + Object.defineProperty(C.prototype, delete id, { + get: function () { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, [0, 1], { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "", { + get: function () { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, id.toString(), { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName12.js b/tests/baselines/reference/parserComputedPropertyName12.js new file mode 100644 index 00000000000..96e62b626e7 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName12.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName12.ts] +class C { + [e]() { } +} + +//// [parserComputedPropertyName12.js] +var C = (function () { + function C() { + } + C.prototype[e] = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName17.js b/tests/baselines/reference/parserComputedPropertyName17.js new file mode 100644 index 00000000000..98d61ab8bca --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName17.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName17.ts] +var v = { set [e](v) { } } + +//// [parserComputedPropertyName17.js] +var v = { set [e](v) { +} }; diff --git a/tests/baselines/reference/parserComputedPropertyName2.js b/tests/baselines/reference/parserComputedPropertyName2.js new file mode 100644 index 00000000000..f3c41f963f5 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName2.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName2.ts] +var v = { [e]: 1 }; + +//// [parserComputedPropertyName2.js] +var v = { [e]: 1 }; diff --git a/tests/baselines/reference/parserComputedPropertyName24.js b/tests/baselines/reference/parserComputedPropertyName24.js new file mode 100644 index 00000000000..0b9467fb26d --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName24.js @@ -0,0 +1,17 @@ +//// [parserComputedPropertyName24.ts] +class C { + set [e](v) { } +} + +//// [parserComputedPropertyName24.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, e, { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName3.js b/tests/baselines/reference/parserComputedPropertyName3.js new file mode 100644 index 00000000000..edb8533ad81 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName3.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName3.ts] +var v = { [e]() { } }; + +//// [parserComputedPropertyName3.js] +var v = { [e]: function () { +} }; diff --git a/tests/baselines/reference/parserComputedPropertyName4.js b/tests/baselines/reference/parserComputedPropertyName4.js new file mode 100644 index 00000000000..a88545566e6 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName4.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName4.ts] +var v = { get [e]() { } }; + +//// [parserComputedPropertyName4.js] +var v = { get [e]() { +} }; diff --git a/tests/baselines/reference/parserComputedPropertyName6.js b/tests/baselines/reference/parserComputedPropertyName6.js new file mode 100644 index 00000000000..b60ad66a9d8 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName6.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName6.ts] +var v = { [e]: 1, [e + e]: 2 }; + +//// [parserComputedPropertyName6.js] +var v = { [e]: 1, [e + e]: 2 }; diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts new file mode 100644 index 00000000000..b35ab29b129 --- /dev/null +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts @@ -0,0 +1,5 @@ +// @target: es6 +var v = { + get [0 + 1]() { return 0 }, + set [0 + 1](v) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts new file mode 100644 index 00000000000..c63ec81d4e6 --- /dev/null +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts @@ -0,0 +1,11 @@ +// @target: es6 +var methodName = "method"; +var accessorName = "accessor"; +class C { + [methodName]() { } + static [methodName]() { } + get [accessorName]() { } + set [accessorName](v) { } + static get [accessorName]() { } + static set [accessorName](v) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts new file mode 100644 index 00000000000..45db2c02fe2 --- /dev/null +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts @@ -0,0 +1,10 @@ +// @target: es6 +var id; +class C { + [0 + 1]() { } + static [() => { }]() { } + get [delete id]() { } + set [[0, 1]](v) { } + static get [""]() { } + static set [id.toString()](v) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts new file mode 100644 index 00000000000..4d6fe09b80a --- /dev/null +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts @@ -0,0 +1,8 @@ +// @target: es6 +var methodName = "method"; +var accessorName = "accessor"; +class C { + [methodName](v: string); + [methodName](); + [methodName](v?: string) { } +} \ No newline at end of file From 98eda2bf5cba36278bfcccf28377ecdd96f751f0 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 18 Nov 2014 10:53:22 -0800 Subject: [PATCH 06/12] Syntax error for computed properties on method overloads --- src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ .../reference/parserComputedPropertyName11.errors.txt | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index c8156dff138..4fbc864b3c5 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -131,6 +131,7 @@ module ts { Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1163, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." }, Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." }, Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + Computed_property_names_are_not_allowed_in_method_overloads: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5784a427224..ba4fb052094 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -515,6 +515,10 @@ "category": "Error", "code": 1165 }, + "Computed property names are not allowed in method overloads.": { + "category": "Error", + "code": 1166 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index 2d2edd2b841..fe2e82b54ee 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,9 +1,12 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1166: Computed property names are not allowed in method overloads. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (2 errors) ==== class C { [e](); ~~~ +!!! error TS1166: Computed property names are not allowed in method overloads. + ~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. } \ No newline at end of file From 2bc1f4f4faba14d7ed82bd0d7db34fb158c0f6e0 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 18 Nov 2014 14:34:04 -0800 Subject: [PATCH 07/12] Update error codes --- .../diagnosticInformationMap.generated.ts | 14 ++++---- src/compiler/diagnosticMessages.json | 30 ++++++++--------- src/compiler/parser.ts | 7 +++- .../ComputedPropertyName10_es6.errors.txt | 9 ------ .../ComputedPropertyName11_es6.errors.txt | 15 --------- .../ComputedPropertyName12_es6.errors.txt | 15 --------- .../ComputedPropertyName13_es6.errors.txt | 7 ---- .../ComputedPropertyName14_es6.errors.txt | 7 ---- .../ComputedPropertyName15_es6.errors.txt | 7 ---- .../ComputedPropertyName16_es6.errors.txt | 18 ----------- .../ComputedPropertyName17_es6.errors.txt | 16 ---------- .../ComputedPropertyName18_es6.errors.txt | 7 ---- .../ComputedPropertyName19_es6.errors.txt | 7 ---- .../ComputedPropertyName1_es6.errors.txt | 13 -------- .../ComputedPropertyName2_es6.errors.txt | 19 ----------- .../ComputedPropertyName3_es6.errors.txt | 16 ---------- .../ComputedPropertyName4_es6.errors.txt | 16 ---------- .../ComputedPropertyName5_es6.errors.txt | 19 ----------- .../ComputedPropertyName6_es6.errors.txt | 28 ---------------- .../ComputedPropertyName7_es6.errors.txt | 9 ------ .../ComputedPropertyName8_es6.errors.txt | 9 ------ .../ComputedPropertyName9_es6.errors.txt | 12 ------- tests/baselines/reference/giant.errors.txt | 32 +++++++++---------- ...SignatureMustHaveTypeAnnotation.errors.txt | 8 ++--- .../indexSignatureWithInitializer.errors.txt | 8 ++--- .../indexWithoutParamType2.errors.txt | 4 +-- ...objectTypeWithOptionalProperty1.errors.txt | 4 +-- ...jectTypesWithOptionalProperties.errors.txt | 4 +-- .../parserComputedPropertyName10.errors.txt | 4 +-- .../parserComputedPropertyName11.errors.txt | 4 +-- .../parserComputedPropertyName13.errors.txt | 4 +-- .../parserComputedPropertyName14.errors.txt | 4 +-- .../parserComputedPropertyName15.errors.txt | 4 +-- .../parserComputedPropertyName16.errors.txt | 4 +-- .../parserComputedPropertyName18.errors.txt | 4 +-- .../parserComputedPropertyName19.errors.txt | 4 +-- .../parserComputedPropertyName20.errors.txt | 4 +-- .../parserComputedPropertyName21.errors.txt | 4 +-- .../parserComputedPropertyName22.errors.txt | 4 +-- .../parserComputedPropertyName25.errors.txt | 4 +-- .../parserComputedPropertyName26.errors.txt | 4 +-- .../parserComputedPropertyName28.errors.txt | 8 ++--- .../parserComputedPropertyName29.errors.txt | 8 ++--- .../parserComputedPropertyName31.errors.txt | 8 ++--- .../parserComputedPropertyName32.errors.txt | 4 +-- .../parserComputedPropertyName34.errors.txt | 8 ++--- .../parserComputedPropertyName7.errors.txt | 4 +-- .../parserComputedPropertyName8.errors.txt | 4 +-- .../parserComputedPropertyName9.errors.txt | 4 +-- .../parserES5ComputedPropertyName1.errors.txt | 4 +-- ...parserES5ComputedPropertyName10.errors.txt | 4 +-- ...parserES5ComputedPropertyName11.errors.txt | 4 +-- .../parserES5ComputedPropertyName2.errors.txt | 4 +-- .../parserES5ComputedPropertyName3.errors.txt | 4 +-- .../parserES5ComputedPropertyName4.errors.txt | 4 +-- .../parserES5ComputedPropertyName5.errors.txt | 4 +-- .../parserES5ComputedPropertyName6.errors.txt | 4 +-- .../parserES5ComputedPropertyName7.errors.txt | 4 +-- .../parserES5ComputedPropertyName8.errors.txt | 4 +-- .../parserES5ComputedPropertyName9.errors.txt | 4 +-- .../parserIndexSignature11.errors.txt | 4 +-- .../parserIndexSignature4.errors.txt | 4 +-- .../parserIndexSignature5.errors.txt | 4 +-- .../reference/propertyAssignment.errors.txt | 4 +-- ...uestionMarkInPropertyAssignment.errors.txt | 4 +-- .../ComputedPropertyName10_es6.ts | 3 -- .../ComputedPropertyName11_es6.ts | 3 -- .../ComputedPropertyName12_es6.ts | 3 -- .../ComputedPropertyName13_es6.ts | 1 - .../ComputedPropertyName14_es6.ts | 1 - .../ComputedPropertyName15_es6.ts | 1 - .../ComputedPropertyName16_es6.ts | 3 -- .../ComputedPropertyName17_es6.ts | 1 - .../ComputedPropertyName18_es6.ts | 1 - .../ComputedPropertyName19_es6.ts | 1 - .../ComputedPropertyName1_es6.ts | 1 - .../ComputedPropertyName2_es6.ts | 1 - .../ComputedPropertyName3_es6.ts | 1 - .../ComputedPropertyName4_es6.ts | 1 - .../ComputedPropertyName5_es6.ts | 1 - .../ComputedPropertyName6_es6.ts | 1 - .../ComputedPropertyName7_es6.ts | 3 -- .../ComputedPropertyName8_es6.ts | 3 -- .../ComputedPropertyName9_es6.ts | 3 -- 84 files changed, 140 insertions(+), 417 deletions(-) delete mode 100644 tests/baselines/reference/ComputedPropertyName10_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName11_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName12_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName13_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName14_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName15_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName16_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName17_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName18_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName19_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName1_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName2_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName3_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName4_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName5_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName6_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName7_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName8_es6.errors.txt delete mode 100644 tests/baselines/reference/ComputedPropertyName9_es6.errors.txt delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts delete mode 100644 tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 4fbc864b3c5..5187fc2512b 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -124,14 +124,14 @@ module ts { Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1160, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - Computed_property_names_are_not_allowed_in_interfaces_or_type_literals: { code: 1161, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces or type literals." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1162, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, - Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1163, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." }, - Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, - Computed_property_names_are_not_allowed_in_method_overloads: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, + Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." }, + Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." }, + Computed_property_names_are_not_allowed_in_interfaces_or_type_literals: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces or type literals." }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ba4fb052094..8b3cd797c63 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -488,14 +488,6 @@ "code": 1161 }, "An object member cannot be declared optional.": { - "category": "Error", - "code": 1160 - }, - "Computed property names are not allowed in interfaces or type literals.": { - "category": "Error", - "code": 1161 - }, - "Computed property names are not allowed in enums.": { "category": "Error", "code": 1162 }, @@ -503,22 +495,30 @@ "category": "Error", "code": 1163 }, - "Computed property names are not allowed in an ambient context.": { - "category": "Error", - "code": 1163 - }, - "Computed property names are not allowed in class property declarations.": { + "Computed property names are not allowed in enums.": { "category": "Error", "code": 1164 }, - "Computed property names are only available when targeting ECMAScript 6 and higher.": { + "Computed property names are not allowed in an ambient context.": { "category": "Error", "code": 1165 }, - "Computed property names are not allowed in method overloads.": { + "Computed property names are not allowed in class property declarations.": { "category": "Error", "code": 1166 }, + "Computed property names are only available when targeting ECMAScript 6 and higher.": { + "category": "Error", + "code": 1167 + }, + "Computed property names are not allowed in method overloads.": { + "category": "Error", + "code": 1168 + }, + "Computed property names are not allowed in interfaces or type literals.": { + "category": "Error", + "code": 1169 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ed85ba711d3..76cabe94e2e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4477,7 +4477,12 @@ module ts { // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - return inAmbientContext && checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + if (inAmbientContext) { + return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + } + else if (!node.body) { + return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); + } } else if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral) { return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces_or_type_literals); diff --git a/tests/baselines/reference/ComputedPropertyName10_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName10_es6.errors.txt deleted file mode 100644 index ba7154a9298..00000000000 --- a/tests/baselines/reference/ComputedPropertyName10_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts(2,8): error TS1005: ';' expected. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts (1 errors) ==== - class C { - [e] = 1 - ~ -!!! error TS1005: ';' expected. - } \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName11_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName11_es6.errors.txt deleted file mode 100644 index 3f96913c1d5..00000000000 --- a/tests/baselines/reference/ComputedPropertyName11_es6.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(2,7): error TS1005: ';' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(2,8): error TS1109: Expression expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(3,1): error TS1128: Declaration or statement expected. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts (3 errors) ==== - class C { - [e](); - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1109: Expression expected. - } - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName12_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName12_es6.errors.txt deleted file mode 100644 index fefff058fe1..00000000000 --- a/tests/baselines/reference/ComputedPropertyName12_es6.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(2,7): error TS1005: ';' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(2,10): error TS1005: '=>' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(3,1): error TS1128: Declaration or statement expected. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts (3 errors) ==== - class C { - [e]() { } - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: '=>' expected. - } - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName13_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName13_es6.errors.txt deleted file mode 100644 index 3f8c10fc643..00000000000 --- a/tests/baselines/reference/ComputedPropertyName13_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts(1,11): error TS1022: An index signature parameter must have a type annotation. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts (1 errors) ==== - var v: { [e]: number }; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName14_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName14_es6.errors.txt deleted file mode 100644 index 7d6052b4179..00000000000 --- a/tests/baselines/reference/ComputedPropertyName14_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts(1,13): error TS1005: ';' expected. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts (1 errors) ==== - var v: { [e](): number }; - ~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName15_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName15_es6.errors.txt deleted file mode 100644 index 689df40f985..00000000000 --- a/tests/baselines/reference/ComputedPropertyName15_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts(1,32): error TS1022: An index signature parameter must have a type annotation. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts (1 errors) ==== - var v: { [e: number]: string; [e]: number }; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName16_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName16_es6.errors.txt deleted file mode 100644 index c3de61ddf07..00000000000 --- a/tests/baselines/reference/ComputedPropertyName16_es6.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,3): error TS1132: Enum member expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(3,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,3): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,4): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts (4 errors) ==== - enum E { - [e] = 1 - ~ -!!! error TS1132: Enum member expected. - ~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. - ~ -!!! error TS2304: Cannot find name 'e'. - } - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName17_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName17_es6.errors.txt deleted file mode 100644 index 4b8caf1e62d..00000000000 --- a/tests/baselines/reference/ComputedPropertyName17_es6.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,15): error TS1003: Identifier expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,22): error TS1005: ',' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,26): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,16): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts (4 errors) ==== - var v = { set [e](v) { } } - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName18_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName18_es6.errors.txt deleted file mode 100644 index 8e409750b5c..00000000000 --- a/tests/baselines/reference/ComputedPropertyName18_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts(1,13): error TS1005: ';' expected. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts (1 errors) ==== - var v: { [e]?(): number }; - ~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName19_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName19_es6.errors.txt deleted file mode 100644 index 1833deef789..00000000000 --- a/tests/baselines/reference/ComputedPropertyName19_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts(1,13): error TS1005: ';' expected. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts (1 errors) ==== - var v: { [e]? }; - ~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName1_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName1_es6.errors.txt deleted file mode 100644 index 260ff20dc36..00000000000 --- a/tests/baselines/reference/ComputedPropertyName1_es6.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,11): error TS1136: Property assignment expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,15): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,12): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts (3 errors) ==== - var v = { [e] }; - ~ -!!! error TS1136: Property assignment expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName2_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName2_es6.errors.txt deleted file mode 100644 index f0a06ef84bc..00000000000 --- a/tests/baselines/reference/ComputedPropertyName2_es6.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,11): error TS1136: Property assignment expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,14): error TS1005: ',' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,16): error TS1134: Variable declaration expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,18): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,12): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts (5 errors) ==== - var v = { [e]: 1 }; - ~ -!!! error TS1136: Property assignment expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1134: Variable declaration expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName3_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName3_es6.errors.txt deleted file mode 100644 index 3f1e5d707a8..00000000000 --- a/tests/baselines/reference/ComputedPropertyName3_es6.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,11): error TS1136: Property assignment expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,17): error TS1005: ',' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,21): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,12): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts (4 errors) ==== - var v = { [e]() { } }; - ~ -!!! error TS1136: Property assignment expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName4_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName4_es6.errors.txt deleted file mode 100644 index a1f22f611f9..00000000000 --- a/tests/baselines/reference/ComputedPropertyName4_es6.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,15): error TS1003: Identifier expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,21): error TS1005: ',' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,25): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,16): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts (4 errors) ==== - var v = { get [e]() { } }; - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName5_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName5_es6.errors.txt deleted file mode 100644 index 2ce2faaee62..00000000000 --- a/tests/baselines/reference/ComputedPropertyName5_es6.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,18): error TS1005: ':' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,28): error TS1005: ',' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,32): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,18): error TS2304: Cannot find name 'get'. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,23): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts (5 errors) ==== - var v = { public get [e]() { } }; - ~~~ -!!! error TS1005: ':' expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~ -!!! error TS2304: Cannot find name 'get'. - ~ -!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName6_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName6_es6.errors.txt deleted file mode 100644 index ca6bce48295..00000000000 --- a/tests/baselines/reference/ComputedPropertyName6_es6.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,11): error TS1136: Property assignment expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,14): error TS1005: ',' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,16): error TS1134: Variable declaration expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,26): error TS1005: ';' expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,30): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,12): error TS2304: Cannot find name 'e'. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,20): error TS2304: Cannot find name 'e'. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,24): error TS2304: Cannot find name 'e'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts (8 errors) ==== - var v = { [e]: 1, [e + e]: 2 }; - ~ -!!! error TS1136: Property assignment expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1134: Variable declaration expected. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS2304: Cannot find name 'e'. - ~ -!!! error TS2304: Cannot find name 'e'. - ~ -!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName7_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName7_es6.errors.txt deleted file mode 100644 index 00be8f610e0..00000000000 --- a/tests/baselines/reference/ComputedPropertyName7_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts(2,5): error TS1022: An index signature parameter must have a type annotation. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts (1 errors) ==== - class C { - [e] - ~ -!!! error TS1022: An index signature parameter must have a type annotation. - } \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName8_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName8_es6.errors.txt deleted file mode 100644 index 58386bbe177..00000000000 --- a/tests/baselines/reference/ComputedPropertyName8_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts(2,12): error TS1022: An index signature parameter must have a type annotation. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts (1 errors) ==== - class C { - public [e] - ~ -!!! error TS1022: An index signature parameter must have a type annotation. - } \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName9_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName9_es6.errors.txt deleted file mode 100644 index 0872f69aebe..00000000000 --- a/tests/baselines/reference/ComputedPropertyName9_es6.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts(2,5): error TS1022: An index signature parameter must have a type annotation. -tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts(2,9): error TS2304: Cannot find name 'Type'. - - -==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts (2 errors) ==== - class C { - [e]: Type - ~ -!!! error TS1022: An index signature parameter must have a type annotation. - ~~~~ -!!! error TS2304: Cannot find name 'Type'. - } \ No newline at end of file diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index 5bc00b7cd28..bd2e2fa6935 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/giant.ts(28,17): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(30,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(34,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(61,5): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(61,5): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(88,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -13,7 +13,7 @@ tests/cases/compiler/giant.ts(92,21): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(94,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(98,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(100,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(125,9): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(125,9): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(154,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -23,7 +23,7 @@ tests/cases/compiler/giant.ts(171,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(173,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(177,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(179,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(204,9): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(204,9): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(233,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -54,7 +54,7 @@ tests/cases/compiler/giant.ts(286,17): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(288,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(292,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(294,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(319,5): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(319,5): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(346,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -63,7 +63,7 @@ tests/cases/compiler/giant.ts(350,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(352,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(356,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(358,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(383,9): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(383,9): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(412,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -73,7 +73,7 @@ tests/cases/compiler/giant.ts(429,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(431,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(435,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(437,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(462,9): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(462,9): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(491,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -120,7 +120,7 @@ tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(561,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(563,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(587,9): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(587,9): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(606,22): error TS1037: A function implementation cannot be declared in an ambient context. @@ -137,7 +137,7 @@ tests/cases/compiler/giant.ts(621,29): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(623,24): error TS1111: A constructor implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(626,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(628,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(653,9): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(653,9): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(672,22): error TS1037: A function implementation cannot be declared in an ambient context. @@ -361,7 +361,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -469,7 +469,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -594,7 +594,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -821,7 +821,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -929,7 +929,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1054,7 +1054,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1323,7 +1323,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1425,7 +1425,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index c76acf795ac..f0bd02524c8 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021: An index signature must have a type annotation. @@ -8,7 +8,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021 interface I { [x]: string; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [x: string]; ~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -17,7 +17,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021 class C { [x]: string ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } diff --git a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt index 414bcdfb84c..cc4e4a9bf4d 100644 --- a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt +++ b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt @@ -1,16 +1,16 @@ -tests/cases/compiler/indexSignatureWithInitializer.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. -tests/cases/compiler/indexSignatureWithInitializer.ts(6,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/compiler/indexSignatureWithInitializer.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/indexSignatureWithInitializer.ts(6,5): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/compiler/indexSignatureWithInitializer.ts (2 errors) ==== interface I { [x = '']: string; ~~~~~~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. } class C { [x = 0]: string ~~~~~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/indexWithoutParamType2.errors.txt b/tests/baselines/reference/indexWithoutParamType2.errors.txt index f9ab6057546..41527d0859f 100644 --- a/tests/baselines/reference/indexWithoutParamType2.errors.txt +++ b/tests/baselines/reference/indexWithoutParamType2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/indexWithoutParamType2.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/compiler/indexWithoutParamType2.ts(2,5): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/compiler/indexWithoutParamType2.ts (1 errors) ==== class C { [x]: string ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt b/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt index 7e17563873a..e2e1c05ea1e 100644 --- a/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt +++ b/tests/baselines/reference/objectTypeWithOptionalProperty1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/objectTypeWithOptionalProperty1.ts(2,10): error TS1160: An object member cannot be declared optional. +tests/cases/compiler/objectTypeWithOptionalProperty1.ts(2,10): error TS1162: An object member cannot be declared optional. ==== tests/cases/compiler/objectTypeWithOptionalProperty1.ts (1 errors) ==== var b = { x?: 1 // error ~ -!!! error TS1160: An object member cannot be declared optional. +!!! error TS1162: An object member cannot be declared optional. } \ No newline at end of file diff --git a/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt b/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt index d33a5e35b63..a2269c29d11 100644 --- a/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt +++ b/tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(12,6): error TS1112: A class member cannot be declared optional. tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(20,6): error TS1112: A class member cannot be declared optional. -tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1160: An object member cannot be declared optional. +tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1162: An object member cannot be declared optional. ==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts (3 errors) ==== @@ -33,5 +33,5 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWith var b = { x?: 1 // error ~ -!!! error TS1160: An object member cannot be declared optional. +!!! error TS1162: An object member cannot be declared optional. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName10.errors.txt b/tests/baselines/reference/parserComputedPropertyName10.errors.txt index 279750d21bd..704c37ebf45 100644 --- a/tests/baselines/reference/parserComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName10.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts (1 errors) ==== class C { [e] = 1 ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index fe2e82b54ee..a47865ba3f8 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1166: Computed property names are not allowed in method overloads. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e](); ~~~ -!!! error TS1166: Computed property names are not allowed in method overloads. +!!! error TS1168: Computed property names are not allowed in method overloads. ~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName13.errors.txt b/tests/baselines/reference/parserComputedPropertyName13.errors.txt index eb5eb57d902..38ad6c1c74c 100644 --- a/tests/baselines/reference/parserComputedPropertyName13.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts (1 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt index ac5fcfff3bd..fe26de08c9d 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (1 errors) ==== var v: { [e](): number }; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName15.errors.txt b/tests/baselines/reference/parserComputedPropertyName15.errors.txt index e03c5c1f259..eaa86105727 100644 --- a/tests/baselines/reference/parserComputedPropertyName15.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts (1 errors) ==== var v: { [e: number]: string; [e]: number }; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName16.errors.txt b/tests/baselines/reference/parserComputedPropertyName16.errors.txt index 8deb137f3af..23361b4ce7e 100644 --- a/tests/baselines/reference/parserComputedPropertyName16.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName16.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts(2,3): error TS1162: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts(2,3): error TS1164: Computed property names are not allowed in enums. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts (1 errors) ==== enum E { [e] = 1 ~~~ -!!! error TS1162: Computed property names are not allowed in enums. +!!! error TS1164: Computed property names are not allowed in enums. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt index 1e09dae76aa..c8241febfe4 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (1 errors) ==== var v: { [e]?(): number }; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName19.errors.txt b/tests/baselines/reference/parserComputedPropertyName19.errors.txt index 3ee3ed84d7b..fd17b02724d 100644 --- a/tests/baselines/reference/parserComputedPropertyName19.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts (1 errors) ==== var v: { [e]? }; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt index 2b77f033d9e..12a82cc6f68 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts (1 errors) ==== interface I { [e](): number ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName21.errors.txt b/tests/baselines/reference/parserComputedPropertyName21.errors.txt index f472afd93ee..b25b1484a90 100644 --- a/tests/baselines/reference/parserComputedPropertyName21.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts (1 errors) ==== interface I { [e]: number ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName22.errors.txt b/tests/baselines/reference/parserComputedPropertyName22.errors.txt index dae871108f0..5149c937108 100644 --- a/tests/baselines/reference/parserComputedPropertyName22.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName22.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts (1 errors) ==== declare class C { [e]: number ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName25.errors.txt b/tests/baselines/reference/parserComputedPropertyName25.errors.txt index 7e0d3abdd37..c8dd6b3bc7c 100644 --- a/tests/baselines/reference/parserComputedPropertyName25.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName25.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // No ASI [e] = 0 ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. [e2] = 1 ~~ !!! error TS2304: Cannot find name 'e2'. diff --git a/tests/baselines/reference/parserComputedPropertyName26.errors.txt b/tests/baselines/reference/parserComputedPropertyName26.errors.txt index 85d0729e73f..9b1cf1d53f4 100644 --- a/tests/baselines/reference/parserComputedPropertyName26.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName26.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts(3,5): error TS1162: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts(3,5): error TS1164: Computed property names are not allowed in enums. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // No ASI [e] = 0 ~~~ -!!! error TS1162: Computed property names are not allowed in enums. +!!! error TS1164: Computed property names are not allowed in enums. [e2] = 1 ~~ !!! error TS2304: Cannot find name 'e2'. diff --git a/tests/baselines/reference/parserComputedPropertyName28.errors.txt b/tests/baselines/reference/parserComputedPropertyName28.errors.txt index f36b15b61b6..bc32f34c151 100644 --- a/tests/baselines/reference/parserComputedPropertyName28.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName28.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1166: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts (2 errors) ==== class C { [e]: number = 0; ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. [e2]: number ~~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName29.errors.txt b/tests/baselines/reference/parserComputedPropertyName29.errors.txt index 0b832d1b68f..13a15bf5f9d 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,11): error TS2304: Cannot find name 'id'. @@ -8,10 +8,10 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e] = id++ ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. ~~ !!! error TS2304: Cannot find name 'id'. [e2]: number ~~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName31.errors.txt b/tests/baselines/reference/parserComputedPropertyName31.errors.txt index 21f96dcbf5d..6dddbd859c9 100644 --- a/tests/baselines/reference/parserComputedPropertyName31.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName31.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1164: Computed property names are not allowed in class property declarations. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1166: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts (2 errors) ==== @@ -7,8 +7,8 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e]: number ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. [e2]: number ~~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName32.errors.txt b/tests/baselines/reference/parserComputedPropertyName32.errors.txt index 88d738421e2..4407014cf99 100644 --- a/tests/baselines/reference/parserComputedPropertyName32.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1163: Computed property names are not allowed in an ambient context. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: Computed property names are not allowed in an ambient context. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts (1 errors) ==== declare class C { [e](): number ~~~ -!!! error TS1163: Computed property names are not allowed in an ambient context. +!!! error TS1165: Computed property names are not allowed in an ambient context. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName34.errors.txt b/tests/baselines/reference/parserComputedPropertyName34.errors.txt index b1cc4b91533..05d7375f132 100644 --- a/tests/baselines/reference/parserComputedPropertyName34.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName34.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(3,5): error TS1162: Computed property names are not allowed in enums. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(4,5): error TS1162: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(3,5): error TS1164: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(4,5): error TS1164: Computed property names are not allowed in enums. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(3,11): error TS2304: Cannot find name 'id'. @@ -8,10 +8,10 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // no ASI, comma expected [e] = id++, ~~~ -!!! error TS1162: Computed property names are not allowed in enums. +!!! error TS1164: Computed property names are not allowed in enums. ~~ !!! error TS2304: Cannot find name 'id'. [e2] = 1 ~~~~ -!!! error TS1162: Computed property names are not allowed in enums. +!!! error TS1164: Computed property names are not allowed in enums. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName7.errors.txt b/tests/baselines/reference/parserComputedPropertyName7.errors.txt index 6c46fc343a8..21147be3074 100644 --- a/tests/baselines/reference/parserComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName7.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts (1 errors) ==== class C { [e] ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName8.errors.txt b/tests/baselines/reference/parserComputedPropertyName8.errors.txt index 07f5ec5dee1..75352ec9e51 100644 --- a/tests/baselines/reference/parserComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName8.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts (1 errors) ==== class C { public [e] ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName9.errors.txt b/tests/baselines/reference/parserComputedPropertyName9.errors.txt index a93da2261c8..eb5cfd28d73 100644 --- a/tests/baselines/reference/parserComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e]: Type ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. ~~~~ !!! error TS2304: Cannot find name 'Type'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt index 75e5d505696..5bae79b95aa 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts (1 errors) ==== declare class C { [e]: number ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt index c2e53b50818..40bec1b4f38 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts (1 errors) ==== class C { [e] = 1 ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt index cfd2ba4c3f8..f37cf910a15 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e](); ~~~ -!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. +!!! error TS1168: Computed property names are not allowed in method overloads. ~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt index 9b2d920f53f..dc7d7e7ba30 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,11): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts (1 errors) ==== var v = { [e]: 1 }; ~~~ -!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt index da346e98bae..376c1a29ae4 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,11): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts (1 errors) ==== var v = { [e]() { } }; ~~~ -!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt index b99115f8d1e..e0b816f157c 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts (1 errors) ==== var v = { get [e]() { } }; ~~~ -!!! error TS1165: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt index fc7a67e729b..1cc70551961 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts (1 errors) ==== interface I { [e]: number ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt index ce3592b08e0..7f43220fc0d 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts(2,3): error TS1162: Computed property names are not allowed in enums. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts(2,3): error TS1164: Computed property names are not allowed in enums. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts (1 errors) ==== enum E { [e] = 1 ~~~ -!!! error TS1162: Computed property names are not allowed in enums. +!!! error TS1164: Computed property names are not allowed in enums. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt index 5bc1a94da3b..6aefd27ef58 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts (1 errors) ==== class C { [e] ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt index e5312829ab6..6a6964849a1 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts (1 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt index af78dcc3e4e..6d035a7c610 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1164: Computed property names are not allowed in class property declarations. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e]: Type ~~~ -!!! error TS1164: Computed property names are not allowed in class property declarations. +!!! error TS1166: Computed property names are not allowed in class property declarations. ~~~~ !!! error TS2304: Cannot find name 'Type'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature11.errors.txt b/tests/baselines/reference/parserIndexSignature11.errors.txt index 427d3090e48..dfdd9955daa 100644 --- a/tests/baselines/reference/parserIndexSignature11.errors.txt +++ b/tests/baselines/reference/parserIndexSignature11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(3,9): error TS1021: An index signature must have a type annotation. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(4,10): error TS1096: An index signature must have exactly one parameter. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1 interface I { [p]; ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/parserIndexSignature4.errors.txt b/tests/baselines/reference/parserIndexSignature4.errors.txt index f93d8aed249..b658dfdd69e 100644 --- a/tests/baselines/reference/parserIndexSignature4.errors.txt +++ b/tests/baselines/reference/parserIndexSignature4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts (1 errors) ==== interface I { [a = 0] ~~~~~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature5.errors.txt b/tests/baselines/reference/parserIndexSignature5.errors.txt index dc6bd18d773..b4d5c5534d0 100644 --- a/tests/baselines/reference/parserIndexSignature5.errors.txt +++ b/tests/baselines/reference/parserIndexSignature5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: Computed property names are not allowed in interfaces or type literals. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts (1 errors) ==== interface I { [a] ~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. } \ No newline at end of file diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index 41bc7cb6065..37df97d5d42 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAssignment.ts(6,13): error TS1161: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/propertyAssignment.ts(6,13): error TS1169: Computed property names are not allowed in interfaces or type literals. tests/cases/compiler/propertyAssignment.ts(14,1): error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: number; }' is not assignable to type '() => void'. @@ -11,7 +11,7 @@ tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: numbe var foo2: { [index]; } // should be an error ~~~~~~~ -!!! error TS1161: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces or type literals. var bar2: { x : number; } var foo3: { ():void; } diff --git a/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt b/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt index f89252523ef..d51b97546d4 100644 --- a/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt +++ b/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts(1,12): error TS1160: An object member cannot be declared optional. +tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts(1,12): error TS1162: An object member cannot be declared optional. ==== tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts (1 errors) ==== var x = {x ?: 1} // should not crash ~ -!!! error TS1160: An object member cannot be declared optional. \ No newline at end of file +!!! error TS1162: An object member cannot be declared optional. \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts deleted file mode 100644 index 64f8b999003..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts +++ /dev/null @@ -1,3 +0,0 @@ -class C { - [e] = 1 -} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts deleted file mode 100644 index cfb1c736b40..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts +++ /dev/null @@ -1,3 +0,0 @@ -class C { - [e](); -} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts deleted file mode 100644 index 7e030263fcc..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts +++ /dev/null @@ -1,3 +0,0 @@ -class C { - [e]() { } -} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts deleted file mode 100644 index 2783955e804..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v: { [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts deleted file mode 100644 index 534b418854b..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v: { [e](): number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts deleted file mode 100644 index 7b9965e8177..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v: { [e: number]: string; [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts deleted file mode 100644 index a088319bf94..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts +++ /dev/null @@ -1,3 +0,0 @@ -enum E { - [e] = 1 -} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts deleted file mode 100644 index 2d002e9ca43..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v = { set [e](v) { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts deleted file mode 100644 index 0659070d643..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v: { [e]?(): number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts deleted file mode 100644 index b6c1756d097..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v: { [e]? }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts deleted file mode 100644 index 0703648cf0b..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v = { [e] }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts deleted file mode 100644 index 34c9d6d918a..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v = { [e]: 1 }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts deleted file mode 100644 index 08ad781e2ba..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v = { [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts deleted file mode 100644 index d5a331ebb4c..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v = { get [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts deleted file mode 100644 index a254f65ee67..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v = { public get [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts deleted file mode 100644 index c09627a0d46..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts +++ /dev/null @@ -1 +0,0 @@ -var v = { [e]: 1, [e + e]: 2 }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts deleted file mode 100644 index b23944da796..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts +++ /dev/null @@ -1,3 +0,0 @@ -class C { - [e] -} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts deleted file mode 100644 index 18f1fd61276..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts +++ /dev/null @@ -1,3 +0,0 @@ -class C { - public [e] -} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts deleted file mode 100644 index 18e290722aa..00000000000 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts +++ /dev/null @@ -1,3 +0,0 @@ -class C { - [e]: Type -} \ No newline at end of file From f6266fc99ed5462d0f3702d029d2bf33aee62b5d Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 19 Nov 2014 15:19:18 -0800 Subject: [PATCH 08/12] Checker refactor for FunctionLike and VariableOrProperty --- src/compiler/binder.ts | 15 +- src/compiler/checker.ts | 152 ++++++++++-------- src/compiler/parser.ts | 3 +- src/compiler/types.ts | 8 +- .../reference/computedPropertyNames1.js | 4 +- .../reference/computedPropertyNames1.types | 12 ++ ...omputedPropertyNamesOnOverloads.errors.txt | 16 ++ .../parserComputedPropertyName11.errors.txt | 5 +- ...parserES5ComputedPropertyName11.errors.txt | 5 +- .../computedPropertyNames1.ts | 2 +- 10 files changed, 134 insertions(+), 88 deletions(-) create mode 100644 tests/baselines/reference/computedPropertyNames1.types create mode 100644 tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1a1075d9d9e..195782a9e1f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -53,6 +53,10 @@ module ts { } } + export function hasUnknownComputedName(declaration: Declaration): boolean { + return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName; + } + export function bindSourceFile(file: SourceFile) { var parent: Node; @@ -84,13 +88,14 @@ module ts { if (symbolKind & SymbolFlags.Value && !symbol.valueDeclaration) symbol.valueDeclaration = node; } - // TODO(jfreeman): Implement getDeclarationName for property name + // Should not be called on a declaration with a computed property name. function getDeclarationName(node: Declaration): string { if (node.name) { if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) { return '"' + (node.name).text + '"'; } - return (node.name).text; + Debug.assert(node.name.kind !== SyntaxKind.ComputedPropertyName); + return (node.name).text; } switch (node.kind) { case SyntaxKind.ConstructorType: @@ -111,6 +116,12 @@ module ts { } function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { + // Nodes with computed property names will not get symbols, because the type checker + // does not make properties for them. + if (node.name && node.name.kind === SyntaxKind.ComputedPropertyName) { + return undefined; + } + var name = getDeclarationName(node); if (name !== undefined) { var symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5ee9fa4ab3e..f4a94f854f7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1663,7 +1663,7 @@ module ts { if (declaration.kind === SyntaxKind.Parameter) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === SyntaxKind.SetAccessor) { + if (func.kind === SyntaxKind.SetAccessor && !hasUnknownComputedName(func)) { var getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); @@ -2531,7 +2531,7 @@ module ts { else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === SyntaxKind.GetAccessor) { + if (declaration.kind === SyntaxKind.GetAccessor && !hasUnknownComputedName(declaration)) { var setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); returnType = getAnnotatedAccessorType(setter); } @@ -6648,9 +6648,6 @@ module ts { checkSourceElement(node.type); } if (fullTypeCheck) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { @@ -6711,17 +6708,14 @@ module ts { } function checkPropertyDeclaration(node: PropertyDeclaration) { - // TODO - checkVariableDeclaration(node); + checkVariableOrPropertyCommon(node); } function checkMethodDeclaration(node: MethodDeclaration) { - // TODO - checkFunctionDeclaration(node); + checkFunctionLikeDeclaration(node); } function checkConstructorDeclaration(node: ConstructorDeclaration) { - // TODO checkSignatureDeclaration(node); checkSourceElement(node.body); @@ -6812,29 +6806,32 @@ module ts { } } - // TypeScript 1.0 spec (April 2014): 8.4.3 - // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) { - error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } + if (!hasUnknownComputedName(node)) { + // TypeScript 1.0 spec (April 2014): 8.4.3 + // Accessors for the same member name must specify the same accessibility. + var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; + var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) { + error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } - var thisType = getAnnotatedAccessorType(node); - var otherType = getAnnotatedAccessorType(otherAccessor); - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - if (thisType && otherType) { - if (!isTypeIdenticalTo(thisType, otherType)) { - error(node, Diagnostics.get_and_set_accessor_must_have_the_same_type); + var thisType = getAnnotatedAccessorType(node); + var otherType = getAnnotatedAccessorType(otherAccessor); + // TypeScript 1.0 spec (April 2014): 4.5 + // If both accessors include type annotations, the specified types must be identical. + if (thisType && otherType) { + if (!isTypeIdenticalTo(thisType, otherType)) { + error(node, Diagnostics.get_and_set_accessor_must_have_the_same_type); + } } } + + checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); } } - checkFunctionDeclaration(node); - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + checkFunctionLikeDeclaration(node); } function checkTypeReference(node: TypeReferenceNode) { @@ -7088,7 +7085,7 @@ module ts { } if (duplicateFunctionDeclaration) { - forEach( declarations, declaration => { + forEach(declarations, declaration => { error(declaration.name, Diagnostics.Duplicate_function_implementation); }); } @@ -7204,26 +7201,37 @@ module ts { } } - function checkFunctionDeclaration(node: FunctionLikeDeclaration): void { + function checkFunctionDeclaration(node: FunctionDeclaration): void { + checkFunctionLikeDeclaration(node); + if (fullTypeCheck) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + + function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void { checkSignatureDeclaration(node); - var symbol = getSymbolOfNode(node); - // first we want to check the local symbol that contain this declaration - // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol - // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode - var localSymbol = node.localSymbol || symbol; + if (!hasUnknownComputedName(node)) { + // first we want to check the local symbol that contain this declaration + // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol + // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; - var firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); - // Only type check the symbol once - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); - } + var firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); + // Only type check the symbol once + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } - if (symbol.parent) { - // run check once for the first declaration - if (getDeclarationOfKind(symbol, node.kind) === node) { - // run check on export symbol to check that modifiers agree across all exported declarations - checkFunctionOrConstructorSymbol(symbol); + if (symbol.parent) { + // run check once for the first declaration + if (getDeclarationOfKind(symbol, node.kind) === node) { + // run check on export symbol to check that modifiers agree across all exported declarations + checkFunctionOrConstructorSymbol(symbol); + } } } @@ -7344,9 +7352,8 @@ module ts { } } - // TODO(jfreeman): Decide what to do for computed properties - function needCollisionCheckForIdentifier(node: Node, identifier: DeclarationName, name: string): boolean { - if (!(identifier && (identifier).text === name)) { + function needCollisionCheckForIdentifier(node: Node, identifier: Identifier, name: string): boolean { + if (!(identifier && identifier.text === name)) { return false; } @@ -7371,8 +7378,7 @@ module ts { return true; } - // TODO(jfreeman): Decide what to do for computed properties - function checkCollisionWithCapturedThisVariable(node: Node, name: DeclarationName): void { + function checkCollisionWithCapturedThisVariable(node: Node, name: Identifier): void { if (!needCollisionCheckForIdentifier(node, name, "_this")) { return; } @@ -7397,7 +7403,7 @@ module ts { } } - function checkCollisionWithCapturedSuperVariable(node: Node, name: DeclarationName) { + function checkCollisionWithCapturedSuperVariable(node: Node, name: Identifier) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } @@ -7420,8 +7426,7 @@ module ts { } } - // TODO(jfreeman): Decide what to do for computed properties - function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: DeclarationName) { + function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) { if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -7472,40 +7477,49 @@ module ts { } } - function checkVariableDeclaration(node: VariableDeclaration | PropertyDeclaration) { + function checkVariableOrPropertyCommon(node: VariableDeclaration | PropertyDeclaration) { checkSourceElement(node.type); - checkExportsOnMergedDeclarations(node); if (fullTypeCheck) { var symbol = getSymbolOfNode(node); - - var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); var type: Type; - var useTypeFromValueDeclaration = node === symbol.valueDeclaration; - if (useTypeFromValueDeclaration) { - type = typeOfValueDeclaration; - } - else { + if (hasUnknownComputedName(node) || symbol.valueDeclaration !== node) { type = getTypeOfVariableOrPropertyDeclaration(node); } + else { + type = getTypeOfVariableOrParameterOrProperty(symbol); + } + if (node.initializer && !(getNodeLinks(node.initializer).flags & NodeCheckFlags.TypeChecked)) { + // Use default messages + checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*headMessage*/ undefined); + } + return type; + } + + // All callers who expect a value to be returned are in fullTypeCheck mode. + // If we are not in type check mode, no need to get the type. + return undefined; + } + + function checkVariableDeclaration(node: VariableDeclaration) { + var type = checkVariableOrPropertyCommon(node); + if (fullTypeCheck) { + checkExportsOnMergedDeclarations(node); if (node.initializer) { - if (!(getNodeLinks(node.initializer).flags & NodeCheckFlags.TypeChecked)) { - // Use default messages - checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*headMessage*/ undefined); - } - //TODO(jfreeman): Check that it is not a computed property - checkCollisionWithConstDeclarations(node); + checkCollisionWithConstDeclarations(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - if (!useTypeFromValueDeclaration) { + var symbol = getSymbolOfNode(node); + if (node !== symbol.valueDeclaration) { // TypeScript 1.0 spec (April 2014): 5.1 // Multiple declarations for the same variable name in the same declaration space are permitted, // provided that each declaration associates the same type with the variable. + var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) { error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); } @@ -8365,7 +8379,7 @@ module ts { case SyntaxKind.ParenType: return checkSourceElement((node).type); case SyntaxKind.FunctionDeclaration: - return checkFunctionDeclaration(node); + return checkFunctionDeclaration(node); case SyntaxKind.Block: return checkBlock(node); case SyntaxKind.FunctionBlock: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 76cabe94e2e..5b3d5de82ba 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -71,8 +71,9 @@ module ts { return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier; } - // TODO(jfreeman): Implement declarationNameToString for computed properties // Return display name of an identifier + // Computed property names will just be emitted as "[]", where is the source + // text of the expression in the computed property. export function declarationNameToString(name: DeclarationName) { return name.kind === SyntaxKind.Missing ? "(Missing)" : getTextOfNode(name); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 108e00e48b4..687adb5f119 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -371,11 +371,9 @@ module ts { * Examples: * FunctionDeclaration * MethodDeclaration - * ConstructorDeclaration * AccessorDeclaration - * FunctionExpression */ - export interface FunctionLikeDeclaration extends Declaration, ParsedSignature { + export interface FunctionLikeDeclaration extends SignatureDeclaration { asteriskToken?: Node; body?: Block | Expression; } @@ -389,7 +387,7 @@ module ts { body?: Block; } - export interface ConstructorDeclaration extends FunctionLikeDeclaration { + export interface ConstructorDeclaration extends Node, ParsedSignature { body?: Block; } @@ -458,7 +456,7 @@ module ts { whenFalse: Expression; } - export interface FunctionExpression extends Expression, FunctionLikeDeclaration { + export interface FunctionExpression extends Expression, SignatureDeclaration { name?: Identifier; body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional } diff --git a/tests/baselines/reference/computedPropertyNames1.js b/tests/baselines/reference/computedPropertyNames1.js index d5e3f3e0392..8f3e448d698 100644 --- a/tests/baselines/reference/computedPropertyNames1.js +++ b/tests/baselines/reference/computedPropertyNames1.js @@ -1,7 +1,7 @@ //// [computedPropertyNames1.ts] var v = { get [0 + 1]() { return 0 }, - set [0 + 1](v) { } + set [0 + 1](v: string) { } //No error } //// [computedPropertyNames1.js] @@ -10,5 +10,5 @@ var v = { return 0; }, set [0 + 1](v) { - } + } //No error }; diff --git a/tests/baselines/reference/computedPropertyNames1.types b/tests/baselines/reference/computedPropertyNames1.types new file mode 100644 index 00000000000..b44aa3c69d0 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames1.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts === +var v = { +>v : {} +>{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {} + + get [0 + 1]() { return 0 }, +>0 + 1 : number + + set [0 + 1](v: string) { } //No error +>0 + 1 : number +>v : string +} diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt new file mode 100644 index 00000000000..b3c2957a13f --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(4,5): error TS1168: Computed property names are not allowed in method overloads. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(5,5): error TS1168: Computed property names are not allowed in method overloads. + + +==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (2 errors) ==== + var methodName = "method"; + var accessorName = "accessor"; + class C { + [methodName](v: string); + ~~~~~~~~~~~~ +!!! error TS1168: Computed property names are not allowed in method overloads. + [methodName](); + ~~~~~~~~~~~~ +!!! error TS1168: Computed property names are not allowed in method overloads. + [methodName](v?: string) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index a47865ba3f8..f47aa75031d 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (1 errors) ==== class C { [e](); ~~~ !!! error TS1168: Computed property names are not allowed in method overloads. - ~~~ -!!! error TS2391: Function implementation is missing or not immediately following the declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt index f37cf910a15..124db7da75a 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration. -==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts (1 errors) ==== class C { [e](); ~~~ !!! error TS1168: Computed property names are not allowed in method overloads. - ~~~ -!!! error TS2391: Function implementation is missing or not immediately following the declaration. } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts index b35ab29b129..b260bd8c539 100644 --- a/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts @@ -1,5 +1,5 @@ // @target: es6 var v = { get [0 + 1]() { return 0 }, - set [0 + 1](v) { } + set [0 + 1](v: string) { } //No error } \ No newline at end of file From d43ed2f10ea2167a90850088418f0a46c4c8d4cf Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 25 Nov 2014 12:03:55 -0800 Subject: [PATCH 09/12] Fix merge issues --- src/compiler/parser.ts | 8 ++++++-- .../FunctionDeclaration8_es6.errors.txt | 17 ++++------------- .../FunctionDeclaration9_es6.errors.txt | 16 +++++----------- ...unctionPropertyAssignments5_es6.errors.txt | 17 ++++------------- .../MemberFunctionDeclaration3_es6.errors.txt | 19 +++++-------------- 5 files changed, 24 insertions(+), 53 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5b3d5de82ba..d3c179b5381 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1272,17 +1272,21 @@ module ts { function parseContextualModifier(t: SyntaxKind): boolean { return token === t && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || isLiteralPropertyName(); + return canFollowModifier(); }); } function parseAnyContextualModifier(): boolean { return isModifier(token) && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || isLiteralPropertyName(); + return canFollowModifier(); }); } + function canFollowModifier(): boolean { + return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isLiteralPropertyName(); + } + // True if positioned at the start of a list element function isListElement(kind: ParsingContext, inErrorRecovery: boolean): boolean { switch (kind) { diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt index a30b8d80310..5232c8f1608 100644 --- a/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt @@ -1,16 +1,7 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1136: Property assignment expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,18): error TS1005: ',' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,24): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (4 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (1 errors) ==== var v = { [yield]: foo } - ~ -!!! error TS1136: Property assignment expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~ -!!! error TS2304: Cannot find name 'yield'. \ No newline at end of file + ~~~~~~~ +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt index b4cf83a7b6c..1288a09e47f 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -1,15 +1,9 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1136: Property assignment expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,20): error TS1005: ',' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== function * foo() { var v = { [yield]: foo } - ~ -!!! error TS1136: Property assignment expected. - ~ -!!! error TS1005: ',' expected. - } - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file + ~~~~~~~ +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. + } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index 961dabaa996..430dd503667 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,16 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1003: Identifier expected. -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,22): error TS1005: ',' expected. -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,26): error TS1128: Declaration or statement expected. -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (4 errors) ==== +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ==== var v = { *[foo()]() { } } - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~ -!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file + ~~~~~~~ +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index b3a2de4eec6..d1d3c3c1223 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,18 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,5): error TS1003: Identifier expected. -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,10): error TS1005: ';' expected. -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,13): error TS1005: '=>' expected. -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (4 errors) ==== +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ==== class C { *[foo]() { } - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: '=>' expected. - } - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file + ~~~~~ +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. + } \ No newline at end of file From 480883b227c2cdebd138c56ff2160d8310272f07 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 25 Nov 2014 14:08:21 -0800 Subject: [PATCH 10/12] Skip computed properties in the nav bar --- computed.txt | 12 ----------- src/services/navigationBar.ts | 15 +++++++++----- .../navigationItemsComputedProperties.ts | 20 +++++++++++++++++++ ...iptLexicalStructureItemsModuleVariables.ts | 1 - 4 files changed, 30 insertions(+), 18 deletions(-) delete mode 100644 computed.txt create mode 100644 tests/cases/fourslash/navigationItemsComputedProperties.ts diff --git a/computed.txt b/computed.txt deleted file mode 100644 index a8869ad7d9d..00000000000 --- a/computed.txt +++ /dev/null @@ -1,12 +0,0 @@ -Parse computed expressions and add tests -Disallow computed expressions in class instance properties -Disallow computed expressions in object literal properties, methods, or accessors -Disallow in interfaces - -Emit computed properties for classes and object literals -Discuss down level support for computed properties - -Tests that need to move: -tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature4.ts -tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature5.ts -tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature11.ts \ No newline at end of file diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 6e4303d0cd8..deb779bea2c 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -377,9 +377,10 @@ module ts.NavigationBar { // Add the constructor parameters in as children of the class (for property parameters). // Note that *all* parameters will be added to the nodes array, but parameters that // are not properties will be filtered out later by createChildItem. - var nodes: Node[] = constructor - ? node.members.concat(constructor.parameters) - : node.members; + var nodes: Node[] = removeComputedProperties(node); + if (constructor) { + nodes.push.apply(nodes, constructor.parameters); + } var childItems = getItemsWorker(sortNodes(nodes), createChildItem); } @@ -394,7 +395,7 @@ module ts.NavigationBar { } function createEnumItem(node: EnumDeclaration): ts.NavigationBarItem { - var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); return getNavigationBarItem( node.name.text, ts.ScriptElementKind.enumElement, @@ -405,7 +406,7 @@ module ts.NavigationBar { } function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem { - var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); return getNavigationBarItem( node.name.text, ts.ScriptElementKind.interfaceElement, @@ -416,6 +417,10 @@ module ts.NavigationBar { } } + function removeComputedProperties(node: ClassDeclaration | InterfaceDeclaration | EnumDeclaration): Declaration[] { + return filter(node.members, member => member.name === undefined || member.name.kind !== SyntaxKind.ComputedPropertyName); + } + function getInnermostModule(node: ModuleDeclaration): ModuleDeclaration { while (node.body.kind === SyntaxKind.ModuleDeclaration) { node = node.body; diff --git a/tests/cases/fourslash/navigationItemsComputedProperties.ts b/tests/cases/fourslash/navigationItemsComputedProperties.ts new file mode 100644 index 00000000000..8a88966b2ef --- /dev/null +++ b/tests/cases/fourslash/navigationItemsComputedProperties.ts @@ -0,0 +1,20 @@ +/// + +////{| "itemName": "C", "kind": "class", "parentName": "" |} +////class C { +//// {| "itemName": "foo", "kind": "method", "parentName": "C" |} +//// foo() { } +//// ["hi" + "bye"]() { } +//// {| "itemName": "bar", "kind": "method", "parentName": "C" |} +//// bar() { } +////} + +test.markers().forEach(marker => { + verify.navigationItemsListContains( + marker.data.itemName, + marker.data.kind, + marker.data.itemName, + "exact", + marker.fileName, + marker.data.parentName); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/scriptLexicalStructureItemsModuleVariables.ts b/tests/cases/fourslash/scriptLexicalStructureItemsModuleVariables.ts index 481d67a4e28..85bf609105c 100644 --- a/tests/cases/fourslash/scriptLexicalStructureItemsModuleVariables.ts +++ b/tests/cases/fourslash/scriptLexicalStructureItemsModuleVariables.ts @@ -18,7 +18,6 @@ ////module Module1 { //// export var z = 0; ////} -debugger; goTo.marker("file1"); verify.getScriptLexicalStructureListContains("Module1", "module"); verify.getScriptLexicalStructureListContains("x", "var"); From 1a8816f45994af2874768076f9007c63cc5f27e6 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 26 Nov 2014 20:10:49 -0800 Subject: [PATCH 11/12] Address feedback --- src/compiler/binder.ts | 12 ++- src/compiler/checker.ts | 75 ++++++++++--------- .../diagnosticInformationMap.generated.ts | 4 +- src/compiler/diagnosticMessages.json | 10 ++- src/compiler/parser.ts | 64 ++++++++++++---- src/compiler/types.ts | 2 +- .../FunctionDeclaration9_es6.errors.txt | 6 +- ...unctionPropertyAssignments5_es6.errors.txt | 5 +- .../MemberFunctionDeclaration3_es6.errors.txt | 6 +- tests/baselines/reference/giant.errors.txt | 32 ++++---- ...SignatureMustHaveTypeAnnotation.errors.txt | 4 +- .../indexSignatureWithInitializer.errors.txt | 4 +- .../parserComputedPropertyName13.errors.txt | 4 +- .../parserComputedPropertyName14.errors.txt | 4 +- .../parserComputedPropertyName15.errors.txt | 4 +- .../parserComputedPropertyName18.errors.txt | 4 +- .../parserComputedPropertyName19.errors.txt | 4 +- .../parserComputedPropertyName20.errors.txt | 4 +- .../parserComputedPropertyName21.errors.txt | 4 +- .../parserComputedPropertyName35.errors.txt | 9 +++ .../parserComputedPropertyName36.errors.txt | 9 +++ .../reference/parserComputedPropertyName37.js | 9 +++ .../reference/parserComputedPropertyName38.js | 13 ++++ .../parserComputedPropertyName39.errors.txt | 22 ++++++ .../reference/parserComputedPropertyName40.js | 13 ++++ .../reference/parserComputedPropertyName41.js | 9 +++ .../parserES5ComputedPropertyName5.errors.txt | 4 +- .../parserES5ComputedPropertyName8.errors.txt | 4 +- .../parserIndexSignature11.errors.txt | 4 +- .../parserIndexSignature4.errors.txt | 4 +- .../parserIndexSignature5.errors.txt | 4 +- .../reference/propertyAssignment.errors.txt | 4 +- .../parserComputedPropertyName35.ts | 4 + .../parserComputedPropertyName36.ts | 4 + .../parserComputedPropertyName37.ts | 4 + .../parserComputedPropertyName38.ts | 4 + .../parserComputedPropertyName39.ts | 5 ++ .../parserComputedPropertyName40.ts | 4 + .../parserComputedPropertyName41.ts | 4 + 39 files changed, 282 insertions(+), 107 deletions(-) create mode 100644 tests/baselines/reference/parserComputedPropertyName35.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName36.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName37.js create mode 100644 tests/baselines/reference/parserComputedPropertyName38.js create mode 100644 tests/baselines/reference/parserComputedPropertyName39.errors.txt create mode 100644 tests/baselines/reference/parserComputedPropertyName40.js create mode 100644 tests/baselines/reference/parserComputedPropertyName41.js create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 195782a9e1f..5098b16e4bb 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -53,7 +53,13 @@ module ts { } } - export function hasUnknownComputedName(declaration: Declaration): boolean { + /** + * Returns false if any of the following are true: + * 1. declaration has no name + * 2. declaration has a literal name (not computed) + * 3. declaration has a computed property name that is a known symbol + */ + export function hasComputedNameButNotSymbol(declaration: Declaration): boolean { return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName; } @@ -94,7 +100,7 @@ module ts { if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) { return '"' + (node.name).text + '"'; } - Debug.assert(node.name.kind !== SyntaxKind.ComputedPropertyName); + Debug.assert(!hasComputedNameButNotSymbol(node)); return (node.name).text; } switch (node.kind) { @@ -118,7 +124,7 @@ module ts { function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { // Nodes with computed property names will not get symbols, because the type checker // does not make properties for them. - if (node.name && node.name.kind === SyntaxKind.ComputedPropertyName) { + if (hasComputedNameButNotSymbol(node)) { return undefined; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f4a94f854f7..6afbbcdd510 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1663,7 +1663,7 @@ module ts { if (declaration.kind === SyntaxKind.Parameter) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === SyntaxKind.SetAccessor && !hasUnknownComputedName(func)) { + if (func.kind === SyntaxKind.SetAccessor && !hasComputedNameButNotSymbol(func)) { var getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); @@ -2531,7 +2531,7 @@ module ts { else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === SyntaxKind.GetAccessor && !hasUnknownComputedName(declaration)) { + if (declaration.kind === SyntaxKind.GetAccessor && !hasComputedNameButNotSymbol(declaration)) { var setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); returnType = getAnnotatedAccessorType(setter); } @@ -6106,6 +6106,12 @@ module ts { checkSignatureDeclaration(node); } } + + if (fullTypeCheck) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } + return type; } @@ -6708,7 +6714,9 @@ module ts { } function checkPropertyDeclaration(node: PropertyDeclaration) { - checkVariableOrPropertyCommon(node); + if (fullTypeCheck) { + checkVariableOrPropertyInFullTypeCheck(node); + } } function checkMethodDeclaration(node: MethodDeclaration) { @@ -6806,7 +6814,7 @@ module ts { } } - if (!hasUnknownComputedName(node)) { + if (!hasComputedNameButNotSymbol(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; @@ -6816,12 +6824,12 @@ module ts { error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } - var thisType = getAnnotatedAccessorType(node); - var otherType = getAnnotatedAccessorType(otherAccessor); + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); // TypeScript 1.0 spec (April 2014): 4.5 // If both accessors include type annotations, the specified types must be identical. - if (thisType && otherType) { - if (!isTypeIdenticalTo(thisType, otherType)) { + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { error(node, Diagnostics.get_and_set_accessor_must_have_the_same_type); } } @@ -7213,7 +7221,7 @@ module ts { function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void { checkSignatureDeclaration(node); - if (!hasUnknownComputedName(node)) { + if (!hasComputedNameButNotSymbol(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -7353,7 +7361,7 @@ module ts { } function needCollisionCheckForIdentifier(node: Node, identifier: Identifier, name: string): boolean { - if (!(identifier && identifier.text === name)) { + if (!identifier || identifier.text !== name) { return false; } @@ -7379,10 +7387,9 @@ module ts { } function checkCollisionWithCapturedThisVariable(node: Node, name: Identifier): void { - if (!needCollisionCheckForIdentifier(node, name, "_this")) { - return; + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); } - potentialThisCollisions.push(node); } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes @@ -7477,35 +7484,35 @@ module ts { } } - function checkVariableOrPropertyCommon(node: VariableDeclaration | PropertyDeclaration) { + function checkVariableOrPropertyInFullTypeCheck(node: VariableDeclaration | PropertyDeclaration) { + Debug.assert(fullTypeCheck); checkSourceElement(node.type); - if (fullTypeCheck) { - var symbol = getSymbolOfNode(node); - var type: Type; - if (hasUnknownComputedName(node) || symbol.valueDeclaration !== node) { - type = getTypeOfVariableOrPropertyDeclaration(node); - } - else { - type = getTypeOfVariableOrParameterOrProperty(symbol); - } - - if (node.initializer && !(getNodeLinks(node.initializer).flags & NodeCheckFlags.TypeChecked)) { - // Use default messages - checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*headMessage*/ undefined); - } - - return type; + if (hasComputedNameButNotSymbol(node)) { + // Just check the initializer, since this property won't contribute to the enclosing type + return node.initializer ? checkAndMarkExpression(node.initializer) : anyType; } - // All callers who expect a value to be returned are in fullTypeCheck mode. - // If we are not in type check mode, no need to get the type. - return undefined; + var symbol = getSymbolOfNode(node); + var type: Type; + if (symbol.valueDeclaration !== node) { + type = getTypeOfVariableOrPropertyDeclaration(node); + } + else { + type = getTypeOfVariableOrParameterOrProperty(symbol); + } + + if (node.initializer && !(getNodeLinks(node.initializer).flags & NodeCheckFlags.TypeChecked)) { + // Use default messages + checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*headMessage*/ undefined); + } + + return type; } function checkVariableDeclaration(node: VariableDeclaration) { - var type = checkVariableOrPropertyCommon(node); if (fullTypeCheck) { + var type = checkVariableOrPropertyInFullTypeCheck(node); checkExportsOnMergedDeclarations(node); if (node.initializer) { checkCollisionWithConstDeclarations(node); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 5187fc2512b..4b4909a54f3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -131,7 +131,9 @@ module ts { Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." }, Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." }, - Computed_property_names_are_not_allowed_in_interfaces_or_type_literals: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces or type literals." }, + Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces." }, + Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8b3cd797c63..c05d612b534 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -515,10 +515,18 @@ "category": "Error", "code": 1168 }, - "Computed property names are not allowed in interfaces or type literals.": { + "Computed property names are not allowed in interfaces.": { "category": "Error", "code": 1169 }, + "Computed property names are not allowed in type literals.": { + "category": "Error", + "code": 1170 + }, + "A comma expression is not allowed in a computed property name.": { + "category": "Error", + "code": 1171 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d3c179b5381..a796e163a30 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1262,9 +1262,29 @@ module ts { } function parseComputedPropertyName(): ComputedPropertyName { + // PropertyName[Yield,GeneratorParameter] : + // LiteralPropertyName + // [+GeneratorParameter] ComputedPropertyName + // [~GeneratorParameter] ComputedPropertyName[?Yield] + // + // ComputedPropertyName[Yield] : + // [ AssignmentExpression[In, ?Yield] ] + // var node = createNode(SyntaxKind.ComputedPropertyName); parseExpected(SyntaxKind.OpenBracketToken); - node.expression = allowInAnd(parseAssignmentExpression); + + // We parse any expression (including a comma expression). But the grammar + // says that only an assignment expression is allowed, so the grammar checker + // will error if it sees a comma expression. + var yieldContext = inYieldContext(); + if (inGeneratorParameterContext()) { + setYieldContext(false); + } + node.expression = allowInAnd(parseExpression); + if (inGeneratorParameterContext()) { + setYieldContext(yieldContext); + } + parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); } @@ -1816,23 +1836,28 @@ module ts { // [protected id // [] // - if (nextToken() === SyntaxKind.DotDotDotToken - || token === SyntaxKind.CloseBracketToken - || token === SyntaxKind.PublicKeyword - || token === SyntaxKind.PrivateKeyword - || token === SyntaxKind.ProtectedKeyword) { - + if (nextToken() === SyntaxKind.DotDotDotToken || token === SyntaxKind.CloseBracketToken) { return true; } - if (!isIdentifier()) { + if (isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { return false; } + else { + // Skip the identifier + nextToken(); + } // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (nextToken() === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken) { + if (token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken) { return true; } @@ -4489,8 +4514,11 @@ module ts { return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); } } - else if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral) { - return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces_or_type_literals); + else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { + return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); + } + else if (node.parent.kind === SyntaxKind.TypeLiteral) { + return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); } } @@ -4829,19 +4857,27 @@ module ts { return true; } } - else if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral) { - if (checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces_or_type_literals)) { + else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { + if (checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { + return true; + } + } + else if (node.parent.kind === SyntaxKind.TypeLiteral) { + if (checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { return true; } } - checkForInitializerInAmbientContext(node); + return checkForInitializerInAmbientContext(node); } function checkComputedPropertyName(node: ComputedPropertyName) { if (languageVersion < ScriptTarget.ES6) { return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } + else if (node.expression.kind === SyntaxKind.BinaryExpression && (node.expression).operator === SyntaxKind.CommaToken) { + return grammarErrorOnNode(node.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } } function checkForDisallowedComputedProperty(node: DeclarationName, message: DiagnosticMessage) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 687adb5f119..597d85ccca0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -456,7 +456,7 @@ module ts { whenFalse: Expression; } - export interface FunctionExpression extends Expression, SignatureDeclaration { + export interface FunctionExpression extends Expression, FunctionLikeDeclaration { name?: Identifier; body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional } diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt index 1288a09e47f..7d51bf56ca4 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: 'generators' are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== function * foo() { + ~ +!!! error TS9001: 'generators' are not currently supported. var v = { [yield]: foo } - ~~~~~~~ -!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index 430dd503667..24a12267dc5 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,7 +1,10 @@ +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: 'generators' are not currently supported. tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ==== var v = { *[foo()]() { } } + ~ +!!! error TS9001: 'generators' are not currently supported. ~~~~~~~ !!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index d1d3c3c1223..b61137f1f3d 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: 'generators' are not currently supported. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ==== class C { *[foo]() { } - ~~~~~ -!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. + ~ +!!! error TS9001: 'generators' are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index bd2e2fa6935..f971c067768 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/giant.ts(28,17): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(30,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(34,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(61,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(61,5): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(88,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -13,7 +13,7 @@ tests/cases/compiler/giant.ts(92,21): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(94,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(98,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(100,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(125,9): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(125,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(154,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -23,7 +23,7 @@ tests/cases/compiler/giant.ts(171,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(173,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(177,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(179,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(204,9): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(204,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(233,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -54,7 +54,7 @@ tests/cases/compiler/giant.ts(286,17): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(288,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(292,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(294,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(319,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(319,5): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(346,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -63,7 +63,7 @@ tests/cases/compiler/giant.ts(350,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(352,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(356,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(358,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(383,9): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(383,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(412,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -73,7 +73,7 @@ tests/cases/compiler/giant.ts(429,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(431,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(435,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(437,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/giant.ts(462,9): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(462,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(491,39): error TS1037: A function implementation cannot be declared in an ambient context. @@ -120,7 +120,7 @@ tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(561,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(563,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(587,9): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(587,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(606,22): error TS1037: A function implementation cannot be declared in an ambient context. @@ -137,7 +137,7 @@ tests/cases/compiler/giant.ts(621,29): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(623,24): error TS1111: A constructor implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(626,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(628,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(653,9): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/giant.ts(653,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(672,22): error TS1037: A function implementation cannot be declared in an ambient context. @@ -361,7 +361,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -469,7 +469,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -594,7 +594,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -821,7 +821,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -929,7 +929,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1054,7 +1054,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1323,7 +1323,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. @@ -1425,7 +1425,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all //Index Signature [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index f0bd02524c8..294282d1e9e 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021: An index signature must have a type annotation. @@ -8,7 +8,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021 interface I { [x]: string; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [x: string]; ~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt index cc4e4a9bf4d..6fb708a3b80 100644 --- a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt +++ b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/indexSignatureWithInitializer.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/indexSignatureWithInitializer.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/indexSignatureWithInitializer.ts(6,5): error TS1166: Computed property names are not allowed in class property declarations. @@ -6,7 +6,7 @@ tests/cases/compiler/indexSignatureWithInitializer.ts(6,5): error TS1166: Comput interface I { [x = '']: string; ~~~~~~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. } class C { diff --git a/tests/baselines/reference/parserComputedPropertyName13.errors.txt b/tests/baselines/reference/parserComputedPropertyName13.errors.txt index 38ad6c1c74c..33ef5f9141a 100644 --- a/tests/baselines/reference/parserComputedPropertyName13.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1170: Computed property names are not allowed in type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts (1 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt index fe26de08c9d..d2f7ad34ed9 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: Computed property names are not allowed in type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (1 errors) ==== var v: { [e](): number }; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName15.errors.txt b/tests/baselines/reference/parserComputedPropertyName15.errors.txt index eaa86105727..b09ddb73112 100644 --- a/tests/baselines/reference/parserComputedPropertyName15.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1170: Computed property names are not allowed in type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts (1 errors) ==== var v: { [e: number]: string; [e]: number }; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt index c8241febfe4..72833dda837 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: Computed property names are not allowed in type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (1 errors) ==== var v: { [e]?(): number }; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName19.errors.txt b/tests/baselines/reference/parserComputedPropertyName19.errors.txt index fd17b02724d..22dbfff3c61 100644 --- a/tests/baselines/reference/parserComputedPropertyName19.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1170: Computed property names are not allowed in type literals. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts (1 errors) ==== var v: { [e]? }; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt index 12a82cc6f68..36a7e2d4866 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts (1 errors) ==== interface I { [e](): number ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName21.errors.txt b/tests/baselines/reference/parserComputedPropertyName21.errors.txt index b25b1484a90..5850de24b76 100644 --- a/tests/baselines/reference/parserComputedPropertyName21.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts (1 errors) ==== interface I { [e]: number ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName35.errors.txt b/tests/baselines/reference/parserComputedPropertyName35.errors.txt new file mode 100644 index 00000000000..e603d1c73fd --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName35.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts(2,6): error TS1171: A comma expression is not allowed in a computed property name. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts (1 errors) ==== + var x = { + [0, 1]: { } + ~~~~ +!!! error TS1171: A comma expression is not allowed in a computed property name. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName36.errors.txt b/tests/baselines/reference/parserComputedPropertyName36.errors.txt new file mode 100644 index 00000000000..d10d826d1a9 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName36.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: Computed property names are not allowed in class property declarations. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts (1 errors) ==== + class C { + [public ]: string; + ~~~~~~~~~ +!!! error TS1166: Computed property names are not allowed in class property declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName37.js b/tests/baselines/reference/parserComputedPropertyName37.js new file mode 100644 index 00000000000..eb16d5ade37 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName37.js @@ -0,0 +1,9 @@ +//// [parserComputedPropertyName37.ts] +var v = { + [public]: 0 +}; + +//// [parserComputedPropertyName37.js] +var v = { + [public]: 0 +}; diff --git a/tests/baselines/reference/parserComputedPropertyName38.js b/tests/baselines/reference/parserComputedPropertyName38.js new file mode 100644 index 00000000000..487ff4078fd --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName38.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName38.ts] +class C { + [public]() { } +} + +//// [parserComputedPropertyName38.js] +var C = (function () { + function C() { + } + C.prototype[public] = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName39.errors.txt b/tests/baselines/reference/parserComputedPropertyName39.errors.txt new file mode 100644 index 00000000000..32d59ad2403 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName39.errors.txt @@ -0,0 +1,22 @@ +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 (5 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. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName40.js b/tests/baselines/reference/parserComputedPropertyName40.js new file mode 100644 index 00000000000..5f6381360fc --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName40.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName40.ts] +class C { + [a ? "" : ""]() {} +} + +//// [parserComputedPropertyName40.js] +var C = (function () { + function C() { + } + C.prototype[a ? "" : ""] = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName41.js b/tests/baselines/reference/parserComputedPropertyName41.js new file mode 100644 index 00000000000..b19cc3e7b3f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName41.js @@ -0,0 +1,9 @@ +//// [parserComputedPropertyName41.ts] +var v = { + [0 in []]: true +} + +//// [parserComputedPropertyName41.js] +var v = { + [0 in []]: true +}; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt index 1cc70551961..8eeeef1516f 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts (1 errors) ==== interface I { [e]: number ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt index 6a6964849a1..4595081c145 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1170: Computed property names are not allowed in type literals. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts (1 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature11.errors.txt b/tests/baselines/reference/parserIndexSignature11.errors.txt index dfdd9955daa..c9976e2bc4a 100644 --- a/tests/baselines/reference/parserIndexSignature11.errors.txt +++ b/tests/baselines/reference/parserIndexSignature11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(3,9): error TS1021: An index signature must have a type annotation. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(4,10): error TS1096: An index signature must have exactly one parameter. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1 interface I { [p]; ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. [p1: string]; ~~~~~~~~~~~~~ !!! error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/parserIndexSignature4.errors.txt b/tests/baselines/reference/parserIndexSignature4.errors.txt index b658dfdd69e..0f11eb17f3c 100644 --- a/tests/baselines/reference/parserIndexSignature4.errors.txt +++ b/tests/baselines/reference/parserIndexSignature4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: Computed property names are not allowed in interfaces. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts (1 errors) ==== interface I { [a = 0] ~~~~~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature5.errors.txt b/tests/baselines/reference/parserIndexSignature5.errors.txt index b4d5c5534d0..6400383f9d2 100644 --- a/tests/baselines/reference/parserIndexSignature5.errors.txt +++ b/tests/baselines/reference/parserIndexSignature5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: Computed property names are not allowed in interfaces. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts (1 errors) ==== interface I { [a] ~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1169: Computed property names are not allowed in interfaces. } \ No newline at end of file diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index 37df97d5d42..2ea55a1a2d3 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAssignment.ts(6,13): error TS1169: Computed property names are not allowed in interfaces or type literals. +tests/cases/compiler/propertyAssignment.ts(6,13): error TS1170: Computed property names are not allowed in type literals. tests/cases/compiler/propertyAssignment.ts(14,1): error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: number; }' is not assignable to type '() => void'. @@ -11,7 +11,7 @@ tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: numbe var foo2: { [index]; } // should be an error ~~~~~~~ -!!! error TS1169: Computed property names are not allowed in interfaces or type literals. +!!! error TS1170: Computed property names are not allowed in type literals. var bar2: { x : number; } var foo3: { ():void; } diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts new file mode 100644 index 00000000000..c33e5ef751c --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts @@ -0,0 +1,4 @@ +//@target: ES6 +var x = { + [0, 1]: { } +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts new file mode 100644 index 00000000000..62f5e340453 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [public ]: string; +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts new file mode 100644 index 00000000000..3af8e29c666 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts @@ -0,0 +1,4 @@ +//@target: ES6 +var v = { + [public]: 0 +}; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts new file mode 100644 index 00000000000..21d13e569dd --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [public]() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts new file mode 100644 index 00000000000..af56d4d23fe --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName39.ts @@ -0,0 +1,5 @@ +//@target: ES6 +"use strict"; +class C { + [public]() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts new file mode 100644 index 00000000000..90eb99f0430 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts @@ -0,0 +1,4 @@ +//@target: ES6 +class C { + [a ? "" : ""]() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts new file mode 100644 index 00000000000..7e5a0c9af62 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts @@ -0,0 +1,4 @@ +//@target: ES6 +var v = { + [0 in []]: true +} \ No newline at end of file From ddebd028288b90c392ef5661a8f18af4f716f77e Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 26 Nov 2014 20:15:36 -0800 Subject: [PATCH 12/12] Accept type baselines (will verify when computed properties are typechecked) --- .../reference/parserComputedPropertyName12.types | 7 +++++++ .../reference/parserComputedPropertyName17.types | 7 +++++++ .../reference/parserComputedPropertyName2.types | 6 ++++++ .../reference/parserComputedPropertyName24.types | 8 ++++++++ .../reference/parserComputedPropertyName3.types | 7 +++++++ .../reference/parserComputedPropertyName37.types | 9 +++++++++ .../reference/parserComputedPropertyName38.types | 7 +++++++ .../reference/parserComputedPropertyName4.types | 6 ++++++ .../reference/parserComputedPropertyName40.types | 8 ++++++++ .../reference/parserComputedPropertyName41.types | 9 +++++++++ .../reference/parserComputedPropertyName6.types | 9 +++++++++ 11 files changed, 83 insertions(+) create mode 100644 tests/baselines/reference/parserComputedPropertyName12.types create mode 100644 tests/baselines/reference/parserComputedPropertyName17.types create mode 100644 tests/baselines/reference/parserComputedPropertyName2.types create mode 100644 tests/baselines/reference/parserComputedPropertyName24.types create mode 100644 tests/baselines/reference/parserComputedPropertyName3.types create mode 100644 tests/baselines/reference/parserComputedPropertyName37.types create mode 100644 tests/baselines/reference/parserComputedPropertyName38.types create mode 100644 tests/baselines/reference/parserComputedPropertyName4.types create mode 100644 tests/baselines/reference/parserComputedPropertyName40.types create mode 100644 tests/baselines/reference/parserComputedPropertyName41.types create mode 100644 tests/baselines/reference/parserComputedPropertyName6.types diff --git a/tests/baselines/reference/parserComputedPropertyName12.types b/tests/baselines/reference/parserComputedPropertyName12.types new file mode 100644 index 00000000000..fcc96bc4d51 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName12.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts === +class C { +>C : C + + [e]() { } +>e : unknown +} diff --git a/tests/baselines/reference/parserComputedPropertyName17.types b/tests/baselines/reference/parserComputedPropertyName17.types new file mode 100644 index 00000000000..8ae109dda37 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName17.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts === +var v = { set [e](v) { } } +>v : {} +>{ set [e](v) { } } : {} +>e : unknown +>v : any + diff --git a/tests/baselines/reference/parserComputedPropertyName2.types b/tests/baselines/reference/parserComputedPropertyName2.types new file mode 100644 index 00000000000..8e533282e28 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName2.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts === +var v = { [e]: 1 }; +>v : {} +>{ [e]: 1 } : {} +>e : unknown + diff --git a/tests/baselines/reference/parserComputedPropertyName24.types b/tests/baselines/reference/parserComputedPropertyName24.types new file mode 100644 index 00000000000..d2de5244057 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName24.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts === +class C { +>C : C + + set [e](v) { } +>e : unknown +>v : any +} diff --git a/tests/baselines/reference/parserComputedPropertyName3.types b/tests/baselines/reference/parserComputedPropertyName3.types new file mode 100644 index 00000000000..f673d9fbeb8 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName3.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts === +var v = { [e]() { } }; +>v : {} +>{ [e]() { } } : {} +>e : unknown +>[e]() { } : () => void + diff --git a/tests/baselines/reference/parserComputedPropertyName37.types b/tests/baselines/reference/parserComputedPropertyName37.types new file mode 100644 index 00000000000..ebcd0ca276c --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName37.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts === +var v = { +>v : {} +>{ [public]: 0} : {} + + [public]: 0 +>public : unknown + +}; diff --git a/tests/baselines/reference/parserComputedPropertyName38.types b/tests/baselines/reference/parserComputedPropertyName38.types new file mode 100644 index 00000000000..c77b9fcc67f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName38.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts === +class C { +>C : C + + [public]() { } +>public : unknown +} diff --git a/tests/baselines/reference/parserComputedPropertyName4.types b/tests/baselines/reference/parserComputedPropertyName4.types new file mode 100644 index 00000000000..32a1b44efeb --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName4.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts === +var v = { get [e]() { } }; +>v : {} +>{ get [e]() { } } : {} +>e : unknown + diff --git a/tests/baselines/reference/parserComputedPropertyName40.types b/tests/baselines/reference/parserComputedPropertyName40.types new file mode 100644 index 00000000000..1b0b3ae49f0 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName40.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts === +class C { +>C : C + + [a ? "" : ""]() {} +>a ? "" : "" : string +>a : unknown +} diff --git a/tests/baselines/reference/parserComputedPropertyName41.types b/tests/baselines/reference/parserComputedPropertyName41.types new file mode 100644 index 00000000000..468a44e6b9e --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName41.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts === +var v = { +>v : {} +>{ [0 in []]: true} : {} + + [0 in []]: true +>0 in [] : boolean +>[] : undefined[] +} diff --git a/tests/baselines/reference/parserComputedPropertyName6.types b/tests/baselines/reference/parserComputedPropertyName6.types new file mode 100644 index 00000000000..5fa7e79c32c --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts === +var v = { [e]: 1, [e + e]: 2 }; +>v : {} +>{ [e]: 1, [e + e]: 2 } : {} +>e : unknown +>e + e : any +>e : unknown +>e : unknown +