From 18276e526754b14d1f0f30ef794f19a64d193767 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 10 Feb 2015 16:13:28 -0800 Subject: [PATCH] Address feedback from @yuit --- src/compiler/checker.ts | 64 +++++++++++-------- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/utilities.ts | 5 ++ .../reference/symbolProperty59.errors.txt | 9 +++ tests/baselines/reference/symbolProperty59.js | 6 ++ .../reference/symbolType12.errors.txt | 12 ++-- .../reference/symbolType3.errors.txt | 16 ++--- .../reference/symbolType6.errors.txt | 24 +++---- .../reference/symbolType8.errors.txt | 40 ++++++------ .../es6/Symbols/symbolProperty59.ts | 4 ++ 11 files changed, 110 insertions(+), 74 deletions(-) create mode 100644 tests/baselines/reference/symbolProperty59.errors.txt create mode 100644 tests/baselines/reference/symbolProperty59.js create mode 100644 tests/cases/conformance/es6/Symbols/symbolProperty59.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 349edf4b609..ad417c4c8d8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2502,9 +2502,9 @@ module ts { return getPropertiesOfObjectType(getApparentType(type)); } - // For a type parameter, return the base constraint of the type parameter. For the string, number, and - // boolean primitive types, return the corresponding object types.Otherwise return the type itself. - // Note that the apparent type of a union type is the union type itself. + // For a type parameter, return the base constraint of the type parameter. For the string, number, + // boolean, and symbol primitive types, return the corresponding object types.Otherwise return the + // type itself. Note that the apparent type of a union type is the union type itself. function getApparentType(type: Type): Type { if (type.flags & TypeFlags.TypeParameter) { do { @@ -5543,8 +5543,8 @@ module ts { if (!isTypeOfKind(links.resolvedType, TypeFlags.Any | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol)) { error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else if (isWellKnownSymbolSyntactically(node.expression)) { - checkSymbolNameIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); + else { + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); } } @@ -5848,11 +5848,9 @@ module ts { if (indexArgumentExpression.kind === SyntaxKind.StringLiteral || indexArgumentExpression.kind === SyntaxKind.NumericLiteral) { return (indexArgumentExpression).text; } - if (isWellKnownSymbolSyntactically(indexArgumentExpression)) { - if (checkSymbolNameIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { - var rightHandSideName = ((indexArgumentExpression).name).text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { + var rightHandSideName = ((indexArgumentExpression).name).text; + return getPropertyNameForKnownSymbolName(rightHandSideName); } return undefined; @@ -5860,34 +5858,33 @@ module ts { /** * A proper symbol reference requires the following: - * 1. The expression is of the form Symbol. - * 2. Symbol in this context resolves to the global Symbol object - * 3. The property access denotes a property that is present on the global Symbol object - * 4. The property on the global Symbol object is of the primitive type symbol. + * 1. The property access denotes a property that exists + * 2. The expression is of the form Symbol. + * 3. The property access is of the primitive type symbol. + * 4. Symbol in this context resolves to the global Symbol object */ - function checkSymbolNameIsProperSymbolReference(wellKnownSymbolName: PropertyAccessExpression, propertyNameType: Type, reportError: boolean): boolean { - if (propertyNameType === unknownType) { + function checkThatExpressionIsProperSymbolReference(expression: Expression, expressionType: Type, reportError: boolean): boolean { + if (expressionType === unknownType) { // There is already an error, so no need to report one. return false; } - Debug.assert(isWellKnownSymbolSyntactically(wellKnownSymbolName)); + if (!isWellKnownSymbolSyntactically(expression)) { + return false; + } // Make sure the property type is the primitive symbol type - if ((propertyNameType.flags & TypeFlags.ESSymbol) === 0) { + if ((expressionType.flags & TypeFlags.ESSymbol) === 0) { if (reportError) { - error(wellKnownSymbolName, Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, getTextOfNode(wellKnownSymbolName)); + error(expression, Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, getTextOfNode(expression)); } return false; } // The name is Symbol., so make sure Symbol actually resolves to the // global Symbol object - var leftHandSide = (wellKnownSymbolName).expression; - // Look up the global symbol, but don't report an error, since checking the actual expression - // would have reported an error. - var leftHandSideSymbol = resolveName(wellKnownSymbolName, (leftHandSide).text, - SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var leftHandSide = (expression).expression; + var leftHandSideSymbol = getResolvedSymbol(leftHandSide); if (!leftHandSideSymbol) { return false; } @@ -6936,7 +6933,7 @@ module ts { case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: if (hasSomeTypeOfKind(operandType, TypeFlags.ESSymbol)) { - error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_a_value_of_type_symbol, tokenToString(node.operator)); + error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator)); } return numberType; case SyntaxKind.ExclamationToken: @@ -7270,7 +7267,7 @@ module ts { hasSomeTypeOfKind(rightType, TypeFlags.ESSymbol) ? node.right : undefined; if (offendingSymbolOperand) { - error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_a_value_of_type_symbol, tokenToString(operator)); + error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); return false; } @@ -7362,6 +7359,9 @@ module ts { } function checkPropertyAssignment(node: PropertyAssignment, contextualMapper?: TypeMapper): Type { + // Do not use hasDynamicName here, because that returns false for well known symbols. + // We want to perform checkComputedPropertyName for all computed properties, including + // well known symbols. if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkComputedPropertyName(node.name); } @@ -7373,6 +7373,9 @@ module ts { // Grammar checking checkGrammarMethod(node); + // Do not use hasDynamicName here, because that returns false for well known symbols. + // We want to perform checkComputedPropertyName for all computed properties, including + // well known symbols. if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkComputedPropertyName(node.name); } @@ -8185,6 +8188,9 @@ module ts { function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void { checkSignatureDeclaration(node); + // Do not use hasDynamicName here, because that returns false for well known symbols. + // We want to perform checkComputedPropertyName for all computed properties, including + // well known symbols. if (node.name.kind === SyntaxKind.ComputedPropertyName) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals @@ -8420,6 +8426,9 @@ module ts { function checkVariableLikeDeclaration(node: VariableLikeDeclaration) { checkSourceElement(node.type); // For a computed property, just check the initializer and exit + // Do not use hasDynamicName here, because that returns false for well known symbols. + // We want to perform checkComputedPropertyName for all computed properties, including + // well known symbols. if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkComputedPropertyName(node.name); if (node.initializer) { @@ -11159,6 +11168,9 @@ module ts { var inAmbientContext = isInAmbientContext(enumDecl); for (var i = 0, n = enumDecl.members.length; i < n; i++) { var node = enumDecl.members[i]; + // Do not use hasDynamicName here, because that returns false for well known symbols. + // We want to perform checkComputedPropertyName for all computed properties, including + // well known symbols. if (node.name.kind === SyntaxKind.ComputedPropertyName) { hasError = grammarErrorOnNode(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9745f251e66..7d5681c706a 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -304,7 +304,7 @@ module ts { super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, Cannot_find_global_value_0: { code: 2468, category: DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_a_value_of_type_symbol: { code: 2469, category: DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to a value of type 'symbol'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fd09a49d3fb..e3c3be59a01 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1208,7 +1208,7 @@ "category": "Error", "code": 2468 }, - "The '{0}' operator cannot be applied to a value of type 'symbol'.": { + "The '{0}' operator cannot be applied to type 'symbol'.": { "category": "Error", "code": 2469 }, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 16d2303a16e..0656bed7d5f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -848,6 +848,11 @@ module ts { !isWellKnownSymbolSyntactically((declaration.name).expression); } + /** + * Checks if the expression is of the form: + * Symbol.name + * where Symbol is literally the word "Symbol", and name is any identifierName + */ export function isWellKnownSymbolSyntactically(node: Expression): boolean { return node.kind === SyntaxKind.PropertyAccessExpression && isESSymbolIdentifier((node).expression); } diff --git a/tests/baselines/reference/symbolProperty59.errors.txt b/tests/baselines/reference/symbolProperty59.errors.txt new file mode 100644 index 00000000000..dfb2ece3d21 --- /dev/null +++ b/tests/baselines/reference/symbolProperty59.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/Symbols/symbolProperty59.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. + + +==== tests/cases/conformance/es6/Symbols/symbolProperty59.ts (1 errors) ==== + interface I { + [Symbol.keyFor]: string; + ~~~~~~~~~~~~~~~ +!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. + } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty59.js b/tests/baselines/reference/symbolProperty59.js new file mode 100644 index 00000000000..78d1d212f28 --- /dev/null +++ b/tests/baselines/reference/symbolProperty59.js @@ -0,0 +1,6 @@ +//// [symbolProperty59.ts] +interface I { + [Symbol.keyFor]: string; +} + +//// [symbolProperty59.js] diff --git a/tests/baselines/reference/symbolType12.errors.txt b/tests/baselines/reference/symbolType12.errors.txt index 85db01ff5d2..adceb58ae56 100644 --- a/tests/baselines/reference/symbolType12.errors.txt +++ b/tests/baselines/reference/symbolType12.errors.txt @@ -9,8 +9,8 @@ tests/cases/conformance/es6/Symbols/symbolType12.ts(7,6): error TS2363: The righ tests/cases/conformance/es6/Symbols/symbolType12.ts(8,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType12.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'symbol' and 'symbol'. tests/cases/conformance/es6/Symbols/symbolType12.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'symbol' and 'number'. -tests/cases/conformance/es6/Symbols/symbolType12.ts(11,1): error TS2469: The '+=' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType12.ts(12,8): error TS2469: The '+=' operator cannot be applied to a value of type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType12.ts(11,1): error TS2469: The '+=' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType12.ts(12,8): error TS2469: The '+=' operator cannot be applied to type 'symbol'. tests/cases/conformance/es6/Symbols/symbolType12.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType12.ts(13,6): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType12.ts(14,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -32,7 +32,7 @@ tests/cases/conformance/es6/Symbols/symbolType12.ts(24,1): error TS2362: The lef tests/cases/conformance/es6/Symbols/symbolType12.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType12.ts(25,6): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType12.ts(26,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es6/Symbols/symbolType12.ts(28,8): error TS2469: The '+=' operator cannot be applied to a value of type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType12.ts(28,8): error TS2469: The '+=' operator cannot be applied to type 'symbol'. ==== tests/cases/conformance/es6/Symbols/symbolType12.ts (35 errors) ==== @@ -70,10 +70,10 @@ tests/cases/conformance/es6/Symbols/symbolType12.ts(28,8): error TS2469: The '+= !!! error TS2365: Operator '+=' cannot be applied to types 'symbol' and 'number'. s += ""; ~ -!!! error TS2469: The '+=' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+=' operator cannot be applied to type 'symbol'. str += s; ~ -!!! error TS2469: The '+=' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+=' operator cannot be applied to type 'symbol'. s -= s; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -133,4 +133,4 @@ tests/cases/conformance/es6/Symbols/symbolType12.ts(28,8): error TS2469: The '+= str += (s || str); ~~~~~~~~~~ -!!! error TS2469: The '+=' operator cannot be applied to a value of type 'symbol'. \ No newline at end of file +!!! error TS2469: The '+=' operator cannot be applied to type 'symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/symbolType3.errors.txt b/tests/baselines/reference/symbolType3.errors.txt index 384ccb06c05..7cc9e82b3b3 100644 --- a/tests/baselines/reference/symbolType3.errors.txt +++ b/tests/baselines/reference/symbolType3.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/es6/Symbols/symbolType3.ts(5,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType3.ts(6,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es6/Symbols/symbolType3.ts(7,3): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType3.ts(8,3): error TS2469: The '-' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType3.ts(9,3): error TS2469: The '~' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType3.ts(12,2): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType3.ts(7,3): error TS2469: The '+' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType3.ts(8,3): error TS2469: The '-' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType3.ts(9,3): error TS2469: The '~' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType3.ts(12,2): error TS2469: The '+' operator cannot be applied to type 'symbol'. ==== tests/cases/conformance/es6/Symbols/symbolType3.ts (6 errors) ==== @@ -19,15 +19,15 @@ tests/cases/conformance/es6/Symbols/symbolType3.ts(12,2): error TS2469: The '+' !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. + Symbol(); ~~~~~~~~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. - Symbol(); ~~~~~~~~ -!!! error TS2469: The '-' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '-' operator cannot be applied to type 'symbol'. ~ Symbol(); ~~~~~~~~ -!!! error TS2469: The '~' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '~' operator cannot be applied to type 'symbol'. ! Symbol(); +(Symbol() || 0); ~~~~~~~~~~~~~~~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. \ No newline at end of file +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/symbolType6.errors.txt b/tests/baselines/reference/symbolType6.errors.txt index 9ad7321063f..29d894c2afb 100644 --- a/tests/baselines/reference/symbolType6.errors.txt +++ b/tests/baselines/reference/symbolType6.errors.txt @@ -1,16 +1,16 @@ tests/cases/conformance/es6/Symbols/symbolType6.ts(3,1): error TS2365: Operator '+' cannot be applied to types 'symbol' and 'symbol'. tests/cases/conformance/es6/Symbols/symbolType6.ts(4,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType6.ts(4,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es6/Symbols/symbolType6.ts(5,1): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType6.ts(6,1): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(5,1): error TS2469: The '+' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(6,1): error TS2469: The '+' operator cannot be applied to type 'symbol'. tests/cases/conformance/es6/Symbols/symbolType6.ts(7,1): error TS2365: Operator '+' cannot be applied to types 'symbol' and 'number'. -tests/cases/conformance/es6/Symbols/symbolType6.ts(8,6): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType6.ts(9,5): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(8,6): error TS2469: The '+' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(9,5): error TS2469: The '+' operator cannot be applied to type 'symbol'. tests/cases/conformance/es6/Symbols/symbolType6.ts(10,1): error TS2365: Operator '+' cannot be applied to types 'number' and 'symbol'. tests/cases/conformance/es6/Symbols/symbolType6.ts(11,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType6.ts(12,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es6/Symbols/symbolType6.ts(14,1): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType6.ts(15,6): error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(14,1): error TS2469: The '+' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(15,6): error TS2469: The '+' operator cannot be applied to type 'symbol'. ==== tests/cases/conformance/es6/Symbols/symbolType6.ts (13 errors) ==== @@ -26,19 +26,19 @@ tests/cases/conformance/es6/Symbols/symbolType6.ts(15,6): error TS2469: The '+' !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. s + ""; ~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. s + a; ~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. s + 0; ~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'symbol' and 'number'. "" + s; ~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. a + s; ~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. 0 + s; ~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'number' and 'symbol'. @@ -51,7 +51,7 @@ tests/cases/conformance/es6/Symbols/symbolType6.ts(15,6): error TS2469: The '+' (s || "") + ""; ~~~~~~~~~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. "" + (s || ""); ~~~~~~~~~ -!!! error TS2469: The '+' operator cannot be applied to a value of type 'symbol'. \ No newline at end of file +!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/symbolType8.errors.txt b/tests/baselines/reference/symbolType8.errors.txt index e72d0d619e4..8df7db61feb 100644 --- a/tests/baselines/reference/symbolType8.errors.txt +++ b/tests/baselines/reference/symbolType8.errors.txt @@ -1,45 +1,45 @@ -tests/cases/conformance/es6/Symbols/symbolType8.ts(2,1): error TS2469: The '<' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(3,1): error TS2469: The '<' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(4,1): error TS2469: The '>' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(5,1): error TS2469: The '>' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(6,1): error TS2469: The '<=' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(7,1): error TS2469: The '<=' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(8,1): error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(9,1): error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(11,6): error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType8.ts(12,1): error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(2,1): error TS2469: The '<' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(3,1): error TS2469: The '<' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(4,1): error TS2469: The '>' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(5,1): error TS2469: The '>' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(6,1): error TS2469: The '<=' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(7,1): error TS2469: The '<=' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(8,1): error TS2469: The '>=' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(9,1): error TS2469: The '>=' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(11,6): error TS2469: The '>=' operator cannot be applied to type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType8.ts(12,1): error TS2469: The '>=' operator cannot be applied to type 'symbol'. ==== tests/cases/conformance/es6/Symbols/symbolType8.ts (10 errors) ==== var s = Symbol.for("compare"); s < s; ~ -!!! error TS2469: The '<' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '<' operator cannot be applied to type 'symbol'. s < 0; ~ -!!! error TS2469: The '<' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '<' operator cannot be applied to type 'symbol'. s > s; ~ -!!! error TS2469: The '>' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '>' operator cannot be applied to type 'symbol'. s > 0; ~ -!!! error TS2469: The '>' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '>' operator cannot be applied to type 'symbol'. s <= s; ~ -!!! error TS2469: The '<=' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '<=' operator cannot be applied to type 'symbol'. s <= 0; ~ -!!! error TS2469: The '<=' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '<=' operator cannot be applied to type 'symbol'. s >= s; ~ -!!! error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '>=' operator cannot be applied to type 'symbol'. s >= 0; ~ -!!! error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '>=' operator cannot be applied to type 'symbol'. 0 >= (s || 0); ~~~~~~~~ -!!! error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. +!!! error TS2469: The '>=' operator cannot be applied to type 'symbol'. (s || 0) >= s; ~~~~~~~~ -!!! error TS2469: The '>=' operator cannot be applied to a value of type 'symbol'. \ No newline at end of file +!!! error TS2469: The '>=' operator cannot be applied to type 'symbol'. \ No newline at end of file diff --git a/tests/cases/conformance/es6/Symbols/symbolProperty59.ts b/tests/cases/conformance/es6/Symbols/symbolProperty59.ts new file mode 100644 index 00000000000..bdea9dab62c --- /dev/null +++ b/tests/cases/conformance/es6/Symbols/symbolProperty59.ts @@ -0,0 +1,4 @@ +//@target: ES6 +interface I { + [Symbol.keyFor]: string; +} \ No newline at end of file