diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1a1075d9d9e..5098b16e4bb 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -53,6 +53,16 @@ module ts { } } + /** + * 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; + } + export function bindSourceFile(file: SourceFile) { var parent: Node; @@ -84,13 +94,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(!hasComputedNameButNotSymbol(node)); + return (node.name).text; } switch (node.kind) { case SyntaxKind.ConstructorType: @@ -111,6 +122,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 (hasComputedNameButNotSymbol(node)) { + 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..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) { + 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) { + 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; } @@ -6648,9 +6654,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 +6714,16 @@ module ts { } function checkPropertyDeclaration(node: PropertyDeclaration) { - // TODO - checkVariableDeclaration(node); + if (fullTypeCheck) { + checkVariableOrPropertyInFullTypeCheck(node); + } } function checkMethodDeclaration(node: MethodDeclaration) { - // TODO - checkFunctionDeclaration(node); + checkFunctionLikeDeclaration(node); } function checkConstructorDeclaration(node: ConstructorDeclaration) { - // TODO checkSignatureDeclaration(node); checkSourceElement(node.body); @@ -6812,29 +6814,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 (!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; + 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 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 (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + 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 +7093,7 @@ module ts { } if (duplicateFunctionDeclaration) { - forEach( declarations, declaration => { + forEach(declarations, declaration => { error(declaration.name, Diagnostics.Duplicate_function_implementation); }); } @@ -7204,26 +7209,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 (!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 + 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 +7360,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,12 +7386,10 @@ module ts { return true; } - // TODO(jfreeman): Decide what to do for computed properties - function checkCollisionWithCapturedThisVariable(node: Node, name: DeclarationName): void { - if (!needCollisionCheckForIdentifier(node, name, "_this")) { - return; + function checkCollisionWithCapturedThisVariable(node: Node, name: Identifier): void { + 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 @@ -7397,7 +7410,7 @@ module ts { } } - function checkCollisionWithCapturedSuperVariable(node: Node, name: DeclarationName) { + function checkCollisionWithCapturedSuperVariable(node: Node, name: Identifier) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } @@ -7420,8 +7433,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 +7484,49 @@ module ts { } } - function checkVariableDeclaration(node: VariableDeclaration | PropertyDeclaration) { + function checkVariableOrPropertyInFullTypeCheck(node: VariableDeclaration | PropertyDeclaration) { + Debug.assert(fullTypeCheck); checkSourceElement(node.type); - checkExportsOnMergedDeclarations(node); + if (hasComputedNameButNotSymbol(node)) { + // Just check the initializer, since this property won't contribute to the enclosing type + return node.initializer ? checkAndMarkExpression(node.initializer) : anyType; + } + + 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) { if (fullTypeCheck) { - var symbol = getSymbolOfNode(node); - - var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); - var type: Type; - var useTypeFromValueDeclaration = node === symbol.valueDeclaration; - if (useTypeFromValueDeclaration) { - type = typeOfValueDeclaration; - } - else { - type = getTypeOfVariableOrPropertyDeclaration(node); - } - - + var type = checkVariableOrPropertyInFullTypeCheck(node); + 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 +8386,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/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index dbc77bb95b7..4b4909a54f3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -126,6 +126,14 @@ module ts { 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." }, 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_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: { 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 4a5ce8f6f70..c05d612b534 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -495,6 +495,38 @@ "category": "Error", "code": 1163 }, + "Computed property names are not allowed in enums.": { + "category": "Error", + "code": 1164 + }, + "Computed property names are not allowed in an ambient context.": { + "category": "Error", + "code": 1165 + }, + "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.": { + "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/emitter.ts b/src/compiler/emitter.ts index 11ecd3a37b8..2f573e57af7 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); @@ -3456,6 +3480,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 8e5c46eefda..c677f0916c8 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); } @@ -383,6 +384,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); } } @@ -1243,33 +1246,68 @@ 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 { + // PropertyName[Yield,GeneratorParameter] : + // LiteralPropertyName + // [+GeneratorParameter] ComputedPropertyName + // [~GeneratorParameter] ComputedPropertyName[?Yield] + // + // ComputedPropertyName[Yield] : + // [ AssignmentExpression[In, ?Yield] ] + // + var node = createNode(SyntaxKind.ComputedPropertyName); + parseExpected(SyntaxKind.OpenBracketToken); + + // 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); + } + function parseContextualModifier(t: SyntaxKind): boolean { return token === t && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || isPropertyName(); + return canFollowModifier(); }); } function parseAnyContextualModifier(): boolean { return isModifier(token) && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isPropertyName(); + 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) { @@ -1286,9 +1324,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: @@ -1775,6 +1815,65 @@ 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, + // [id?, + // [id?: + // [id?] + // [public id + // [private id + // [protected id + // [] + // + if (nextToken() === SyntaxKind.DotDotDotToken || token === SyntaxKind.CloseBracketToken) { + return true; + } + + 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 (token === 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; + }); + } + function parseIndexSignatureMember(fullStart: number, modifiers: ModifiersArray): SignatureDeclaration { var node = createNode(SyntaxKind.IndexSignature, fullStart); setModifiers(node, modifiers); @@ -1818,10 +1917,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()); } } @@ -1832,7 +1931,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); @@ -3369,12 +3469,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; } @@ -3443,12 +3543,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."); @@ -3939,6 +4042,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); @@ -4226,13 +4330,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; } @@ -4386,10 +4494,33 @@ 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. + 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) { + 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); + } } function checkForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean { @@ -4438,15 +4569,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]; - // TODO(jfreeman): continue if we have a computed property - if (prop.kind === SyntaxKind.OmittedExpression) { + 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 @@ -4456,20 +4584,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)) { @@ -4724,8 +4852,39 @@ 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) { + 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; + } + } + + 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) { + if (node.kind === SyntaxKind.ComputedPropertyName) { + return grammarErrorOnNode(node, message); + } } function checkForInitializerInAmbientContext(node: PropertyDeclaration) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1cfcf8036cd..597d85ccca0 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, @@ -370,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; } @@ -388,7 +387,7 @@ module ts { body?: Block; } - export interface ConstructorDeclaration extends FunctionLikeDeclaration { + export interface ConstructorDeclaration extends Node, ParsedSignature { body?: Block; } @@ -632,7 +631,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 +1256,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'. 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/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/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..7d51bf56ca4 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(1,10): error TS9001: 'generators' are not currently supported. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== function * foo() { + ~ +!!! error TS9001: 'generators' are not currently supported. var v = { [yield]: foo } - ~ -!!! error TS1136: Property assignment expected. - ~ -!!! error TS1005: ',' expected. - } - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file + } \ 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..24a12267dc5 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,16 +1,10 @@ -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,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 (4 errors) ==== +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 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 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 b3a2de4eec6..b61137f1f3d 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,4): error TS9001: 'generators' are not currently supported. -==== 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 TS9001: 'generators' are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames1.js b/tests/baselines/reference/computedPropertyNames1.js new file mode 100644 index 00000000000..8f3e448d698 --- /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: string) { } //No error +} + +//// [computedPropertyNames1.js] +var v = { + get [0 + 1]() { + 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/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/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/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index 767c419952c..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,6): error TS1022: An index signature parameter must have a type annotation. +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,10): error TS1022: An index signature parameter must have a type annotation. +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,10): error TS1022: An index signature parameter must have a type annotation. +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,6): error TS1022: An index signature parameter must have a type annotation. +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,10): error TS1022: An index signature parameter must have a type annotation. +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,10): error TS1022: An index signature parameter must have a type annotation. +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,10): error TS1022: An index signature parameter must have a type annotation. +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,10): error TS1022: An index signature parameter must have a type annotation. +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. @@ -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 TS1169: Computed property names are not allowed in interfaces. [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 TS1169: Computed property names are not allowed in interfaces. [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 TS1169: Computed property names are not allowed in interfaces. [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 TS1169: Computed property names are not allowed in interfaces. [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 TS1169: Computed property names are not allowed in interfaces. [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 TS1169: Computed property names are not allowed in interfaces. [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 TS1169: Computed property names are not allowed in interfaces. [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 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 e7437fcb056..294282d1e9e 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 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,6): error TS1022: An index signature parameter 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. ==== tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts (4 errors) ==== interface I { [x]: string; - ~ -!!! error TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1169: Computed property names are not allowed in interfaces. [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 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 9eeff2c5781..6fb708a3b80 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 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. -==== 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 TS1169: Computed property names are not allowed in interfaces. } 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 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 3e7b9b49223..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,6): error TS1022: An index signature parameter must have a type annotation. +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 TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! error TS1166: Computed property names are not allowed in class property declarations. } \ 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..704c37ebf45 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName10.errors.txt @@ -0,0 +1,9 @@ +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 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 new file mode 100644 index 00000000000..f47aa75031d --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -0,0 +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 (1 errors) ==== + class C { + [e](); + ~~~ +!!! error TS1168: Computed property names are not allowed in method overloads. + } \ No newline at end of file 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/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/parserComputedPropertyName13.errors.txt b/tests/baselines/reference/parserComputedPropertyName13.errors.txt new file mode 100644 index 00000000000..33ef5f9141a --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -0,0 +1,7 @@ +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 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 new file mode 100644 index 00000000000..d2f7ad34ed9 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -0,0 +1,7 @@ +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 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 new file mode 100644 index 00000000000..b09ddb73112 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -0,0 +1,7 @@ +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 TS1170: Computed property names are not allowed in 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..23361b4ce7e --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName16.errors.txt @@ -0,0 +1,9 @@ +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 TS1164: Computed property names are not allowed in enums. + } \ No newline at end of file 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/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/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt new file mode 100644 index 00000000000..72833dda837 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -0,0 +1,7 @@ +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 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 new file mode 100644 index 00000000000..22dbfff3c61 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -0,0 +1,7 @@ +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 TS1170: Computed property names are not allowed in type literals. \ No newline at end of file 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/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/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt new file mode 100644 index 00000000000..36a7e2d4866 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -0,0 +1,9 @@ +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. + } \ 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..5850de24b76 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -0,0 +1,9 @@ +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. + } \ 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..5149c937108 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName22.errors.txt @@ -0,0 +1,9 @@ +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 TS1166: 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/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/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/parserComputedPropertyName25.errors.txt b/tests/baselines/reference/parserComputedPropertyName25.errors.txt new file mode 100644 index 00000000000..c8dd6b3bc7c --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName25.errors.txt @@ -0,0 +1,14 @@ +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'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts (2 errors) ==== + class C { + // No ASI + [e] = 0 + ~~~ +!!! error TS1166: 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..9b1cf1d53f4 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName26.errors.txt @@ -0,0 +1,14 @@ +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'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts (2 errors) ==== + enum E { + // No ASI + [e] = 0 + ~~~ +!!! error TS1164: 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..bc32f34c151 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName28.errors.txt @@ -0,0 +1,13 @@ +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 TS1166: Computed property names are not allowed in class property declarations. + [e2]: number + ~~~~ +!!! 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 new file mode 100644 index 00000000000..13a15bf5f9d --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -0,0 +1,17 @@ +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'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts (3 errors) ==== + class C { + // yes ASI + [e] = id++ + ~~~ +!!! error TS1166: Computed property names are not allowed in class property declarations. + ~~ +!!! error TS2304: Cannot find name 'id'. + [e2]: number + ~~~~ +!!! error TS1166: Computed property names are not allowed in class property declarations. + } \ No newline at end of file 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/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/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..6dddbd859c9 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName31.errors.txt @@ -0,0 +1,14 @@ +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) ==== + class C { + // yes ASI + [e]: number + ~~~ +!!! error TS1166: Computed property names are not allowed in class property declarations. + [e2]: number + ~~~~ +!!! 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 new file mode 100644 index 00000000000..4407014cf99 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -0,0 +1,9 @@ +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 TS1165: 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..05d7375f132 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName34.errors.txt @@ -0,0 +1,17 @@ +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'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts (3 errors) ==== + enum E { + // no ASI, comma expected + [e] = id++, + ~~~ +!!! error TS1164: Computed property names are not allowed in enums. + ~~ +!!! error TS2304: Cannot find name 'id'. + [e2] = 1 + ~~~~ +!!! error TS1164: Computed property names are not allowed in enums. + } \ 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/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.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/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/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/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/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.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/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.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/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/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/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/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 + diff --git a/tests/baselines/reference/parserComputedPropertyName7.errors.txt b/tests/baselines/reference/parserComputedPropertyName7.errors.txt new file mode 100644 index 00000000000..21147be3074 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName7.errors.txt @@ -0,0 +1,9 @@ +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 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 new file mode 100644 index 00000000000..75352ec9e51 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName8.errors.txt @@ -0,0 +1,9 @@ +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 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 new file mode 100644 index 00000000000..eb5cfd28d73 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName9.errors.txt @@ -0,0 +1,12 @@ +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'. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts (2 errors) ==== + class C { + [e]: Type + ~~~ +!!! 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 new file mode 100644 index 00000000000..5bae79b95aa --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt @@ -0,0 +1,9 @@ +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 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 new file mode 100644 index 00000000000..40bec1b4f38 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt @@ -0,0 +1,9 @@ +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 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 new file mode 100644 index 00000000000..124db7da75a --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -0,0 +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 (1 errors) ==== + class C { + [e](); + ~~~ +!!! error TS1168: Computed property names are not allowed in method overloads. + } \ 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..dc7d7e7ba30 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt @@ -0,0 +1,7 @@ +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 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 new file mode 100644 index 00000000000..376c1a29ae4 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt @@ -0,0 +1,7 @@ +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 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 new file mode 100644 index 00000000000..e0b816f157c --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt @@ -0,0 +1,7 @@ +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 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 new file mode 100644 index 00000000000..8eeeef1516f --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -0,0 +1,9 @@ +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. + } \ 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..7f43220fc0d --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName6.errors.txt @@ -0,0 +1,9 @@ +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 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 new file mode 100644 index 00000000000..6aefd27ef58 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt @@ -0,0 +1,9 @@ +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 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 new file mode 100644 index 00000000000..4595081c145 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -0,0 +1,7 @@ +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 TS1170: Computed property names are not allowed in 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..6d035a7c610 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt @@ -0,0 +1,12 @@ +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'. + + +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts (2 errors) ==== + class C { + [e]: Type + ~~~ +!!! 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 585e72a3516..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,10): error TS1022: An index signature parameter must have a type annotation. +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. @@ -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 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 cf4bbad234b..0f11eb17f3c 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 TS1169: Computed property names are not allowed in interfaces. -==== 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 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 5c33bb583b6..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,4): error TS1022: An index signature parameter must have a type annotation. +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 TS1022: An index signature parameter must have a type annotation. + ~~~ +!!! 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 20894f159e0..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,14): error TS1022: An index signature parameter must have a type annotation. +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'. @@ -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 TS1170: Computed property names are not allowed in type literals. var bar2: { x : number; } var foo3: { ():void; } diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts new file mode 100644 index 00000000000..b260bd8c539 --- /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: string) { } //No error +} \ 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 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/es6/computedPropertyNames/ComputedPropertyName10_es6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts similarity index 55% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts index 64f8b999003..777c44e0185 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts @@ -1,3 +1,4 @@ +//@target: ES5 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/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts similarity index 53% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts index cfb1c736b40..b5e27ecc71b 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts @@ -1,3 +1,4 @@ +//@target: ES5 class C { [e](); } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts similarity index 54% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts index 34c9d6d918a..2f37b0f2cad 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts @@ -1 +1,2 @@ +//@target: ES5 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/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts similarity index 57% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts index 08ad781e2ba..5091ee0b98c 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts @@ -1 +1,2 @@ +//@target: ES5 var v = { [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts similarity index 61% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts index d5a331ebb4c..67b97a6a0bb 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts @@ -1 +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/es6/computedPropertyNames/ComputedPropertyName16_es6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts similarity index 52% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts index a088319bf94..622bd43e465 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts @@ -1,3 +1,4 @@ +//@target: ES5 enum E { [e] = 1 } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts similarity index 50% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts index b23944da796..280dc1a5a0d 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts @@ -1,3 +1,4 @@ +//@target: ES5 class C { [e] } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts similarity index 58% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts index 2783955e804..48abbd6fe95 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts @@ -1 +1,2 @@ +//@target: ES5 var v: { [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts similarity index 57% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts rename to tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts index 18e290722aa..de00d6f8245 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts +++ b/tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts @@ -1,3 +1,4 @@ +//@target: ES5 class C { [e]: Type } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts similarity index 50% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts index 0703648cf0b..e6fbccb8e1f 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts @@ -1 +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/es6/computedPropertyNames/ComputedPropertyName12_es6.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts similarity index 57% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts index 7e030263fcc..b9b870a9ec9 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts @@ -1,3 +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/es6/computedPropertyNames/ComputedPropertyName14_es6.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts similarity index 60% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts index 534b418854b..3d9fb800d70 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts @@ -1 +1,2 @@ +//@target: ES6 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/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts similarity index 73% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts index 7b9965e8177..ba0a7b84b90 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts @@ -1 +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/es6/computedPropertyNames/ComputedPropertyName17_es6.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts similarity index 61% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts index 2d002e9ca43..6e6485ea85f 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts @@ -1 +1,2 @@ +//@target: ES6 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/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts similarity index 61% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts index 0659070d643..dd05fcac482 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts @@ -1 +1,2 @@ +//@target: ES6 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/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts similarity index 50% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts index b6c1756d097..f190dadb92c 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts @@ -1 +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/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/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/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 diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts similarity index 67% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts index a254f65ee67..869f340929b 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts @@ -1 +1,2 @@ +//@target: ES6 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/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts similarity index 65% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts index c09627a0d46..aaf4131d158 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts @@ -1 +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/es6/computedPropertyNames/ComputedPropertyName8_es6.ts b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts similarity index 58% rename from tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts rename to tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts index 18f1fd61276..6e55c04b7a1 100644 --- a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts +++ b/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts @@ -1,3 +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 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");