diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3ad62c1d63..9a3aa0d2fc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10416,22 +10416,18 @@ module ts { return false; } - function checkGrammarComputedPropertyName(node: Node): void { + function checkGrammarComputedPropertyName(node: Node): boolean { // If node is not a computedPropertyName, just skip the grammar checking if (node.kind !== SyntaxKind.ComputedPropertyName) { - return; + return false; } - // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 - // Once full support is added, remove this error. - grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported); - return; var computedPropertyName = node; if (compilerOptions.target < ScriptTarget.ES6) { - grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); + return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } else if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (computedPropertyName.expression).operator === SyntaxKind.CommaToken) { - grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + return grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9d62ee0e03..03df069a9a 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -445,6 +445,5 @@ module ts { You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true }, Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported.", isEarly: true }, - Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported.", isEarly: true }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ee962edc3a..6be3bb65c7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1880,10 +1880,5 @@ "category": "Error", "code": 9001, "isEarly": true - }, - "Computed property names are not currently supported.": { - "category": "Error", - "code": 9002, - "isEarly": true } } diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt index 08d151203c..5232c8f160 100644 --- a/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS9002: Computed property names are not currently supported. +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 (1 errors) ==== var v = { [yield]: foo } ~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. \ 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 8333eceb26..902a195e8f 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -1,5 +1,5 @@ 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(2,13): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,1 !!! error TS9001: Generators are not currently supported. var v = { [yield]: foo } ~~~~~~~ -!!! error TS9002: Computed property names 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/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index eff0c79d82..430dd50366 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ==== var v = { *[foo()]() { } } ~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. \ 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/computedPropertyNames1.errors.txt b/tests/baselines/reference/computedPropertyNames1.errors.txt deleted file mode 100644 index 02abbcd6b2..0000000000 --- a/tests/baselines/reference/computedPropertyNames1.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(2,9): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(3,9): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts (2 errors) ==== - var v = { - get [0 + 1]() { return 0 }, - ~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - set [0 + 1](v: string) { } //No error - ~~~~~~~ -!!! error TS9002: Computed property names 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 0000000000..8f3e448d69 --- /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/computedPropertyNames2.errors.txt b/tests/baselines/reference/computedPropertyNames2.errors.txt index 3dd4ac01d5..d0fd1de457 100644 --- a/tests/baselines/reference/computedPropertyNames2.errors.txt +++ b/tests/baselines/reference/computedPropertyNames2.errors.txt @@ -1,37 +1,19 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(4,5): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(5,12): error TS9002: Computed property names are not currently supported. 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(6,9): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(7,9): error TS9002: Computed property names are not currently supported. 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(8,16): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(9,16): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (8 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (2 errors) ==== var methodName = "method"; var accessorName = "accessor"; class C { [methodName]() { } - ~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. static [methodName]() { } - ~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. get [accessorName]() { } ~~~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. - ~~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. set [accessorName](v) { } - ~~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. static get [accessorName]() { } ~~~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. - ~~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. static set [accessorName](v) { } - ~~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. } \ 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 0000000000..78d53ef94f --- /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 index 084a1f8889..37a4ddaf1c 100644 --- a/tests/baselines/reference/computedPropertyNames3.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3.errors.txt @@ -1,36 +1,18 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(3,5): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS9002: Computed property names are not currently supported. 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(5,9): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS9002: Computed property names are not currently supported. 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(7,16): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(8,16): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (8 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (2 errors) ==== var id; class C { [0 + 1]() { } - ~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. static [() => { }]() { } - ~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. get [delete id]() { } ~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. - ~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. set [[0, 1]](v) { } - ~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. static get [""]() { } ~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. - ~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. static set [id.toString()](v) { } - ~~~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. } \ 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 0000000000..fbd76bf48f --- /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 index 6329ab39f0..b3c2957a13 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt @@ -1,9 +1,8 @@ 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(6,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (3 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (2 errors) ==== var methodName = "method"; var accessorName = "accessor"; class C { @@ -14,6 +13,4 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads. ~~~~~~~~~~~~ !!! error TS1168: Computed property names are not allowed in method overloads. [methodName](v?: string) { } - ~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName12.errors.txt b/tests/baselines/reference/parserComputedPropertyName12.errors.txt deleted file mode 100644 index c028275369..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName12.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts(2,4): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts (1 errors) ==== - class C { - [e]() { } - ~~~ -!!! error TS9002: Computed property names are not currently supported. - } \ 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 0000000000..96e62b626e --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName12.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName12.ts] +class C { + [e]() { } +} + +//// [parserComputedPropertyName12.js] +var C = (function () { + function C() { + } + C.prototype[e] = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName17.errors.txt b/tests/baselines/reference/parserComputedPropertyName17.errors.txt deleted file mode 100644 index f8b1a4866e..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName17.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts(1,15): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts (1 errors) ==== - var v = { set [e](v) { } } - ~~~ -!!! error TS9002: Computed property names are not currently supported. \ 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 0000000000..98d61ab8bc --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName17.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName17.ts] +var v = { set [e](v) { } } + +//// [parserComputedPropertyName17.js] +var v = { set [e](v) { +} }; diff --git a/tests/baselines/reference/parserComputedPropertyName2.errors.txt b/tests/baselines/reference/parserComputedPropertyName2.errors.txt deleted file mode 100644 index 9eb6cdd600..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName2.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts(1,11): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts (1 errors) ==== - var v = { [e]: 1 }; - ~~~ -!!! error TS9002: Computed property names are not currently supported. \ 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 0000000000..f3c41f963f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName2.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName2.ts] +var v = { [e]: 1 }; + +//// [parserComputedPropertyName2.js] +var v = { [e]: 1 }; diff --git a/tests/baselines/reference/parserComputedPropertyName24.errors.txt b/tests/baselines/reference/parserComputedPropertyName24.errors.txt deleted file mode 100644 index fa7280a93e..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName24.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts(2,9): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts (1 errors) ==== - class C { - set [e](v) { } - ~~~ -!!! error TS9002: Computed property names are not currently supported. - } \ 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 0000000000..0b9467fb26 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName24.js @@ -0,0 +1,17 @@ +//// [parserComputedPropertyName24.ts] +class C { + set [e](v) { } +} + +//// [parserComputedPropertyName24.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, e, { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName3.errors.txt b/tests/baselines/reference/parserComputedPropertyName3.errors.txt deleted file mode 100644 index b13f453cb8..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName3.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts(1,11): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts (1 errors) ==== - var v = { [e]() { } }; - ~~~ -!!! error TS9002: Computed property names are not currently supported. \ 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 0000000000..2e73fe87d3 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName3.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName3.ts] +var v = { [e]() { } }; + +//// [parserComputedPropertyName3.js] +var v = { [e]() { +} }; diff --git a/tests/baselines/reference/parserComputedPropertyName35.errors.txt b/tests/baselines/reference/parserComputedPropertyName35.errors.txt index d68f0eb1ec..e603d1c73f 100644 --- a/tests/baselines/reference/parserComputedPropertyName35.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName35.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts(2,5): error TS9002: Computed property names are not currently supported. +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 TS9002: Computed property names are not currently supported. + ~~~~ +!!! 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/parserComputedPropertyName35.js b/tests/baselines/reference/parserComputedPropertyName35.js new file mode 100644 index 0000000000..15992d54ec --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName35.js @@ -0,0 +1,9 @@ +//// [parserComputedPropertyName35.ts] +var x = { + [0, 1]: { } +} + +//// [parserComputedPropertyName35.js] +var x = { + [0, 1]: {} +}; diff --git a/tests/baselines/reference/parserComputedPropertyName37.errors.txt b/tests/baselines/reference/parserComputedPropertyName37.errors.txt deleted file mode 100644 index fa1acd5dbe..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName37.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts(2,5): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts (1 errors) ==== - var v = { - [public]: 0 - ~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - }; \ 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 0000000000..eb16d5ade3 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName37.js @@ -0,0 +1,9 @@ +//// [parserComputedPropertyName37.ts] +var v = { + [public]: 0 +}; + +//// [parserComputedPropertyName37.js] +var v = { + [public]: 0 +}; diff --git a/tests/baselines/reference/parserComputedPropertyName38.errors.txt b/tests/baselines/reference/parserComputedPropertyName38.errors.txt deleted file mode 100644 index 910a907ee0..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName38.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,5): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (1 errors) ==== - class C { - [public]() { } - ~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName38.js b/tests/baselines/reference/parserComputedPropertyName38.js new file mode 100644 index 0000000000..487ff4078f --- /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/parserComputedPropertyName4.errors.txt b/tests/baselines/reference/parserComputedPropertyName4.errors.txt deleted file mode 100644 index c1137b1587..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName4.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,15): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts (1 errors) ==== - var v = { get [e]() { } }; - ~~~ -!!! error TS9002: Computed property names are not currently supported. \ 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 0000000000..a88545566e --- /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/parserComputedPropertyName40.errors.txt b/tests/baselines/reference/parserComputedPropertyName40.errors.txt deleted file mode 100644 index 93be0ad51b..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName40.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts(2,5): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts (1 errors) ==== - class C { - [a ? "" : ""]() {} - ~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName40.js b/tests/baselines/reference/parserComputedPropertyName40.js new file mode 100644 index 0000000000..5f6381360f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName40.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName40.ts] +class C { + [a ? "" : ""]() {} +} + +//// [parserComputedPropertyName40.js] +var C = (function () { + function C() { + } + C.prototype[a ? "" : ""] = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName41.errors.txt b/tests/baselines/reference/parserComputedPropertyName41.errors.txt deleted file mode 100644 index eb5e9a9ebb..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName41.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts(2,5): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts (1 errors) ==== - var v = { - [0 in []]: true - ~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName41.js b/tests/baselines/reference/parserComputedPropertyName41.js new file mode 100644 index 0000000000..b19cc3e7b3 --- /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/parserComputedPropertyName5.errors.txt b/tests/baselines/reference/parserComputedPropertyName5.errors.txt deleted file mode 100644 index f0dd056fdf..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName5.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,22): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts (1 errors) ==== - var v = { public get [e]() { } }; - ~~~ -!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName5.js b/tests/baselines/reference/parserComputedPropertyName5.js new file mode 100644 index 0000000000..aa86d54d09 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName5.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName5.ts] +var v = { public get [e]() { } }; + +//// [parserComputedPropertyName5.js] +var v = { get [e]() { +} }; diff --git a/tests/baselines/reference/parserComputedPropertyName6.errors.txt b/tests/baselines/reference/parserComputedPropertyName6.errors.txt deleted file mode 100644 index 893bf3da71..0000000000 --- a/tests/baselines/reference/parserComputedPropertyName6.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts(1,11): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts(1,19): error TS9002: Computed property names are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts (2 errors) ==== - var v = { [e]: 1, [e + e]: 2 }; - ~~~ -!!! error TS9002: Computed property names are not currently supported. - ~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. \ 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 0000000000..b60ad66a9d --- /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/parserES5ComputedPropertyName2.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt index 7b6b74b8fd..dc7d7e7ba3 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,11): error TS9002: Computed property names are not currently supported. +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 TS9002: Computed property names are not currently supported. \ No newline at end of file +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt index 669fd19026..376c1a29ae 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,11): error TS9002: Computed property names are not currently supported. +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 TS9002: Computed property names are not currently supported. \ No newline at end of file +!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt index af0c6e858a..e0b816f157 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS9002: Computed property names are not currently supported. +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 TS9002: Computed property names are not currently supported. \ 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