diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ea9c4286038..63977ffd41c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7924,14 +7924,7 @@ namespace ts { links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; case SyntaxKind.UniqueKeyword: - if (node.type.kind === SyntaxKind.SymbolKeyword) { - const parent = skipParentheses(node).parent; - const symbol = getSymbolOfNode(parent); - links.resolvedType = symbol ? getUniqueESSymbolTypeForSymbol(symbol) : esSymbolType; - } - else { - links.resolvedType = unknownType; - } + links.resolvedType = getUniqueType(node); break; } } @@ -8299,37 +8292,35 @@ namespace ts { return links.resolvedType; } + function nodeCanHaveUniqueESSymbolType(node: Node) { + return isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : + isPropertySignature(node) ? hasReadonlyModifier(node) : + false; + } + function createUniqueESSymbolType(symbol: Symbol) { const type = createType(TypeFlags.UniqueESSymbol); type.symbol = symbol; return type; } - function isReferenceToValidDeclarationForUniqueESSymbol(symbol: Symbol) { - if (symbol.valueDeclaration) { - switch (symbol.valueDeclaration.kind) { - case SyntaxKind.VariableDeclaration: - return getNameOfDeclaration(symbol.valueDeclaration).kind === SyntaxKind.Identifier - && isVariableDeclarationInVariableStatement(symbol.valueDeclaration) - && !!(symbol.valueDeclaration.parent.flags & NodeFlags.Const); - case SyntaxKind.PropertySignature: - return hasModifier(symbol.valueDeclaration, ModifierFlags.Readonly); - case SyntaxKind.PropertyDeclaration: - return hasModifier(symbol.valueDeclaration, ModifierFlags.Readonly) - && hasModifier(symbol.valueDeclaration, ModifierFlags.Static); - } - } - return false; - } - - function getUniqueESSymbolTypeForSymbol(symbol: Symbol) { - if (isReferenceToValidDeclarationForUniqueESSymbol(symbol)) { + function getUniqueESSymbolTypeForNode(node: Node) { + const parent = walkUpParentheses(node); + if (nodeCanHaveUniqueESSymbolType(parent)) { + const symbol = getSymbolOfNode(parent); const links = getSymbolLinks(symbol); return links.type || (links.type = createUniqueESSymbolType(symbol)); } return esSymbolType; } + function getUniqueType(node: UniqueTypeOperatorNode) { + return node.type.kind === SyntaxKind.SymbolKeyword + ? getUniqueESSymbolTypeForNode(node.parent) + : unknownType; + } + function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { const links = getNodeLinks(node); if (!links.resolvedType) { @@ -17180,9 +17171,7 @@ namespace ts { // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. if (returnType.flags & TypeFlags.ESSymbolLike && isSymbolOrSymbolForCall(node)) { - const parent = skipParentheses(node).parent; - const symbol = getSymbolOfNode(parent); - if (symbol) return getUniqueESSymbolTypeForSymbol(symbol); + return getUniqueESSymbolTypeForNode(node.parent); } return returnType; } @@ -25542,19 +25531,6 @@ namespace ts { } break; - // report specific errors for cases where a `unique symbol` type is disallowed even when it is in a `const` or `readonly` declaration. - case SyntaxKind.UnionType: - return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_not_allowed_in_a_union_type); - case SyntaxKind.IntersectionType: - return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_not_allowed_in_an_intersection_type); - case SyntaxKind.ArrayType: - return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_not_allowed_in_an_array_type); - case SyntaxKind.TupleType: - return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_not_allowed_in_a_tuple_type); - case SyntaxKind.MappedType: - return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_not_allowed_in_a_mapped_type); - - // report a general error for any other invalid use site. default: return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_not_allowed_here); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 87fd4db0407..7d1afd98e99 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -911,49 +911,29 @@ "category": "Error", "code": 1329 }, - "'unique symbol' types are not allowed in a union type.": { + "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'.": { "category": "Error", "code": 1330 }, - "'unique symbol' types are not allowed in an intersection type.": { + "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.": { "category": "Error", "code": 1331 }, - "'unique symbol' types are not allowed in an array type.": { + "A variable whose type is a 'unique symbol' type must be 'const'.": { "category": "Error", "code": 1332 }, - "'unique symbol' types are not allowed in a tuple type.": { + "'unique symbol' types may not be used on a variable declaration with a binding name.": { "category": "Error", "code": 1333 }, - "'unique symbol' types are not allowed in a mapped type.": { + "'unique symbol' types are only allowed on variables in a variable statement.": { "category": "Error", "code": 1334 }, - "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'.": { - "category": "Error", - "code": 1335 - }, - "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.": { - "category": "Error", - "code": 1336 - }, - "A variable whose type is a 'unique symbol' type must be 'const'.": { - "category": "Error", - "code": 1337 - }, - "'unique symbol' types may not be used on a variable declaration with a binding name.": { - "category": "Error", - "code": 1338 - }, - "'unique symbol' types are only allowed on variables in a variable statement.": { - "category": "Error", - "code": 1339 - }, "'unique symbol' types are not allowed here.": { "category": "Error", - "code": 1340 + "code": 1335 }, "Duplicate identifier '{0}'.": { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a3a522cec27..051bbe305c9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1046,6 +1046,11 @@ namespace ts { type: TypeNode; } + /* @internal */ + export interface UniqueTypeOperatorNode extends TypeOperatorNode { + operator: SyntaxKind.UniqueKeyword; + } + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 71d30a1ab9b..2ec5134d7e3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1695,12 +1695,27 @@ namespace ts { return getAssignmentTargetKind(node) !== AssignmentKind.None; } + export function walkUpParentheses(node: Node) { + while (node && (node.kind === SyntaxKind.ParenthesizedType || + node.kind === SyntaxKind.ParenthesizedExpression)) { + node = node.parent; + } + return node; + } + + export function walkUpParenthesizedExpressions(node: Node) { + while (node && node.kind === SyntaxKind.ParenthesizedExpression) { + node = node.parent; + } + return node; + } + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped export function isDeleteTarget(node: Node): boolean { if (node.kind !== SyntaxKind.PropertyAccessExpression && node.kind !== SyntaxKind.ElementAccessExpression) { return false; } - node = node.parent; + node = walkUpParenthesizedExpressions(node.parent); while (node && node.kind === SyntaxKind.ParenthesizedExpression) { node = node.parent; } @@ -3009,6 +3024,10 @@ namespace ts { return hasModifier(node, ModifierFlags.Static); } + export function hasReadonlyModifier(node: Node): boolean { + return hasModifier(node, ModifierFlags.Readonly); + } + export function getSelectedModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags { return getModifierFlags(node) & flags; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 89f6c276141..b1cc56ad8ce 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1989,7 +1989,7 @@ declare namespace ts { IndexedAccess = 1048576, NonPrimitive = 33554432, MarkerType = 134217728, - Literal = 1248, + Literal = 224, Unit = 13536, StringOrNumberLiteral = 96, PossiblyFalsy = 14574, @@ -2004,6 +2004,8 @@ declare namespace ts { TypeVariable = 1081344, Narrowable = 35620607, NotUnionOrUnit = 33620481, + WidenableLiteral = 480, + WidenableLiteralLike = 1504, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 30c5cfd0233..226b2acfd52 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1989,7 +1989,7 @@ declare namespace ts { IndexedAccess = 1048576, NonPrimitive = 33554432, MarkerType = 134217728, - Literal = 1248, + Literal = 224, Unit = 13536, StringOrNumberLiteral = 96, PossiblyFalsy = 14574, @@ -2004,6 +2004,8 @@ declare namespace ts { TypeVariable = 1081344, Narrowable = 35620607, NotUnionOrUnit = 33620481, + WidenableLiteral = 480, + WidenableLiteralLike = 1504, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { diff --git a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt index de4c8f981bd..4f49e7b096c 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt +++ b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt @@ -1,63 +1,63 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(2,41): error TS1005: 'symbol' expected. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,19): error TS1338: 'unique symbol' types may not be used on a variable declaration with a binding name. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(4,13): error TS1337: A variable whose type is a 'unique symbol' type must be 'const'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(5,13): error TS1337: A variable whose type is a 'unique symbol' type must be 'const'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,38): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,46): error TS1332: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,39): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,40): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,53): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,59): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(14,50): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(18,44): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(20,14): error TS1336: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(21,5): error TS1336: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(22,25): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,34): error TS1332: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,26): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,27): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,40): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,46): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,37): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,26): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(30,28): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(32,12): error TS1336: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(33,38): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,47): error TS1332: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,39): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,40): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,53): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,59): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,50): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,39): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(41,41): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(46,5): error TS1335: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(47,25): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,34): error TS1332: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,26): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,27): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,40): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,46): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(53,37): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(58,5): error TS1335: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(59,25): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,34): error TS1332: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,26): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,27): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,40): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,46): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(65,37): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,21): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,52): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(71,49): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,44): error TS1340: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1332: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(76,34): error TS1333: 'unique symbol' types are not allowed in a tuple type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(79,51): error TS1334: 'unique symbol' types are not allowed in a mapped type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,29): error TS1330: 'unique symbol' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,45): error TS1330: 'unique symbol' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,36): error TS1330: 'unique symbol' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,52): error TS1330: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,19): error TS1333: 'unique symbol' types may not be used on a variable declaration with a binding name. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(4,13): error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(5,13): error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,38): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,39): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,53): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,59): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(14,50): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(18,44): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(20,14): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(21,5): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(22,25): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,27): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,37): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(30,28): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(32,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(33,38): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,47): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,39): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,53): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,59): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,50): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,39): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(41,41): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(46,5): error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(47,25): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,27): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(53,37): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(58,5): error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(59,25): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,27): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(65,37): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,21): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,52): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(71,49): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,44): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(76,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(79,51): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,29): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,45): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,36): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,52): error TS1335: 'unique symbol' types are not allowed here. ==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts (60 errors) ==== @@ -67,203 +67,203 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,52): error !!! error TS1005: 'symbol' expected. declare const {}: unique symbol; ~~~~~~~~~~~~~ -!!! error TS1338: 'unique symbol' types may not be used on a variable declaration with a binding name. +!!! error TS1333: 'unique symbol' types may not be used on a variable declaration with a binding name. declare let invalidLetType: unique symbol; ~~~~~~~~~~~~~~ -!!! error TS1337: A variable whose type is a 'unique symbol' type must be 'const'. +!!! error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. declare var invalidVarType: unique symbol; ~~~~~~~~~~~~~~ -!!! error TS1337: A variable whose type is a 'unique symbol' type must be 'const'. +!!! error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. // function arguments and return types declare function invalidArgType(arg: unique symbol): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. declare function invalidRestArgType(...arg: (unique symbol)[]): void; ~~~~~~~~~~~~~ -!!! error TS1332: 'unique symbol' types are not allowed in an array type. +!!! error TS1335: 'unique symbol' types are not allowed here. declare function invalidReturnType(): unique symbol; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. declare function invalidThisType(this: unique symbol): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. declare function invalidTypePredicate(n: any): n is unique symbol; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. declare function invalidTypeParameterConstraint(): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. declare function invalidTypeParameterDefault(): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. // classes class InvalidClass { constructor(invalidConstructorArgType: unique symbol) {} ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. readonly invalidReadonlyPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1336: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. invalidPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~ -!!! error TS1336: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. invalidArgType(arg: unique symbol): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidRestArgType(...args: (unique symbol)[]): void { return; } ~~~~~~~~~~~~~ -!!! error TS1332: 'unique symbol' types are not allowed in an array type. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidReturnType(): unique symbol { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidThisType(this: unique symbol): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypePredicate(n: any): n is unique symbol { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypeParameterConstraint(): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypeParameterDefault(): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. get invalidGetter(): unique symbol { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. set invalidSetter(arg: unique symbol) { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static invalidStaticPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1336: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. static invalidStaticArgType(arg: unique symbol): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } ~~~~~~~~~~~~~ -!!! error TS1332: 'unique symbol' types are not allowed in an array type. +!!! error TS1335: 'unique symbol' types are not allowed here. static invalidStaticReturnType(): unique symbol { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static invalidStaticThisType(this: unique symbol): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static invalidStaticTypePredicate(n: any): n is unique symbol { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static invalidStaticTypeParameterConstraint(): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static invalidStaticTypeParameterDefault(): void { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static get invalidStaticGetter(): unique symbol { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. static set invalidStaticSetter(arg: unique symbol) { return; } ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. } // interfaces interface InvalidInterface { invalidPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~ -!!! error TS1335: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. +!!! error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. invalidArgType(arg: unique symbol): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidRestArgType(...args: (unique symbol)[]): void; ~~~~~~~~~~~~~ -!!! error TS1332: 'unique symbol' types are not allowed in an array type. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidReturnType(): unique symbol; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidThisType(this: unique symbol); ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypePredicate(n: any): n is unique symbol ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypeParameterConstraint(): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypeParameterDefault(): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. } // type literals type InvalidTypeLiteral = { invalidPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~ -!!! error TS1335: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. +!!! error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. invalidArgType(arg: unique symbol): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidRestArgType(...args: (unique symbol)[]): void; ~~~~~~~~~~~~~ -!!! error TS1332: 'unique symbol' types are not allowed in an array type. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidReturnType(): unique symbol; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidThisType(this: unique symbol); ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypePredicate(n: any): n is unique symbol ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypeParameterConstraint(): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. invalidTypeParameterDefault(): void; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. }; // type alias type InvalidAlias = unique symbol; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. type InvalidAliasTypeParameterConstraint = never; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. type InvalidAliasTypeParameterDefault = never; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. // type references declare const invalidTypeArgument: Promise; ~~~~~~~~~~~~~ -!!! error TS1340: 'unique symbol' types are not allowed here. +!!! error TS1335: 'unique symbol' types are not allowed here. declare const invalidArrayType: (unique symbol)[]; ~~~~~~~~~~~~~ -!!! error TS1332: 'unique symbol' types are not allowed in an array type. +!!! error TS1335: 'unique symbol' types are not allowed here. declare const invalidTupleType: [unique symbol]; ~~~~~~~~~~~~~ -!!! error TS1333: 'unique symbol' types are not allowed in a tuple type. +!!! error TS1335: 'unique symbol' types are not allowed here. // mapped types declare const invalidMappedType: { [P in string]: unique symbol }; ~~~~~~~~~~~~~ -!!! error TS1334: 'unique symbol' types are not allowed in a mapped type. +!!! error TS1335: 'unique symbol' types are not allowed here. // unions/intersection declare const invalidUnion: unique symbol | unique symbol; ~~~~~~~~~~~~~ -!!! error TS1330: 'unique symbol' types are not allowed in a union type. +!!! error TS1335: 'unique symbol' types are not allowed here. ~~~~~~~~~~~~~ -!!! error TS1330: 'unique symbol' types are not allowed in a union type. +!!! error TS1335: 'unique symbol' types are not allowed here. declare const invalidIntersection: unique symbol | unique symbol; ~~~~~~~~~~~~~ -!!! error TS1330: 'unique symbol' types are not allowed in a union type. +!!! error TS1335: 'unique symbol' types are not allowed here. ~~~~~~~~~~~~~ -!!! error TS1330: 'unique symbol' types are not allowed in a union type. +!!! error TS1335: 'unique symbol' types are not allowed here. \ No newline at end of file