mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Address feedback from @yuit
This commit is contained in:
+38
-26
@@ -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(<PropertyAccessExpression>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 (<LiteralExpression>indexArgumentExpression).text;
|
||||
}
|
||||
if (isWellKnownSymbolSyntactically(indexArgumentExpression)) {
|
||||
if (checkSymbolNameIsProperSymbolReference(<PropertyAccessExpression>indexArgumentExpression, indexArgumentType, /*reportError*/ false)) {
|
||||
var rightHandSideName = (<Identifier>(<PropertyAccessExpression>indexArgumentExpression).name).text;
|
||||
return getPropertyNameForKnownSymbolName(rightHandSideName);
|
||||
}
|
||||
if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) {
|
||||
var rightHandSideName = (<Identifier>(<PropertyAccessExpression>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.<identifier>
|
||||
* 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.<identifier>
|
||||
* 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.<someName>, so make sure Symbol actually resolves to the
|
||||
// global Symbol object
|
||||
var leftHandSide = (<PropertyAccessExpression>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, (<Identifier>leftHandSide).text,
|
||||
SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
||||
var leftHandSide = <Identifier>(<PropertyAccessExpression>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(<ComputedPropertyName>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(<ComputedPropertyName>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(<ComputedPropertyName>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);
|
||||
}
|
||||
|
||||
@@ -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}'." },
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -848,6 +848,11 @@ module ts {
|
||||
!isWellKnownSymbolSyntactically((<ComputedPropertyName>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((<PropertyAccessExpression>node).expression);
|
||||
}
|
||||
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [symbolProperty59.ts]
|
||||
interface I {
|
||||
[Symbol.keyFor]: string;
|
||||
}
|
||||
|
||||
//// [symbolProperty59.js]
|
||||
@@ -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'.
|
||||
!!! error TS2469: The '+=' operator cannot be applied to type 'symbol'.
|
||||
@@ -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'.
|
||||
!!! error TS2469: The '+' operator cannot be applied to type 'symbol'.
|
||||
@@ -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'.
|
||||
!!! error TS2469: The '+' operator cannot be applied to type 'symbol'.
|
||||
@@ -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'.
|
||||
!!! error TS2469: The '>=' operator cannot be applied to type 'symbol'.
|
||||
@@ -0,0 +1,4 @@
|
||||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.keyFor]: string;
|
||||
}
|
||||
Reference in New Issue
Block a user