From d8cb3c628af07ae522e2955f54c5fc0e7a9b7dd4 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 28 Apr 2017 22:24:24 -0700 Subject: [PATCH 01/43] Allow some dynamic names in types --- src/compiler/checker.ts | 153 ++++++- src/compiler/types.ts | 3 + src/harness/unittests/transform.ts | 3 + tests/baselines/reference/dynamicNames.js | 150 +++++++ .../baselines/reference/dynamicNames.symbols | 352 +++++++++++++++ tests/baselines/reference/dynamicNames.types | 420 ++++++++++++++++++ .../reference/dynamicNamesErrors.errors.txt | 43 ++ .../baselines/reference/dynamicNamesErrors.js | 29 ++ ...transformsCorrectly.fromTranspileModule.js | 2 +- tests/cases/compiler/dynamicNames.ts | 109 +++++ tests/cases/compiler/dynamicNamesErrors.ts | 22 + 11 files changed, 1277 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/dynamicNames.js create mode 100644 tests/baselines/reference/dynamicNames.symbols create mode 100644 tests/baselines/reference/dynamicNames.types create mode 100644 tests/baselines/reference/dynamicNamesErrors.errors.txt create mode 100644 tests/baselines/reference/dynamicNamesErrors.js create mode 100644 tests/cases/compiler/dynamicNames.ts create mode 100644 tests/cases/compiler/dynamicNamesErrors.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 18e57303c127c..7db62ed487dda 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -959,7 +959,7 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) { + if (result = getSymbol(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & SymbolFlags.Type)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -2895,6 +2895,9 @@ namespace ts { } function getNameOfSymbol(symbol: Symbol): string { + if (symbol.flags & SymbolFlags.Dynamic) { + return unescapeIdentifier(symbol.name); + } if (symbol.declarations && symbol.declarations.length) { const declaration = symbol.declarations[0]; if (declaration.name) { @@ -5133,7 +5136,7 @@ namespace ts { function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers { if (!(type).declaredProperties) { const symbol = type.symbol; - (type).declaredProperties = getNamedMembers(symbol.members); + (type).declaredProperties = getNamedMembers(getMembersOfSymbol(symbol)); (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); @@ -5142,6 +5145,137 @@ namespace ts { return type; } + function getMembersOfSymbol(symbol: Symbol) { + const links = getSymbolLinks(symbol); + if (!links.resolvedMembers) { + links.resolvedMembers = emptySymbols; + const dynamicMembers = getDynamicMembersOfSymbol(symbol); + if (!dynamicMembers || dynamicMembers.size === 0) { + return links.resolvedMembers = symbol.members || emptySymbols; + } + if (!symbol.members || symbol.members.size === 0) { + return links.resolvedMembers = dynamicMembers; + } + const resolvedMembers = createMap(); + mergeSymbolTable(resolvedMembers, symbol.members); + mergeSymbolTable(resolvedMembers, dynamicMembers); + return links.resolvedMembers = resolvedMembers; + } + return links.resolvedMembers; + } + + function getDynamicMembersOfSymbol(symbol: Symbol) { + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral)) { + const links = getSymbolLinks(symbol); + if (!links.dynamicMembers) { + const members = createMap(); + for (const decl of symbol.declarations) { + resolveDynamicMembersOfSymbol(decl, members); + } + links.dynamicMembers = members; + } + return links.dynamicMembers; + } + } + + function resolveDynamicMembersOfSymbol(node: Declaration, symbolTable: SymbolTable) { + switch (node.kind) { + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.TypeLiteral: + resolveDynamicMembersOfClassOrInterfaceOrTypeLiteralNode(node, symbolTable); + break; + case SyntaxKind.ObjectLiteralExpression: + resolveDynamicMembersOfObjectLiteralExpression(node, symbolTable); + break; + } + } + + function resolveDynamicMembersOfClassOrInterfaceOrTypeLiteralNode(node: ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode, symbolTable: SymbolTable) { + for (const member of node.members) { + if (member.name && isComputedPropertyName(member.name) && isEntityNameExpression(member.name.expression)) { + bindDynamicMember(symbolTable, node.symbol, member); + } + } + } + + function resolveDynamicMembersOfObjectLiteralExpression(node: ObjectLiteralExpression, symbolTable: SymbolTable) { + for (const member of node.properties) { + if (member.name && isComputedPropertyName(member.name) && isEntityNameExpression(member.name.expression)) { + bindDynamicMember(symbolTable, node.symbol, member); + } + } + } + + function bindDynamicMember(symbolTable: SymbolTable, parent: Symbol, member: ClassElement | TypeElement | ObjectLiteralElement) { + const links = getNodeLinks(member); + if (!links.resolvedSymbol) { + switch (member.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + return resolveDynamicMember(symbolTable, parent, member, + SymbolFlags.Property | ((member).questionToken ? SymbolFlags.Optional : SymbolFlags.None), + SymbolFlags.PropertyExcludes); + case SyntaxKind.PropertyAssignment: + return resolveDynamicMember(symbolTable, parent, member, SymbolFlags.Property, SymbolFlags.PropertyExcludes); + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + return resolveDynamicMember(symbolTable, parent, member, + SymbolFlags.Method | ((member).questionToken ? SymbolFlags.Optional : SymbolFlags.None), + isObjectLiteralMethod(member) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); + case SyntaxKind.GetAccessor: + return resolveDynamicMember(symbolTable, parent, member, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); + case SyntaxKind.SetAccessor: + return resolveDynamicMember(symbolTable, parent, member, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); + } + } + return links.resolvedSymbol; + } + + function resolveDynamicMember(symbolTable: SymbolTable, parent: Symbol, member: ClassElement | TypeElement | ObjectLiteralElement, includes: SymbolFlags, excludes: SymbolFlags) { + Debug.assert(isComputedPropertyName(member.name)); + const nameType = checkComputedPropertyName(member.name); + if (nameType.flags & TypeFlags.StringOrNumberLiteral) { + // TODO(rbuckton): ESSymbolLiteral + const memberName = escapeIdentifier((nameType).text); + let symbol = symbolTable.get(memberName); + if (!symbol) { + symbolTable.set(memberName, symbol = createSymbol(SymbolFlags.Dynamic, memberName)); + } + const staticMember = parent.members && parent.members.get(memberName); + if (symbol.flags & excludes || staticMember) { + const declarations = staticMember ? concatenate(staticMember.declarations, symbol.declarations) : symbol.declarations; + forEach(declarations, declaration => { + error(declaration.name || declaration, Diagnostics.Duplicate_identifier_0, memberName); + }); + error(member.name || member, Diagnostics.Duplicate_identifier_0, memberName); + symbol = createSymbol(SymbolFlags.Dynamic, memberName); + } + addDeclarationToSymbol(symbol, member, includes); + symbol.parent = parent; + return symbol; + } + return getNodeLinks(member).resolvedSymbol = member.symbol || unknownSymbol; + } + + function addDeclarationToSymbol(symbol: Symbol, member: ClassElement | TypeElement | ObjectLiteralElement, symbolFlags: SymbolFlags) { + symbol.flags |= symbolFlags; + getNodeLinks(member).resolvedSymbol = symbol; + if (!symbol.declarations) { + symbol.declarations = [member]; + } + else { + symbol.declarations.push(member); + } + if (symbolFlags & SymbolFlags.Value) { + const valueDeclaration = symbol.valueDeclaration; + if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + symbol.valueDeclaration = member; + } + } + } + function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { if (getObjectFlags(type) & ObjectFlags.Reference) { const target = (type).target; @@ -5165,7 +5299,7 @@ namespace ts { let numberIndexInfo: IndexInfo; if (rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { mapper = identityMapper; - members = source.symbol ? source.symbol.members : createSymbolTable(source.declaredProperties); + members = source.symbol ? getMembersOfSymbol(source.symbol) : createSymbolTable(source.declaredProperties); callSignatures = source.declaredCallSignatures; constructSignatures = source.declaredConstructSignatures; stringIndexInfo = source.declaredStringIndexInfo; @@ -5425,7 +5559,7 @@ namespace ts { setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & SymbolFlags.TypeLiteral) { - const members = symbol.members; + const members = getMembersOfSymbol(symbol); const callSignatures = getSignaturesOfSymbol(members.get("__call")); const constructSignatures = getSignaturesOfSymbol(members.get("__new")); const stringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); @@ -7396,7 +7530,7 @@ namespace ts { if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers const aliasSymbol = getAliasSymbolForTypeNode(node); - if (node.symbol.members.size === 0 && !aliasSymbol) { + if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -15623,7 +15757,7 @@ namespace ts { function getInferredClassType(symbol: Symbol) { const links = getSymbolLinks(symbol); if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); + links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol), emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); } return links.inferredClassType; } @@ -21741,7 +21875,7 @@ namespace ts { // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!(memberFlags & ModifierFlags.Static)) { - copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & SymbolFlags.Type); } break; case SyntaxKind.FunctionExpression: @@ -23739,7 +23873,10 @@ namespace ts { function checkGrammarForNonSymbolComputedProperty(node: DeclarationName, message: DiagnosticMessage) { if (isDynamicName(node)) { - return grammarErrorOnNode(node, message); + if (!isEntityNameExpression((node).expression) || + (checkExpressionCached((node).expression).flags & TypeFlags.StringOrNumberLiteral) === 0) { + return grammarErrorOnNode(node, message); + } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 57cf17f710003..bbe5dff8ef24c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2775,6 +2775,7 @@ namespace ts { ExportStar = 1 << 25, // Export * declaration Optional = 1 << 26, // Optional property Transient = 1 << 27, // Transient symbol (created during type check) + Dynamic = 1 << 28, // Dynamically resolved symbol from computed property Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, @@ -2869,6 +2870,8 @@ namespace ts { isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) + dynamicMembers?: SymbolTable; // Dynamic members with literal names resolved during check + resolvedMembers?: SymbolTable; } /* @internal */ diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 71f50ed94a98a..b66849917d631 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -68,6 +68,9 @@ namespace ts { transformers: { before: [replaceUndefinedWithVoid0], after: [replaceIdentifiersNamedOldNameWithNewName] + }, + compilerOptions: { + newLine: ts.NewLineKind.CarriageReturnLineFeed } }).outputText; }); diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js new file mode 100644 index 0000000000000..b5462f91c7805 --- /dev/null +++ b/tests/baselines/reference/dynamicNames.js @@ -0,0 +1,150 @@ +//// [tests/cases/compiler/dynamicNames.ts] //// + +//// [module.ts] +export const c0 = "a"; +export const c1 = 1; +export interface T0 { + [c0]: number; + [c1]: string; +} +export declare class T1 implements T2 { + [c0]: number; + [c1]: string; +} +export declare class T2 extends T1 { +} +export declare type T3 = { + [c0]: number; + [c1]: string; +}; + +//// [main.ts] +import { c0, c1, T0, T1, T2, T3 } from "./module"; +import * as M from "./module"; + +namespace N { + export const c2 = "a"; + export const c3 = 1; + + export interface T4 { + [N.c2]: number; + [N.c3]: string; + } + export declare class T5 implements T4 { + [N.c2]: number; + [N.c3]: string; + } + export declare class T6 extends T5 { + } + export declare type T7 = { + [N.c2]: number; + [N.c3]: string; + }; +} + +const c4 = "a"; +const c5 = 1; +const c6 = "1"; + +interface T8 { + [c4]: number; + [c5]: string; +} +declare class T9 implements T8 { + [c4]: number; + [c5]: string; +} +declare class T10 extends T9 { +} +declare type T11 = { + [c4]: number; + [c5]: string; +}; + +interface T12 { + a: number; + 1: string; +} +declare class T13 implements T2 { + a: number; + 1: string; +} +declare class T14 extends T13 { +} +declare type T15 = { + a: number; + 1: string; +}; + +interface T16 { + [c5]: number; + [c6]: string; +} + + +let t0: T0; +let t1: T1; +let t2: T2; +let t3: T3; +let t0_1: M.T0; +let t1_1: M.T1; +let t2_1: M.T2; +let t3_1: M.T3; +let t4: N.T4; +let t5: N.T5; +let t6: N.T6; +let t7: N.T7; +let t8: T8; +let t9: T9; +let t10: T10; +let t11: T11; +let t12: T12; +let t13: T13; +let t14: T14; +let t15: T15; + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; + +//// [module.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c0 = "a"; +exports.c1 = 1; +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var N; +(function (N) { + N.c2 = "a"; + N.c3 = 1; +})(N || (N = {})); +const c4 = "a"; +const c5 = 1; +const c6 = "1"; +let t0; +let t1; +let t2; +let t3; +let t0_1; +let t1_1; +let t2_1; +let t3_1; +let t4; +let t5; +let t6; +let t7; +let t8; +let t9; +let t10; +let t11; +let t12; +let t13; +let t14; +let t15; +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols new file mode 100644 index 0000000000000..fec309e2937b4 --- /dev/null +++ b/tests/baselines/reference/dynamicNames.symbols @@ -0,0 +1,352 @@ +=== tests/cases/compiler/module.ts === +export const c0 = "a"; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + +export const c1 = 1; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) + +export interface T0 { +>T0 : Symbol(T0, Decl(module.ts, 1, 20)) + + [c0]: number; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + + [c1]: string; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) +} +export declare class T1 implements T2 { +>T1 : Symbol(T1, Decl(module.ts, 5, 1)) +>T2 : Symbol(T2, Decl(module.ts, 9, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + + [c1]: string; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) +} +export declare class T2 extends T1 { +>T2 : Symbol(T2, Decl(module.ts, 9, 1)) +>T1 : Symbol(T1, Decl(module.ts, 5, 1)) +} +export declare type T3 = { +>T3 : Symbol(T3, Decl(module.ts, 11, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + + [c1]: string; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) + +}; + +=== tests/cases/compiler/main.ts === +import { c0, c1, T0, T1, T2, T3 } from "./module"; +>c0 : Symbol(c0, Decl(main.ts, 0, 8)) +>c1 : Symbol(c1, Decl(main.ts, 0, 12)) +>T0 : Symbol(T0, Decl(main.ts, 0, 16)) +>T1 : Symbol(T1, Decl(main.ts, 0, 20)) +>T2 : Symbol(T2, Decl(main.ts, 0, 24)) +>T3 : Symbol(T3, Decl(main.ts, 0, 28)) + +import * as M from "./module"; +>M : Symbol(M, Decl(main.ts, 1, 6)) + +namespace N { +>N : Symbol(N, Decl(main.ts, 1, 30)) + + export const c2 = "a"; +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + export const c3 = 1; +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + export interface T4 { +>T4 : Symbol(T4, Decl(main.ts, 5, 24)) + + [N.c2]: number; +>N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + [N.c3]: string; +>N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + } + export declare class T5 implements T4 { +>T5 : Symbol(T5, Decl(main.ts, 10, 5)) +>T4 : Symbol(T4, Decl(main.ts, 5, 24)) + + [N.c2]: number; +>N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + [N.c3]: string; +>N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + } + export declare class T6 extends T5 { +>T6 : Symbol(T6, Decl(main.ts, 14, 5)) +>T5 : Symbol(T5, Decl(main.ts, 10, 5)) + } + export declare type T7 = { +>T7 : Symbol(T7, Decl(main.ts, 16, 5)) + + [N.c2]: number; +>N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + [N.c3]: string; +>N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + }; +} + +const c4 = "a"; +>c4 : Symbol(c4, Decl(main.ts, 23, 5)) + +const c5 = 1; +>c5 : Symbol(c5, Decl(main.ts, 24, 5)) + +const c6 = "1"; +>c6 : Symbol(c6, Decl(main.ts, 25, 5)) + +interface T8 { +>T8 : Symbol(T8, Decl(main.ts, 25, 15)) + + [c4]: number; +>c4 : Symbol(c4, Decl(main.ts, 23, 5)) + + [c5]: string; +>c5 : Symbol(c5, Decl(main.ts, 24, 5)) +} +declare class T9 implements T8 { +>T9 : Symbol(T9, Decl(main.ts, 30, 1)) +>T8 : Symbol(T8, Decl(main.ts, 25, 15)) + + [c4]: number; +>c4 : Symbol(c4, Decl(main.ts, 23, 5)) + + [c5]: string; +>c5 : Symbol(c5, Decl(main.ts, 24, 5)) +} +declare class T10 extends T9 { +>T10 : Symbol(T10, Decl(main.ts, 34, 1)) +>T9 : Symbol(T9, Decl(main.ts, 30, 1)) +} +declare type T11 = { +>T11 : Symbol(T11, Decl(main.ts, 36, 1)) + + [c4]: number; +>c4 : Symbol(c4, Decl(main.ts, 23, 5)) + + [c5]: string; +>c5 : Symbol(c5, Decl(main.ts, 24, 5)) + +}; + +interface T12 { +>T12 : Symbol(T12, Decl(main.ts, 40, 2)) + + a: number; +>a : Symbol(T12.a, Decl(main.ts, 42, 15)) + + 1: string; +} +declare class T13 implements T2 { +>T13 : Symbol(T13, Decl(main.ts, 45, 1)) +>T2 : Symbol(T2, Decl(main.ts, 0, 24)) + + a: number; +>a : Symbol(T13.a, Decl(main.ts, 46, 33)) + + 1: string; +} +declare class T14 extends T13 { +>T14 : Symbol(T14, Decl(main.ts, 49, 1)) +>T13 : Symbol(T13, Decl(main.ts, 45, 1)) +} +declare type T15 = { +>T15 : Symbol(T15, Decl(main.ts, 51, 1)) + + a: number; +>a : Symbol(a, Decl(main.ts, 52, 20)) + + 1: string; +}; + +interface T16 { +>T16 : Symbol(T16, Decl(main.ts, 55, 2)) + + [c5]: number; +>c5 : Symbol(c5, Decl(main.ts, 24, 5)) + + [c6]: string; +>c6 : Symbol(c6, Decl(main.ts, 25, 5)) +} + + +let t0: T0; +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>T0 : Symbol(T0, Decl(main.ts, 0, 16)) + +let t1: T1; +>t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>T1 : Symbol(T1, Decl(main.ts, 0, 20)) + +let t2: T2; +>t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>T2 : Symbol(T2, Decl(main.ts, 0, 24)) + +let t3: T3; +>t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>T3 : Symbol(T3, Decl(main.ts, 0, 28)) + +let t0_1: M.T0; +>t0_1 : Symbol(t0_1, Decl(main.ts, 67, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T0 : Symbol(T0, Decl(module.ts, 1, 20)) + +let t1_1: M.T1; +>t1_1 : Symbol(t1_1, Decl(main.ts, 68, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T1 : Symbol(T1, Decl(module.ts, 5, 1)) + +let t2_1: M.T2; +>t2_1 : Symbol(t2_1, Decl(main.ts, 69, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T2 : Symbol(T2, Decl(module.ts, 9, 1)) + +let t3_1: M.T3; +>t3_1 : Symbol(t3_1, Decl(main.ts, 70, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T3 : Symbol(T3, Decl(module.ts, 11, 1)) + +let t4: N.T4; +>t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T4 : Symbol(N.T4, Decl(main.ts, 5, 24)) + +let t5: N.T5; +>t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T5 : Symbol(N.T5, Decl(main.ts, 10, 5)) + +let t6: N.T6; +>t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T6 : Symbol(N.T6, Decl(main.ts, 14, 5)) + +let t7: N.T7; +>t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T7 : Symbol(N.T7, Decl(main.ts, 16, 5)) + +let t8: T8; +>t8 : Symbol(t8, Decl(main.ts, 75, 3)) +>T8 : Symbol(T8, Decl(main.ts, 25, 15)) + +let t9: T9; +>t9 : Symbol(t9, Decl(main.ts, 76, 3)) +>T9 : Symbol(T9, Decl(main.ts, 30, 1)) + +let t10: T10; +>t10 : Symbol(t10, Decl(main.ts, 77, 3)) +>T10 : Symbol(T10, Decl(main.ts, 34, 1)) + +let t11: T11; +>t11 : Symbol(t11, Decl(main.ts, 78, 3)) +>T11 : Symbol(T11, Decl(main.ts, 36, 1)) + +let t12: T12; +>t12 : Symbol(t12, Decl(main.ts, 79, 3)) +>T12 : Symbol(T12, Decl(main.ts, 40, 2)) + +let t13: T13; +>t13 : Symbol(t13, Decl(main.ts, 80, 3)) +>T13 : Symbol(T13, Decl(main.ts, 45, 1)) + +let t14: T14; +>t14 : Symbol(t14, Decl(main.ts, 81, 3)) +>T14 : Symbol(T14, Decl(main.ts, 49, 1)) + +let t15: T15; +>t15 : Symbol(t15, Decl(main.ts, 82, 3)) +>T15 : Symbol(T15, Decl(main.ts, 51, 1)) + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>t2 : Symbol(t2, Decl(main.ts, 65, 3)) + +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +>t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>t6 : Symbol(t6, Decl(main.ts, 73, 3)) + +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t12 : Symbol(t12, Decl(main.ts, 79, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t13 : Symbol(t13, Decl(main.ts, 80, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t14 : Symbol(t14, Decl(main.ts, 81, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t15 : Symbol(t15, Decl(main.ts, 82, 3)) +>t12 : Symbol(t12, Decl(main.ts, 79, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t13 : Symbol(t13, Decl(main.ts, 80, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t14 : Symbol(t14, Decl(main.ts, 81, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t15 : Symbol(t15, Decl(main.ts, 82, 3)) +>t0 : Symbol(t0, Decl(main.ts, 63, 3)) + diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types new file mode 100644 index 0000000000000..68c4026c35c96 --- /dev/null +++ b/tests/baselines/reference/dynamicNames.types @@ -0,0 +1,420 @@ +=== tests/cases/compiler/module.ts === +export const c0 = "a"; +>c0 : "a" +>"a" : "a" + +export const c1 = 1; +>c1 : 1 +>1 : 1 + +export interface T0 { +>T0 : T0 + + [c0]: number; +>c0 : "a" + + [c1]: string; +>c1 : 1 +} +export declare class T1 implements T2 { +>T1 : T1 +>T2 : T2 + + [c0]: number; +>c0 : "a" + + [c1]: string; +>c1 : 1 +} +export declare class T2 extends T1 { +>T2 : T2 +>T1 : T1 +} +export declare type T3 = { +>T3 : T3 + + [c0]: number; +>c0 : "a" + + [c1]: string; +>c1 : 1 + +}; + +=== tests/cases/compiler/main.ts === +import { c0, c1, T0, T1, T2, T3 } from "./module"; +>c0 : "a" +>c1 : 1 +>T0 : any +>T1 : typeof T1 +>T2 : typeof T2 +>T3 : any + +import * as M from "./module"; +>M : typeof M + +namespace N { +>N : typeof N + + export const c2 = "a"; +>c2 : "a" +>"a" : "a" + + export const c3 = 1; +>c3 : 1 +>1 : 1 + + export interface T4 { +>T4 : T4 + + [N.c2]: number; +>N.c2 : "a" +>N : typeof N +>c2 : "a" + + [N.c3]: string; +>N.c3 : 1 +>N : typeof N +>c3 : 1 + } + export declare class T5 implements T4 { +>T5 : T5 +>T4 : T4 + + [N.c2]: number; +>N.c2 : "a" +>N : typeof N +>c2 : "a" + + [N.c3]: string; +>N.c3 : 1 +>N : typeof N +>c3 : 1 + } + export declare class T6 extends T5 { +>T6 : T6 +>T5 : T5 + } + export declare type T7 = { +>T7 : { a: number; 1: string; } + + [N.c2]: number; +>N.c2 : "a" +>N : typeof N +>c2 : "a" + + [N.c3]: string; +>N.c3 : 1 +>N : typeof N +>c3 : 1 + + }; +} + +const c4 = "a"; +>c4 : "a" +>"a" : "a" + +const c5 = 1; +>c5 : 1 +>1 : 1 + +const c6 = "1"; +>c6 : "1" +>"1" : "1" + +interface T8 { +>T8 : T8 + + [c4]: number; +>c4 : "a" + + [c5]: string; +>c5 : 1 +} +declare class T9 implements T8 { +>T9 : T9 +>T8 : T8 + + [c4]: number; +>c4 : "a" + + [c5]: string; +>c5 : 1 +} +declare class T10 extends T9 { +>T10 : T10 +>T9 : T9 +} +declare type T11 = { +>T11 : { a: number; 1: string; } + + [c4]: number; +>c4 : "a" + + [c5]: string; +>c5 : 1 + +}; + +interface T12 { +>T12 : T12 + + a: number; +>a : number + + 1: string; +} +declare class T13 implements T2 { +>T13 : T13 +>T2 : T2 + + a: number; +>a : number + + 1: string; +} +declare class T14 extends T13 { +>T14 : T14 +>T13 : T13 +} +declare type T15 = { +>T15 : { a: number; 1: string; } + + a: number; +>a : number + + 1: string; +}; + +interface T16 { +>T16 : T16 + + [c5]: number; +>c5 : 1 + + [c6]: string; +>c6 : "1" +} + + +let t0: T0; +>t0 : T0 +>T0 : T0 + +let t1: T1; +>t1 : T1 +>T1 : T1 + +let t2: T2; +>t2 : T2 +>T2 : T2 + +let t3: T3; +>t3 : T3 +>T3 : T3 + +let t0_1: M.T0; +>t0_1 : T0 +>M : any +>T0 : T0 + +let t1_1: M.T1; +>t1_1 : T1 +>M : any +>T1 : T1 + +let t2_1: M.T2; +>t2_1 : T2 +>M : any +>T2 : T2 + +let t3_1: M.T3; +>t3_1 : T3 +>M : any +>T3 : T3 + +let t4: N.T4; +>t4 : N.T4 +>N : any +>T4 : N.T4 + +let t5: N.T5; +>t5 : N.T5 +>N : any +>T5 : N.T5 + +let t6: N.T6; +>t6 : N.T6 +>N : any +>T6 : N.T6 + +let t7: N.T7; +>t7 : { a: number; 1: string; } +>N : any +>T7 : { a: number; 1: string; } + +let t8: T8; +>t8 : T8 +>T8 : T8 + +let t9: T9; +>t9 : T9 +>T9 : T9 + +let t10: T10; +>t10 : T10 +>T10 : T10 + +let t11: T11; +>t11 : { a: number; 1: string; } +>T11 : { a: number; 1: string; } + +let t12: T12; +>t12 : T12 +>T12 : T12 + +let t13: T13; +>t13 : T13 +>T13 : T13 + +let t14: T14; +>t14 : T14 +>T14 : T14 + +let t15: T15; +>t15 : { a: number; 1: string; } +>T15 : { a: number; 1: string; } + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2 : T2 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1 : T1 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0 : T0 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3 : T3 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1 : T1 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0 : T0 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3 : T3 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2 : T2 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0 : T0 +>t0 = t1, t0 = t2, t0 = t3 : T3 +>t0 = t1, t0 = t2 : T2 +>t0 = t1 : T1 +>t0 : T0 +>t1 : T1 +>t0 = t2 : T2 +>t0 : T0 +>t2 : T2 +>t0 = t3 : T3 +>t0 : T0 +>t3 : T3 +>t1 = t0 : T0 +>t1 : T1 +>t0 : T0 +>t1 = t2 : T2 +>t1 : T1 +>t2 : T2 +>t1 = t3 : T3 +>t1 : T1 +>t3 : T3 +>t2 = t0 : T0 +>t2 : T2 +>t0 : T0 +>t2 = t1 : T1 +>t2 : T2 +>t1 : T1 +>t2 = t3 : T3 +>t2 : T2 +>t3 : T3 +>t3 = t0 : T0 +>t3 : T3 +>t0 : T0 +>t3 = t1 : T1 +>t3 : T3 +>t1 : T1 +>t3 = t2 : T2 +>t3 : T3 +>t2 : T2 + +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6 : N.T6 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5 : N.T5 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4 : N.T4 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { a: number; 1: string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5 : N.T5 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4 : N.T4 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { a: number; 1: string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6 : N.T6 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4 : N.T4 +>t4 = t5, t4 = t6, t4 = t7 : { a: number; 1: string; } +>t4 = t5, t4 = t6 : N.T6 +>t4 = t5 : N.T5 +>t4 : N.T4 +>t5 : N.T5 +>t4 = t6 : N.T6 +>t4 : N.T4 +>t6 : N.T6 +>t4 = t7 : { a: number; 1: string; } +>t4 : N.T4 +>t7 : { a: number; 1: string; } +>t5 = t4 : N.T4 +>t5 : N.T5 +>t4 : N.T4 +>t5 = t6 : N.T6 +>t5 : N.T5 +>t6 : N.T6 +>t5 = t7 : { a: number; 1: string; } +>t5 : N.T5 +>t7 : { a: number; 1: string; } +>t6 = t4 : N.T4 +>t6 : N.T6 +>t4 : N.T4 +>t6 = t5 : N.T5 +>t6 : N.T6 +>t5 : N.T5 +>t6 = t7 : { a: number; 1: string; } +>t6 : N.T6 +>t7 : { a: number; 1: string; } +>t7 = t4 : N.T4 +>t7 : { a: number; 1: string; } +>t4 : N.T4 +>t7 = t5 : N.T5 +>t7 : { a: number; 1: string; } +>t5 : N.T5 +>t7 = t6 : N.T6 +>t7 : { a: number; 1: string; } +>t6 : N.T6 + +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15 : { a: number; 1: string; } +>t0 = t12, t0 = t13, t0 = t14 : T14 +>t0 = t12, t0 = t13 : T13 +>t0 = t12 : T12 +>t0 : T0 +>t12 : T12 +>t0 = t13 : T13 +>t0 : T0 +>t13 : T13 +>t0 = t14 : T14 +>t0 : T0 +>t14 : T14 +>t0 = t15 : { a: number; 1: string; } +>t0 : T0 +>t15 : { a: number; 1: string; } +>t12 = t0 : T0 +>t12 : T12 +>t0 : T0 +>t13 = t0 : T0 +>t13 : T13 +>t0 : T0 +>t14 = t0 : T0 +>t14 : T14 +>t0 : T0 +>t15 = t0 : T0 +>t15 : { a: number; 1: string; } +>t0 : T0 + diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt new file mode 100644 index 0000000000000..12796f95b99d1 --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -0,0 +1,43 @@ +tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2300: Duplicate identifier '1'. +tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2300: Duplicate identifier '1'. +tests/cases/compiler/dynamicNamesErrors.ts(19,1): error TS2322: Type 'T2' is not assignable to type 'T1'. + Types of property '1' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/dynamicNamesErrors.ts(20,1): error TS2322: Type 'T1' is not assignable to type 'T2'. + Types of property '1' are incompatible. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/compiler/dynamicNamesErrors.ts (4 errors) ==== + const c0 = "1"; + const c1 = 1; + + interface T0 { + [c0]: number; + ~~~~ +!!! error TS2300: Duplicate identifier '1'. + 1: number; + ~ +!!! error TS2300: Duplicate identifier '1'. + } + + interface T1 { + [c0]: number; + } + + interface T2 { + [c0]: string; + } + + let t1: T1; + let t2: T2; + t1 = t2; + ~~ +!!! error TS2322: Type 'T2' is not assignable to type 'T1'. +!!! error TS2322: Types of property '1' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + t2 = t1; + ~~ +!!! error TS2322: Type 'T1' is not assignable to type 'T2'. +!!! error TS2322: Types of property '1' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/dynamicNamesErrors.js b/tests/baselines/reference/dynamicNamesErrors.js new file mode 100644 index 0000000000000..960ad19db7786 --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.js @@ -0,0 +1,29 @@ +//// [dynamicNamesErrors.ts] +const c0 = "1"; +const c1 = 1; + +interface T0 { + [c0]: number; + 1: number; +} + +interface T1 { + [c0]: number; +} + +interface T2 { + [c0]: string; +} + +let t1: T1; +let t2: T2; +t1 = t2; +t2 = t1; + +//// [dynamicNamesErrors.js] +const c0 = "1"; +const c1 = 1; +let t1; +let t2; +t1 = t2; +t2 = t1; diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.fromTranspileModule.js b/tests/baselines/reference/transformApi/transformsCorrectly.fromTranspileModule.js index ddf3fd0e8d65d..714feaea305e3 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.fromTranspileModule.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.fromTranspileModule.js @@ -1 +1 @@ -var newName = void 0 /*undefined*/; +var newName = void 0 /*undefined*/; diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts new file mode 100644 index 0000000000000..09255054d00bf --- /dev/null +++ b/tests/cases/compiler/dynamicNames.ts @@ -0,0 +1,109 @@ +// @target: esnext +// @module: commonjs +// @filename: module.ts +export const c0 = "a"; +export const c1 = 1; +export interface T0 { + [c0]: number; + [c1]: string; +} +export declare class T1 implements T2 { + [c0]: number; + [c1]: string; +} +export declare class T2 extends T1 { +} +export declare type T3 = { + [c0]: number; + [c1]: string; +}; + +// @filename: main.ts +import { c0, c1, T0, T1, T2, T3 } from "./module"; +import * as M from "./module"; + +namespace N { + export const c2 = "a"; + export const c3 = 1; + + export interface T4 { + [N.c2]: number; + [N.c3]: string; + } + export declare class T5 implements T4 { + [N.c2]: number; + [N.c3]: string; + } + export declare class T6 extends T5 { + } + export declare type T7 = { + [N.c2]: number; + [N.c3]: string; + }; +} + +const c4 = "a"; +const c5 = 1; +const c6 = "1"; + +interface T8 { + [c4]: number; + [c5]: string; +} +declare class T9 implements T8 { + [c4]: number; + [c5]: string; +} +declare class T10 extends T9 { +} +declare type T11 = { + [c4]: number; + [c5]: string; +}; + +interface T12 { + a: number; + 1: string; +} +declare class T13 implements T2 { + a: number; + 1: string; +} +declare class T14 extends T13 { +} +declare type T15 = { + a: number; + 1: string; +}; + +interface T16 { + [c5]: number; + [c6]: string; +} + + +let t0: T0; +let t1: T1; +let t2: T2; +let t3: T3; +let t0_1: M.T0; +let t1_1: M.T1; +let t2_1: M.T2; +let t3_1: M.T3; +let t4: N.T4; +let t5: N.T5; +let t6: N.T6; +let t7: N.T7; +let t8: T8; +let t9: T9; +let t10: T10; +let t11: T11; +let t12: T12; +let t13: T13; +let t14: T14; +let t15: T15; + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; \ No newline at end of file diff --git a/tests/cases/compiler/dynamicNamesErrors.ts b/tests/cases/compiler/dynamicNamesErrors.ts new file mode 100644 index 0000000000000..f2c937cbdebf4 --- /dev/null +++ b/tests/cases/compiler/dynamicNamesErrors.ts @@ -0,0 +1,22 @@ +// @target: esnext + +const c0 = "1"; +const c1 = 1; + +interface T0 { + [c0]: number; + 1: number; +} + +interface T1 { + [c0]: number; +} + +interface T2 { + [c0]: string; +} + +let t1: T1; +let t2: T2; +t1 = t2; +t2 = t1; \ No newline at end of file From 0c1eef70b0dfb731dbf2a94eaf46acebdf94082d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sat, 29 Apr 2017 15:18:34 -0700 Subject: [PATCH 02/43] Add support for declaration emit --- src/compiler/checker.ts | 15 +++++++- src/compiler/declarationEmitter.ts | 56 ++++++++++++++++++++---------- src/compiler/types.ts | 1 + 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7db62ed487dda..b091388ed8eeb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2184,7 +2184,9 @@ namespace ts { function isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult { // get symbol of the first identifier of the entityName let meaning: SymbolFlags; - if (entityName.parent.kind === SyntaxKind.TypeQuery || isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === SyntaxKind.TypeQuery || + isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || + entityName.parent.kind === SyntaxKind.ComputedPropertyName) { // Typeof value meaning = SymbolFlags.Value | SymbolFlags.ExportValue; } @@ -22822,6 +22824,16 @@ namespace ts { return undefined; } + function isLiteralDynamicName(name: ComputedPropertyName) { + name = getParseTreeNode(name, isComputedPropertyName); + if (name) { + // TODO(rbuckton): ESSymbolLiteral + const nameType = checkComputedPropertyName(name); + return (nameType.flags & TypeFlags.StringOrNumberLiteral) !== 0; + } + return false; + } + function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { if (isConst(node)) { const type = getTypeOfSymbol(getSymbolOfNode(node)); @@ -22895,6 +22907,7 @@ namespace ts { getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration, + isLiteralDynamicName, writeLiteralConstValue, getJsxFactoryEntity: () => _jsxFactoryEntity }; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 2bd8d5971fb2f..ec123a7488d97 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -452,19 +452,6 @@ namespace ts { return emitTypePredicate(type); } - function writeEntityName(entityName: EntityName | Expression) { - if (entityName.kind === SyntaxKind.Identifier) { - writeTextOfNode(currentText, entityName); - } - else { - const left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; - const right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; - writeEntityName(left); - write("."); - writeTextOfNode(currentText, right); - } - } - function emitEntityName(entityName: EntityNameOrEntityNameExpression) { const visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration @@ -584,6 +571,19 @@ namespace ts { } } + function writeEntityName(entityName: EntityName | Expression) { + if (entityName.kind === SyntaxKind.Identifier) { + writeTextOfNode(currentText, entityName); + } + else { + const left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; + const right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; + writeEntityName(left); + write("."); + writeTextOfNode(currentText, right); + } + } + function emitSourceFile(node: SourceFile) { currentText = node.text; currentLineMap = getLineStarts(node); @@ -1202,7 +1202,7 @@ namespace ts { } function emitPropertyDeclaration(node: Declaration) { - if (hasDynamicName(node)) { + if (hasDynamicName(node) && !resolver.isLiteralDynamicName(node.name)) { return; } @@ -1221,10 +1221,17 @@ namespace ts { emitBindingPattern(node.name); } else { - // If this node is a computed name, it can only be a symbol, because we've already skipped - // it if it's not a well known symbol. In that case, the text of the name will be exactly - // what we want, namely the name expression enclosed in brackets. - writeTextOfNode(currentText, node.name); + if (isDynamicName(node.name)) { + // If this node has a dynamic name, it can only be an identifier or property access because + // we've already skipped it otherwise. + emitDynamicName((node.name).expression); + } + else { + // If this node is a computed name, it can only be a symbol, because we've already skipped + // it if it's not a well known symbol. In that case, the text of the name will be exactly + // what we want, namely the name expression enclosed in brackets. + writeTextOfNode(currentText, node.name); + } // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || @@ -1287,6 +1294,19 @@ namespace ts { } : undefined; } + function emitDynamicName(entityName: EntityNameExpression) { + writer.getSymbolAccessibilityDiagnostic = getVariableDeclarationTypeVisibilityError; + const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration); + if (visibilityResult.accessibility !== SymbolAccessibility.Accessible) { + resolver.writeTypeOfExpression(entityName, enclosingDeclaration, TypeFormatFlags.None, writer); + } + else { + handleSymbolAccessibilityError(visibilityResult); + recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); + writeTextOfNode(currentText, node.name); + } + } + function emitBindingPattern(bindingPattern: BindingPattern) { // Only select non-omitted expression from the bindingPattern's elements. // We have to do this to avoid emitting trailing commas. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index bbe5dff8ef24c..8b00f8f27b624 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2721,6 +2721,7 @@ namespace ts { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + isLiteralDynamicName(node: ComputedPropertyName): boolean; collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; isRequiredInitializedParameter(node: ParameterDeclaration): boolean; From d572a54d152a1bbd5cb9f4351eecfe417dc99689 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sun, 30 Apr 2017 22:27:31 -0700 Subject: [PATCH 03/43] Report errors from duplicate member names --- src/compiler/checker.ts | 7 +- src/compiler/diagnosticMessages.json | 4 + tests/baselines/reference/dynamicNames.js | 8 - .../baselines/reference/dynamicNames.symbols | 226 ++++++++---------- tests/baselines/reference/dynamicNames.types | 15 -- .../reference/dynamicNamesErrors.errors.txt | 15 +- .../baselines/reference/dynamicNamesErrors.js | 6 + tests/cases/compiler/dynamicNames.ts | 7 - tests/cases/compiler/dynamicNamesErrors.ts | 6 + 9 files changed, 139 insertions(+), 155 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b091388ed8eeb..e811b83844c31 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1815,7 +1815,7 @@ namespace ts { } function getSymbolOfNode(node: Node): Symbol { - return getMergedSymbol(node.symbol); + return getMergedSymbol(node.symbol && node.symbol.name === "__computed" && node.id && getNodeLinks(node).resolvedSymbol || node.symbol); } function getParentOfSymbol(symbol: Symbol): Symbol { @@ -19502,7 +19502,10 @@ namespace ts { // initializer is consistent with type associated with the node const declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { - error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); + const message = node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature + ? Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 + : Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; + error(node.name, message, declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b69adf708f24e..6092e91976064 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2123,6 +2123,10 @@ "category": "Error", "code": 2710 }, + "Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'.": { + "category": "Error", + "code": 2711 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index b5462f91c7805..766494683e100 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -44,7 +44,6 @@ namespace N { const c4 = "a"; const c5 = 1; -const c6 = "1"; interface T8 { [c4]: number; @@ -76,12 +75,6 @@ declare type T15 = { 1: string; }; -interface T16 { - [c5]: number; - [c6]: string; -} - - let t0: T0; let t1: T1; let t2: T2; @@ -123,7 +116,6 @@ var N; })(N || (N = {})); const c4 = "a"; const c5 = 1; -const c6 = "1"; let t0; let t1; let t2; diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index fec309e2937b4..09970da02e117 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -113,11 +113,8 @@ const c4 = "a"; const c5 = 1; >c5 : Symbol(c5, Decl(main.ts, 24, 5)) -const c6 = "1"; ->c6 : Symbol(c6, Decl(main.ts, 25, 5)) - interface T8 { ->T8 : Symbol(T8, Decl(main.ts, 25, 15)) +>T8 : Symbol(T8, Decl(main.ts, 24, 13)) [c4]: number; >c4 : Symbol(c4, Decl(main.ts, 23, 5)) @@ -126,8 +123,8 @@ interface T8 { >c5 : Symbol(c5, Decl(main.ts, 24, 5)) } declare class T9 implements T8 { ->T9 : Symbol(T9, Decl(main.ts, 30, 1)) ->T8 : Symbol(T8, Decl(main.ts, 25, 15)) +>T9 : Symbol(T9, Decl(main.ts, 29, 1)) +>T8 : Symbol(T8, Decl(main.ts, 24, 13)) [c4]: number; >c4 : Symbol(c4, Decl(main.ts, 23, 5)) @@ -136,11 +133,11 @@ declare class T9 implements T8 { >c5 : Symbol(c5, Decl(main.ts, 24, 5)) } declare class T10 extends T9 { ->T10 : Symbol(T10, Decl(main.ts, 34, 1)) ->T9 : Symbol(T9, Decl(main.ts, 30, 1)) +>T10 : Symbol(T10, Decl(main.ts, 33, 1)) +>T9 : Symbol(T9, Decl(main.ts, 29, 1)) } declare type T11 = { ->T11 : Symbol(T11, Decl(main.ts, 36, 1)) +>T11 : Symbol(T11, Decl(main.ts, 35, 1)) [c4]: number; >c4 : Symbol(c4, Decl(main.ts, 23, 5)) @@ -151,202 +148,191 @@ declare type T11 = { }; interface T12 { ->T12 : Symbol(T12, Decl(main.ts, 40, 2)) +>T12 : Symbol(T12, Decl(main.ts, 39, 2)) a: number; ->a : Symbol(T12.a, Decl(main.ts, 42, 15)) +>a : Symbol(T12.a, Decl(main.ts, 41, 15)) 1: string; } declare class T13 implements T2 { ->T13 : Symbol(T13, Decl(main.ts, 45, 1)) +>T13 : Symbol(T13, Decl(main.ts, 44, 1)) >T2 : Symbol(T2, Decl(main.ts, 0, 24)) a: number; ->a : Symbol(T13.a, Decl(main.ts, 46, 33)) +>a : Symbol(T13.a, Decl(main.ts, 45, 33)) 1: string; } declare class T14 extends T13 { ->T14 : Symbol(T14, Decl(main.ts, 49, 1)) ->T13 : Symbol(T13, Decl(main.ts, 45, 1)) +>T14 : Symbol(T14, Decl(main.ts, 48, 1)) +>T13 : Symbol(T13, Decl(main.ts, 44, 1)) } declare type T15 = { ->T15 : Symbol(T15, Decl(main.ts, 51, 1)) +>T15 : Symbol(T15, Decl(main.ts, 50, 1)) a: number; ->a : Symbol(a, Decl(main.ts, 52, 20)) +>a : Symbol(a, Decl(main.ts, 51, 20)) 1: string; }; -interface T16 { ->T16 : Symbol(T16, Decl(main.ts, 55, 2)) - - [c5]: number; ->c5 : Symbol(c5, Decl(main.ts, 24, 5)) - - [c6]: string; ->c6 : Symbol(c6, Decl(main.ts, 25, 5)) -} - - let t0: T0; ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) >T0 : Symbol(T0, Decl(main.ts, 0, 16)) let t1: T1; ->t1 : Symbol(t1, Decl(main.ts, 64, 3)) +>t1 : Symbol(t1, Decl(main.ts, 57, 3)) >T1 : Symbol(T1, Decl(main.ts, 0, 20)) let t2: T2; ->t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>t2 : Symbol(t2, Decl(main.ts, 58, 3)) >T2 : Symbol(T2, Decl(main.ts, 0, 24)) let t3: T3; ->t3 : Symbol(t3, Decl(main.ts, 66, 3)) +>t3 : Symbol(t3, Decl(main.ts, 59, 3)) >T3 : Symbol(T3, Decl(main.ts, 0, 28)) let t0_1: M.T0; ->t0_1 : Symbol(t0_1, Decl(main.ts, 67, 3)) +>t0_1 : Symbol(t0_1, Decl(main.ts, 60, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T0 : Symbol(T0, Decl(module.ts, 1, 20)) let t1_1: M.T1; ->t1_1 : Symbol(t1_1, Decl(main.ts, 68, 3)) +>t1_1 : Symbol(t1_1, Decl(main.ts, 61, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T1 : Symbol(T1, Decl(module.ts, 5, 1)) let t2_1: M.T2; ->t2_1 : Symbol(t2_1, Decl(main.ts, 69, 3)) +>t2_1 : Symbol(t2_1, Decl(main.ts, 62, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T2 : Symbol(T2, Decl(module.ts, 9, 1)) let t3_1: M.T3; ->t3_1 : Symbol(t3_1, Decl(main.ts, 70, 3)) +>t3_1 : Symbol(t3_1, Decl(main.ts, 63, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T3 : Symbol(T3, Decl(module.ts, 11, 1)) let t4: N.T4; ->t4 : Symbol(t4, Decl(main.ts, 71, 3)) +>t4 : Symbol(t4, Decl(main.ts, 64, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T4 : Symbol(N.T4, Decl(main.ts, 5, 24)) let t5: N.T5; ->t5 : Symbol(t5, Decl(main.ts, 72, 3)) +>t5 : Symbol(t5, Decl(main.ts, 65, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T5 : Symbol(N.T5, Decl(main.ts, 10, 5)) let t6: N.T6; ->t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>t6 : Symbol(t6, Decl(main.ts, 66, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T6 : Symbol(N.T6, Decl(main.ts, 14, 5)) let t7: N.T7; ->t7 : Symbol(t7, Decl(main.ts, 74, 3)) +>t7 : Symbol(t7, Decl(main.ts, 67, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T7 : Symbol(N.T7, Decl(main.ts, 16, 5)) let t8: T8; ->t8 : Symbol(t8, Decl(main.ts, 75, 3)) ->T8 : Symbol(T8, Decl(main.ts, 25, 15)) +>t8 : Symbol(t8, Decl(main.ts, 68, 3)) +>T8 : Symbol(T8, Decl(main.ts, 24, 13)) let t9: T9; ->t9 : Symbol(t9, Decl(main.ts, 76, 3)) ->T9 : Symbol(T9, Decl(main.ts, 30, 1)) +>t9 : Symbol(t9, Decl(main.ts, 69, 3)) +>T9 : Symbol(T9, Decl(main.ts, 29, 1)) let t10: T10; ->t10 : Symbol(t10, Decl(main.ts, 77, 3)) ->T10 : Symbol(T10, Decl(main.ts, 34, 1)) +>t10 : Symbol(t10, Decl(main.ts, 70, 3)) +>T10 : Symbol(T10, Decl(main.ts, 33, 1)) let t11: T11; ->t11 : Symbol(t11, Decl(main.ts, 78, 3)) ->T11 : Symbol(T11, Decl(main.ts, 36, 1)) +>t11 : Symbol(t11, Decl(main.ts, 71, 3)) +>T11 : Symbol(T11, Decl(main.ts, 35, 1)) let t12: T12; ->t12 : Symbol(t12, Decl(main.ts, 79, 3)) ->T12 : Symbol(T12, Decl(main.ts, 40, 2)) +>t12 : Symbol(t12, Decl(main.ts, 72, 3)) +>T12 : Symbol(T12, Decl(main.ts, 39, 2)) let t13: T13; ->t13 : Symbol(t13, Decl(main.ts, 80, 3)) ->T13 : Symbol(T13, Decl(main.ts, 45, 1)) +>t13 : Symbol(t13, Decl(main.ts, 73, 3)) +>T13 : Symbol(T13, Decl(main.ts, 44, 1)) let t14: T14; ->t14 : Symbol(t14, Decl(main.ts, 81, 3)) ->T14 : Symbol(T14, Decl(main.ts, 49, 1)) +>t14 : Symbol(t14, Decl(main.ts, 74, 3)) +>T14 : Symbol(T14, Decl(main.ts, 48, 1)) let t15: T15; ->t15 : Symbol(t15, Decl(main.ts, 82, 3)) ->T15 : Symbol(T15, Decl(main.ts, 51, 1)) +>t15 : Symbol(t15, Decl(main.ts, 75, 3)) +>T15 : Symbol(T15, Decl(main.ts, 50, 1)) // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t1 : Symbol(t1, Decl(main.ts, 64, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t2 : Symbol(t2, Decl(main.ts, 65, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t3 : Symbol(t3, Decl(main.ts, 66, 3)) ->t1 : Symbol(t1, Decl(main.ts, 64, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t1 : Symbol(t1, Decl(main.ts, 64, 3)) ->t2 : Symbol(t2, Decl(main.ts, 65, 3)) ->t1 : Symbol(t1, Decl(main.ts, 64, 3)) ->t3 : Symbol(t3, Decl(main.ts, 66, 3)) ->t2 : Symbol(t2, Decl(main.ts, 65, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t2 : Symbol(t2, Decl(main.ts, 65, 3)) ->t1 : Symbol(t1, Decl(main.ts, 64, 3)) ->t2 : Symbol(t2, Decl(main.ts, 65, 3)) ->t3 : Symbol(t3, Decl(main.ts, 66, 3)) ->t3 : Symbol(t3, Decl(main.ts, 66, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t3 : Symbol(t3, Decl(main.ts, 66, 3)) ->t1 : Symbol(t1, Decl(main.ts, 64, 3)) ->t3 : Symbol(t3, Decl(main.ts, 66, 3)) ->t2 : Symbol(t2, Decl(main.ts, 65, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t1 : Symbol(t1, Decl(main.ts, 57, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t2 : Symbol(t2, Decl(main.ts, 58, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t3 : Symbol(t3, Decl(main.ts, 59, 3)) +>t1 : Symbol(t1, Decl(main.ts, 57, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t1 : Symbol(t1, Decl(main.ts, 57, 3)) +>t2 : Symbol(t2, Decl(main.ts, 58, 3)) +>t1 : Symbol(t1, Decl(main.ts, 57, 3)) +>t3 : Symbol(t3, Decl(main.ts, 59, 3)) +>t2 : Symbol(t2, Decl(main.ts, 58, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t2 : Symbol(t2, Decl(main.ts, 58, 3)) +>t1 : Symbol(t1, Decl(main.ts, 57, 3)) +>t2 : Symbol(t2, Decl(main.ts, 58, 3)) +>t3 : Symbol(t3, Decl(main.ts, 59, 3)) +>t3 : Symbol(t3, Decl(main.ts, 59, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t3 : Symbol(t3, Decl(main.ts, 59, 3)) +>t1 : Symbol(t1, Decl(main.ts, 57, 3)) +>t3 : Symbol(t3, Decl(main.ts, 59, 3)) +>t2 : Symbol(t2, Decl(main.ts, 58, 3)) t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; ->t4 : Symbol(t4, Decl(main.ts, 71, 3)) ->t5 : Symbol(t5, Decl(main.ts, 72, 3)) ->t4 : Symbol(t4, Decl(main.ts, 71, 3)) ->t6 : Symbol(t6, Decl(main.ts, 73, 3)) ->t4 : Symbol(t4, Decl(main.ts, 71, 3)) ->t7 : Symbol(t7, Decl(main.ts, 74, 3)) ->t5 : Symbol(t5, Decl(main.ts, 72, 3)) ->t4 : Symbol(t4, Decl(main.ts, 71, 3)) ->t5 : Symbol(t5, Decl(main.ts, 72, 3)) ->t6 : Symbol(t6, Decl(main.ts, 73, 3)) ->t5 : Symbol(t5, Decl(main.ts, 72, 3)) ->t7 : Symbol(t7, Decl(main.ts, 74, 3)) ->t6 : Symbol(t6, Decl(main.ts, 73, 3)) ->t4 : Symbol(t4, Decl(main.ts, 71, 3)) ->t6 : Symbol(t6, Decl(main.ts, 73, 3)) ->t5 : Symbol(t5, Decl(main.ts, 72, 3)) ->t6 : Symbol(t6, Decl(main.ts, 73, 3)) ->t7 : Symbol(t7, Decl(main.ts, 74, 3)) ->t7 : Symbol(t7, Decl(main.ts, 74, 3)) ->t4 : Symbol(t4, Decl(main.ts, 71, 3)) ->t7 : Symbol(t7, Decl(main.ts, 74, 3)) ->t5 : Symbol(t5, Decl(main.ts, 72, 3)) ->t7 : Symbol(t7, Decl(main.ts, 74, 3)) ->t6 : Symbol(t6, Decl(main.ts, 73, 3)) +>t4 : Symbol(t4, Decl(main.ts, 64, 3)) +>t5 : Symbol(t5, Decl(main.ts, 65, 3)) +>t4 : Symbol(t4, Decl(main.ts, 64, 3)) +>t6 : Symbol(t6, Decl(main.ts, 66, 3)) +>t4 : Symbol(t4, Decl(main.ts, 64, 3)) +>t7 : Symbol(t7, Decl(main.ts, 67, 3)) +>t5 : Symbol(t5, Decl(main.ts, 65, 3)) +>t4 : Symbol(t4, Decl(main.ts, 64, 3)) +>t5 : Symbol(t5, Decl(main.ts, 65, 3)) +>t6 : Symbol(t6, Decl(main.ts, 66, 3)) +>t5 : Symbol(t5, Decl(main.ts, 65, 3)) +>t7 : Symbol(t7, Decl(main.ts, 67, 3)) +>t6 : Symbol(t6, Decl(main.ts, 66, 3)) +>t4 : Symbol(t4, Decl(main.ts, 64, 3)) +>t6 : Symbol(t6, Decl(main.ts, 66, 3)) +>t5 : Symbol(t5, Decl(main.ts, 65, 3)) +>t6 : Symbol(t6, Decl(main.ts, 66, 3)) +>t7 : Symbol(t7, Decl(main.ts, 67, 3)) +>t7 : Symbol(t7, Decl(main.ts, 67, 3)) +>t4 : Symbol(t4, Decl(main.ts, 64, 3)) +>t7 : Symbol(t7, Decl(main.ts, 67, 3)) +>t5 : Symbol(t5, Decl(main.ts, 65, 3)) +>t7 : Symbol(t7, Decl(main.ts, 67, 3)) +>t6 : Symbol(t6, Decl(main.ts, 66, 3)) t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t12 : Symbol(t12, Decl(main.ts, 79, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t13 : Symbol(t13, Decl(main.ts, 80, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t14 : Symbol(t14, Decl(main.ts, 81, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t15 : Symbol(t15, Decl(main.ts, 82, 3)) ->t12 : Symbol(t12, Decl(main.ts, 79, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t13 : Symbol(t13, Decl(main.ts, 80, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t14 : Symbol(t14, Decl(main.ts, 81, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) ->t15 : Symbol(t15, Decl(main.ts, 82, 3)) ->t0 : Symbol(t0, Decl(main.ts, 63, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t12 : Symbol(t12, Decl(main.ts, 72, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t13 : Symbol(t13, Decl(main.ts, 73, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t14 : Symbol(t14, Decl(main.ts, 74, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t15 : Symbol(t15, Decl(main.ts, 75, 3)) +>t12 : Symbol(t12, Decl(main.ts, 72, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t13 : Symbol(t13, Decl(main.ts, 73, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t14 : Symbol(t14, Decl(main.ts, 74, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t15 : Symbol(t15, Decl(main.ts, 75, 3)) +>t0 : Symbol(t0, Decl(main.ts, 56, 3)) diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 68c4026c35c96..509b0a3f937f0 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -119,10 +119,6 @@ const c5 = 1; >c5 : 1 >1 : 1 -const c6 = "1"; ->c6 : "1" ->"1" : "1" - interface T8 { >T8 : T8 @@ -187,17 +183,6 @@ declare type T15 = { 1: string; }; -interface T16 { ->T16 : T16 - - [c5]: number; ->c5 : 1 - - [c6]: string; ->c6 : "1" -} - - let t0: T0; >t0 : T0 >T0 : T0 diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index 12796f95b99d1..50af0addb9af3 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -1,14 +1,15 @@ tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2300: Duplicate identifier '1'. tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2300: Duplicate identifier '1'. -tests/cases/compiler/dynamicNamesErrors.ts(19,1): error TS2322: Type 'T2' is not assignable to type 'T1'. +tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2711: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. +tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '1' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/dynamicNamesErrors.ts(20,1): error TS2322: Type 'T1' is not assignable to type 'T2'. +tests/cases/compiler/dynamicNamesErrors.ts(26,1): error TS2322: Type 'T1' is not assignable to type 'T2'. Types of property '1' are incompatible. Type 'number' is not assignable to type 'string'. -==== tests/cases/compiler/dynamicNamesErrors.ts (4 errors) ==== +==== tests/cases/compiler/dynamicNamesErrors.ts (5 errors) ==== const c0 = "1"; const c1 = 1; @@ -29,6 +30,14 @@ tests/cases/compiler/dynamicNamesErrors.ts(20,1): error TS2322: Type 'T1' is not [c0]: string; } + interface T3 { + [c0]: number; + [c1]: string; + ~~~~ +!!! error TS2711: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. + } + + let t1: T1; let t2: T2; t1 = t2; diff --git a/tests/baselines/reference/dynamicNamesErrors.js b/tests/baselines/reference/dynamicNamesErrors.js index 960ad19db7786..186ae8870d7ab 100644 --- a/tests/baselines/reference/dynamicNamesErrors.js +++ b/tests/baselines/reference/dynamicNamesErrors.js @@ -15,6 +15,12 @@ interface T2 { [c0]: string; } +interface T3 { + [c0]: number; + [c1]: string; +} + + let t1: T1; let t2: T2; t1 = t2; diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index 09255054d00bf..f99a49e975d06 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -44,7 +44,6 @@ namespace N { const c4 = "a"; const c5 = 1; -const c6 = "1"; interface T8 { [c4]: number; @@ -76,12 +75,6 @@ declare type T15 = { 1: string; }; -interface T16 { - [c5]: number; - [c6]: string; -} - - let t0: T0; let t1: T1; let t2: T2; diff --git a/tests/cases/compiler/dynamicNamesErrors.ts b/tests/cases/compiler/dynamicNamesErrors.ts index f2c937cbdebf4..c819619a58193 100644 --- a/tests/cases/compiler/dynamicNamesErrors.ts +++ b/tests/cases/compiler/dynamicNamesErrors.ts @@ -16,6 +16,12 @@ interface T2 { [c0]: string; } +interface T3 { + [c0]: number; + [c1]: string; +} + + let t1: T1; let t2: T2; t1 = t2; From 271429544331e335d2e1b6ed4dccb4d27609b6d7 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 2 May 2017 16:22:28 -0700 Subject: [PATCH 04/43] Add declaration file output to tests --- tests/baselines/reference/dynamicNames.js | 26 +++++++++++++++-- .../baselines/reference/dynamicNames.symbols | 29 ++++++++++--------- tests/baselines/reference/dynamicNames.types | 10 +++++-- tests/cases/compiler/dynamicNames.ts | 6 ++-- 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index 766494683e100..173c02b444821 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -3,6 +3,7 @@ //// [module.ts] export const c0 = "a"; export const c1 = 1; +const c2 = "a"; export interface T0 { [c0]: number; [c1]: string; @@ -14,7 +15,7 @@ export declare class T1 implements T2 { export declare class T2 extends T1 { } export declare type T3 = { - [c0]: number; + [c2]: number; [c1]: string; }; @@ -98,7 +99,7 @@ let t15: T15; // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; -t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; //// [module.js] @@ -106,6 +107,7 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; Object.defineProperty(exports, "__esModule", { value: true }); exports.c0 = "a"; exports.c1 = 1; +const c2 = "a"; //// [main.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -140,3 +142,23 @@ let t15; t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; + + +//// [module.d.ts] +export declare const c0 = "a"; +export declare const c1 = 1; +export interface T0 { + [c0]: number; + [c1]: string; +} +export declare class T1 implements T2 { + [c0]: number; + [c1]: string; +} +export declare class T2 extends T1 { +} +export declare type T3 = { + "a": number; + [c1]: string; +}; +//// [main.d.ts] diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index 09970da02e117..12dd6576b740c 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -5,8 +5,11 @@ export const c0 = "a"; export const c1 = 1; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) +const c2 = "a"; +>c2 : Symbol(c2, Decl(module.ts, 2, 5)) + export interface T0 { ->T0 : Symbol(T0, Decl(module.ts, 1, 20)) +>T0 : Symbol(T0, Decl(module.ts, 2, 15)) [c0]: number; >c0 : Symbol(c0, Decl(module.ts, 0, 12)) @@ -15,8 +18,8 @@ export interface T0 { >c1 : Symbol(c1, Decl(module.ts, 1, 12)) } export declare class T1 implements T2 { ->T1 : Symbol(T1, Decl(module.ts, 5, 1)) ->T2 : Symbol(T2, Decl(module.ts, 9, 1)) +>T1 : Symbol(T1, Decl(module.ts, 6, 1)) +>T2 : Symbol(T2, Decl(module.ts, 10, 1)) [c0]: number; >c0 : Symbol(c0, Decl(module.ts, 0, 12)) @@ -25,14 +28,14 @@ export declare class T1 implements T2 { >c1 : Symbol(c1, Decl(module.ts, 1, 12)) } export declare class T2 extends T1 { ->T2 : Symbol(T2, Decl(module.ts, 9, 1)) ->T1 : Symbol(T1, Decl(module.ts, 5, 1)) +>T2 : Symbol(T2, Decl(module.ts, 10, 1)) +>T1 : Symbol(T1, Decl(module.ts, 6, 1)) } export declare type T3 = { ->T3 : Symbol(T3, Decl(module.ts, 11, 1)) +>T3 : Symbol(T3, Decl(module.ts, 12, 1)) - [c0]: number; ->c0 : Symbol(c0, Decl(module.ts, 0, 12)) + [c2]: number; +>c2 : Symbol(c2, Decl(module.ts, 2, 5)) [c1]: string; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) @@ -196,22 +199,22 @@ let t3: T3; let t0_1: M.T0; >t0_1 : Symbol(t0_1, Decl(main.ts, 60, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T0 : Symbol(T0, Decl(module.ts, 1, 20)) +>T0 : Symbol(T0, Decl(module.ts, 2, 15)) let t1_1: M.T1; >t1_1 : Symbol(t1_1, Decl(main.ts, 61, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T1 : Symbol(T1, Decl(module.ts, 5, 1)) +>T1 : Symbol(T1, Decl(module.ts, 6, 1)) let t2_1: M.T2; >t2_1 : Symbol(t2_1, Decl(main.ts, 62, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T2 : Symbol(T2, Decl(module.ts, 9, 1)) +>T2 : Symbol(T2, Decl(module.ts, 10, 1)) let t3_1: M.T3; >t3_1 : Symbol(t3_1, Decl(main.ts, 63, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T3 : Symbol(T3, Decl(module.ts, 11, 1)) +>T3 : Symbol(T3, Decl(module.ts, 12, 1)) let t4: N.T4; >t4 : Symbol(t4, Decl(main.ts, 64, 3)) @@ -292,7 +295,7 @@ t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, >t3 : Symbol(t3, Decl(main.ts, 59, 3)) >t2 : Symbol(t2, Decl(main.ts, 58, 3)) -t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; >t4 : Symbol(t4, Decl(main.ts, 64, 3)) >t5 : Symbol(t5, Decl(main.ts, 65, 3)) >t4 : Symbol(t4, Decl(main.ts, 64, 3)) diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 509b0a3f937f0..8d46cb8b6f80f 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -7,6 +7,10 @@ export const c1 = 1; >c1 : 1 >1 : 1 +const c2 = "a"; +>c2 : "a" +>"a" : "a" + export interface T0 { >T0 : T0 @@ -33,8 +37,8 @@ export declare class T2 extends T1 { export declare type T3 = { >T3 : T3 - [c0]: number; ->c0 : "a" + [c2]: number; +>c2 : "a" [c1]: string; >c1 : 1 @@ -321,7 +325,7 @@ t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, >t3 : T3 >t2 : T2 -t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4 : N.T4 diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index f99a49e975d06..473d5bc3a8d23 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -1,8 +1,10 @@ // @target: esnext // @module: commonjs +// @declaration: true // @filename: module.ts export const c0 = "a"; export const c1 = 1; +const c2 = "a"; export interface T0 { [c0]: number; [c1]: string; @@ -14,7 +16,7 @@ export declare class T1 implements T2 { export declare class T2 extends T1 { } export declare type T3 = { - [c0]: number; + [c2]: number; [c1]: string; }; @@ -98,5 +100,5 @@ let t15: T15; // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; -t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; \ No newline at end of file From b5f11695b73fe28394f14ec86825dec757aa7e8d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 2 May 2017 16:32:29 -0700 Subject: [PATCH 05/43] Accept baselines --- src/compiler/checker.ts | 2 +- .../classWithDuplicateIdentifier.errors.txt | 4 ++-- .../reference/duplicateClassElements.errors.txt | 4 ++-- .../reference/gettersAndSettersErrors.errors.txt | 4 ++-- .../reference/interfaceDeclaration1.errors.txt | 4 ++-- ...InterfacesWithConflictingPropertyNames.errors.txt | 12 ++++++------ .../numericStringNamedPropertyEquivalence.errors.txt | 4 ++-- .../reference/reassignStaticProp.errors.txt | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e0cecdcda0914..f5ff6a8c7c7a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2184,7 +2184,7 @@ namespace ts { function isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult { // get symbol of the first identifier of the entityName let meaning: SymbolFlags; - if (entityName.parent.kind === SyntaxKind.TypeQuery || + if (entityName.parent.kind === SyntaxKind.TypeQuery || isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || entityName.parent.kind === SyntaxKind.ComputedPropertyName) { // Typeof value diff --git a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt index 325db86d47d50..b304d197ada8d 100644 --- a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt +++ b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(3,5): error TS2300: Duplica tests/cases/compiler/classWithDuplicateIdentifier.ts(6,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(7,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2300: Duplicate identifier 'c'. -tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'number', but here has type 'string'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2711: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. ==== tests/cases/compiler/classWithDuplicateIdentifier.ts (5 errors) ==== @@ -26,6 +26,6 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2403: Subseq ~ !!! error TS2300: Duplicate identifier 'c'. ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'number', but here has type 'string'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateClassElements.errors.txt b/tests/baselines/reference/duplicateClassElements.errors.txt index 7579190db7194..73c6e8eb7a846 100644 --- a/tests/baselines/reference/duplicateClassElements.errors.txt +++ b/tests/baselines/reference/duplicateClassElements.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/duplicateClassElements.ts(26,9): error TS2300: Duplicate id tests/cases/compiler/duplicateClassElements.ts(29,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2300: Duplicate identifier 'x2'. -tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2403: Subsequent variable declarations must have the same type. Variable 'x2' must be of type 'number', but here has type 'any'. +tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2711: Subsequent property declarations must have the same type. Property 'x2' must be of type 'number', but here has type 'any'. tests/cases/compiler/duplicateClassElements.ts(36,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(36,9): error TS2300: Duplicate identifier 'z2'. tests/cases/compiler/duplicateClassElements.ts(39,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -96,7 +96,7 @@ tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate i ~~ !!! error TS2300: Duplicate identifier 'x2'. ~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x2' must be of type 'number', but here has type 'any'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'x2' must be of type 'number', but here has type 'any'. get z2() { ~~ diff --git a/tests/baselines/reference/gettersAndSettersErrors.errors.txt b/tests/baselines/reference/gettersAndSettersErrors.errors.txt index a3be786cb264b..c58b263d047f6 100644 --- a/tests/baselines/reference/gettersAndSettersErrors.errors.txt +++ b/tests/baselines/reference/gettersAndSettersErrors.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/gettersAndSettersErrors.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2403: Subsequent variable declarations must have the same type. Variable 'Foo' must be of type 'string', but here has type 'number'. +tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2711: Subsequent property declarations must have the same type. Property 'Foo' must be of type 'string', but here has type 'number'. tests/cases/compiler/gettersAndSettersErrors.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -23,7 +23,7 @@ tests/cases/compiler/gettersAndSettersErrors.ts(12,16): error TS2379: Getter and ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Foo' must be of type 'string', but here has type 'number'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'Foo' must be of type 'string', but here has type 'number'. public get Goo(v:string):string {return null;} // error - getters must not have a parameter ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/interfaceDeclaration1.errors.txt b/tests/baselines/reference/interfaceDeclaration1.errors.txt index 95b3d90ca2cbb..0a5df54aab3c7 100644 --- a/tests/baselines/reference/interfaceDeclaration1.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration1.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/interfaceDeclaration1.ts(2,5): error TS2300: Duplicate iden tests/cases/compiler/interfaceDeclaration1.ts(3,5): error TS2300: Duplicate identifier 'item'. tests/cases/compiler/interfaceDeclaration1.ts(7,5): error TS2300: Duplicate identifier 'item'. tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2300: Duplicate identifier 'item'. -tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'item' must be of type 'any', but here has type 'number'. +tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2711: Subsequent property declarations must have the same type. Property 'item' must be of type 'any', but here has type 'number'. tests/cases/compiler/interfaceDeclaration1.ts(22,11): error TS2310: Type 'I5' recursively references itself as a base type. tests/cases/compiler/interfaceDeclaration1.ts(35,7): error TS2420: Class 'C1' incorrectly implements interface 'I3'. Property 'prototype' is missing in type 'C1'. @@ -29,7 +29,7 @@ tests/cases/compiler/interfaceDeclaration1.ts(52,11): error TS2320: Interface 'i ~~~~ !!! error TS2300: Duplicate identifier 'item'. ~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'item' must be of type 'any', but here has type 'number'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'item' must be of type 'any', but here has type 'number'. } interface I3 { diff --git a/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt b/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt index 437bf2d80f0c7..aa21d20ebf46a 100644 --- a/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt +++ b/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(6,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(15,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'T', but here has type 'number'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(39,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'T', but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(6,5): error TS2711: Subsequent property declarations must have the same type. Property 'x' must be of type 'string', but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(15,9): error TS2711: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(39,9): error TS2711: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. ==== tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts (3 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli interface A { x: number; ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'x' must be of type 'string', but here has type 'number'. } module M { @@ -22,7 +22,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli interface A { x: number; // error ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'T', but here has type 'number'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. } } @@ -48,6 +48,6 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli export interface A { x: number; // error ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'T', but here has type 'number'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. } } \ No newline at end of file diff --git a/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt b/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt index 102a6a0783673..99b43122a076d 100644 --- a/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt +++ b/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericString tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(12,5): error TS2300: Duplicate identifier '1'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(16,5): error TS2300: Duplicate identifier '1'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2300: Duplicate identifier '1'. -tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2403: Subsequent variable declarations must have the same type. Variable '1.0' must be of type 'number', but here has type 'string'. +tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2711: Subsequent property declarations must have the same type. Property '1.0' must be of type 'number', but here has type 'string'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(22,5): error TS2300: Duplicate identifier '0'. @@ -36,7 +36,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericString ~~~ !!! error TS2300: Duplicate identifier '1'. ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable '1.0' must be of type 'number', but here has type 'string'. +!!! error TS2711: Subsequent property declarations must have the same type. Property '1.0' must be of type 'number', but here has type 'string'. } var b = { diff --git a/tests/baselines/reference/reassignStaticProp.errors.txt b/tests/baselines/reference/reassignStaticProp.errors.txt index 7f67a6e7fc316..149f04b99959d 100644 --- a/tests/baselines/reference/reassignStaticProp.errors.txt +++ b/tests/baselines/reference/reassignStaticProp.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2300: Duplicate identifier 'bar'. -tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2403: Subsequent variable declarations must have the same type. Variable 'bar' must be of type 'number', but here has type 'string'. +tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2711: Subsequent property declarations must have the same type. Property 'bar' must be of type 'number', but here has type 'string'. ==== tests/cases/compiler/reassignStaticProp.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2403: Subsequent varia ~~~ !!! error TS2300: Duplicate identifier 'bar'. ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'bar' must be of type 'number', but here has type 'string'. +!!! error TS2711: Subsequent property declarations must have the same type. Property 'bar' must be of type 'number', but here has type 'string'. } From 3b684d420fc3c62d0589eac7e785e373f51d9197 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 2 May 2017 16:34:51 -0700 Subject: [PATCH 06/43] PR feedback --- src/compiler/checker.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f5ff6a8c7c7a4..8ca7ba850566d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5186,24 +5186,16 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: case SyntaxKind.TypeLiteral: - resolveDynamicMembersOfClassOrInterfaceOrTypeLiteralNode(node, symbolTable); + resolveDynamicMembersOfNode(node, (node).members, symbolTable); break; case SyntaxKind.ObjectLiteralExpression: - resolveDynamicMembersOfObjectLiteralExpression(node, symbolTable); + resolveDynamicMembersOfNode(node, (node).properties, symbolTable); break; } } - function resolveDynamicMembersOfClassOrInterfaceOrTypeLiteralNode(node: ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode, symbolTable: SymbolTable) { - for (const member of node.members) { - if (member.name && isComputedPropertyName(member.name) && isEntityNameExpression(member.name.expression)) { - bindDynamicMember(symbolTable, node.symbol, member); - } - } - } - - function resolveDynamicMembersOfObjectLiteralExpression(node: ObjectLiteralExpression, symbolTable: SymbolTable) { - for (const member of node.properties) { + function resolveDynamicMembersOfNode(node: Declaration, members: NodeArray, symbolTable: SymbolTable) { + for (const member of members) { if (member.name && isComputedPropertyName(member.name) && isEntityNameExpression(member.name.expression)) { bindDynamicMember(symbolTable, node.symbol, member); } From 64fd857b0dcca50b2babe4b5404e6eb496e5dbcb Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 2 May 2017 17:34:08 -0700 Subject: [PATCH 07/43] fix symbol display for computed properties --- src/compiler/checker.ts | 12 ++++--- .../computedPropertyNames13_ES5.symbols | 4 +-- .../computedPropertyNames13_ES6.symbols | 4 +-- .../computedPropertyNames16_ES5.symbols | 4 +-- .../computedPropertyNames16_ES6.symbols | 4 +-- .../computedPropertyNames37_ES5.symbols | 4 +-- .../computedPropertyNames37_ES6.symbols | 4 +-- .../computedPropertyNames41_ES5.symbols | 2 +- .../computedPropertyNames41_ES6.symbols | 2 +- ...omputedPropertyNamesSourceMap1_ES5.symbols | 4 +-- ...omputedPropertyNamesSourceMap1_ES6.symbols | 4 +-- .../decoratorOnClassMethod13.symbols | 4 +-- .../reference/decoratorOnClassMethod4.symbols | 2 +- .../reference/decoratorOnClassMethod5.symbols | 2 +- .../reference/decoratorOnClassMethod7.symbols | 2 +- tests/baselines/reference/dynamicNames.types | 36 +++++++++---------- .../reference/dynamicNamesErrors.errors.txt | 8 ++--- ...ssDeclarationWithGetterSetterInES6.symbols | 12 +++---- ...mitClassDeclarationWithMethodInES6.symbols | 12 +++---- .../findAllRefsForComputedProperties.ts | 8 ++--- .../findAllRefsForComputedProperties2.ts | 8 ++--- 21 files changed, 73 insertions(+), 69 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8ca7ba850566d..4491804c56d68 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2898,7 +2898,7 @@ namespace ts { function getNameOfSymbol(symbol: Symbol): string { if (symbol.flags & SymbolFlags.Dynamic) { - return unescapeIdentifier(symbol.name); + return `"${escapeString(unescapeIdentifier(symbol.name))}"`; } if (symbol.declarations && symbol.declarations.length) { const declaration = symbol.declarations[0]; @@ -2940,14 +2940,18 @@ namespace ts { const needsElementAccess = !isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, SyntaxKind.OpenBracketToken); + if (firstChar !== CharacterCodes.openBracket) { + writePunctuation(writer, SyntaxKind.OpenBracketToken); + } if (isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, SyntaxKind.CloseBracketToken); + if (firstChar !== CharacterCodes.openBracket) { + writePunctuation(writer, SyntaxKind.CloseBracketToken); + } } else { writePunctuation(writer, SyntaxKind.DotToken); @@ -5232,7 +5236,7 @@ namespace ts { const nameType = checkComputedPropertyName(member.name); if (nameType.flags & TypeFlags.StringOrNumberLiteral) { // TODO(rbuckton): ESSymbolLiteral - const memberName = escapeIdentifier((nameType).text); + const memberName = (nameType).text; let symbol = symbolTable.get(memberName); if (!symbol) { symbolTable.set(memberName, symbol = createSymbol(SymbolFlags.Dynamic, memberName)); diff --git a/tests/baselines/reference/computedPropertyNames13_ES5.symbols b/tests/baselines/reference/computedPropertyNames13_ES5.symbols index 493ea44b3399d..4fae0886ca2ef 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames13_ES5.symbols @@ -29,10 +29,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames13_ES5.ts, 0, 3)) static [""]() { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES5.ts, 8, 14)) +>"" : Symbol(C[""], Decl(computedPropertyNames13_ES5.ts, 8, 14)) [0]() { } ->0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES5.ts, 9, 21)) +>0 : Symbol(C[0], Decl(computedPropertyNames13_ES5.ts, 9, 21)) [a]() { } >a : Symbol(a, Decl(computedPropertyNames13_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames13_ES6.symbols b/tests/baselines/reference/computedPropertyNames13_ES6.symbols index 7c421d3f9f77c..1f3a1c1460c9a 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames13_ES6.symbols @@ -29,10 +29,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames13_ES6.ts, 0, 3)) static [""]() { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES6.ts, 8, 14)) +>"" : Symbol(C[""], Decl(computedPropertyNames13_ES6.ts, 8, 14)) [0]() { } ->0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES6.ts, 9, 21)) +>0 : Symbol(C[0], Decl(computedPropertyNames13_ES6.ts, 9, 21)) [a]() { } >a : Symbol(a, Decl(computedPropertyNames13_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames16_ES5.symbols b/tests/baselines/reference/computedPropertyNames16_ES5.symbols index 43f6e208957f7..dff21e3cd97cc 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames16_ES5.symbols @@ -31,11 +31,11 @@ class C { >s : Symbol(s, Decl(computedPropertyNames16_ES5.ts, 0, 3)) static set [""](v) { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES5.ts, 8, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames16_ES5.ts, 8, 28)) >v : Symbol(v, Decl(computedPropertyNames16_ES5.ts, 9, 20)) get [0]() { return 0; } ->0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES5.ts, 9, 26)) +>0 : Symbol(C[0], Decl(computedPropertyNames16_ES5.ts, 9, 26)) set [a](v) { } >a : Symbol(a, Decl(computedPropertyNames16_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames16_ES6.symbols b/tests/baselines/reference/computedPropertyNames16_ES6.symbols index 4febdc01b9b7f..3e1af442b2ddd 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames16_ES6.symbols @@ -31,11 +31,11 @@ class C { >s : Symbol(s, Decl(computedPropertyNames16_ES6.ts, 0, 3)) static set [""](v) { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES6.ts, 8, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames16_ES6.ts, 8, 28)) >v : Symbol(v, Decl(computedPropertyNames16_ES6.ts, 9, 20)) get [0]() { return 0; } ->0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES6.ts, 9, 26)) +>0 : Symbol(C[0], Decl(computedPropertyNames16_ES6.ts, 9, 26)) set [a](v) { } >a : Symbol(a, Decl(computedPropertyNames16_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames37_ES5.symbols b/tests/baselines/reference/computedPropertyNames37_ES5.symbols index 7763c5970a35f..5d9ea09078038 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames37_ES5.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES5.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames37_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames37_ES5.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES5.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames37_ES5.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames37_ES5.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames37_ES6.symbols b/tests/baselines/reference/computedPropertyNames37_ES6.symbols index d2e1e2fdc6e69..f30cd6cad377e 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames37_ES6.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES6.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames37_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames37_ES6.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES6.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames37_ES6.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames37_ES6.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames41_ES5.symbols b/tests/baselines/reference/computedPropertyNames41_ES5.symbols index 821a39c8d594f..c0642d6b0a6a7 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames41_ES5.symbols @@ -17,6 +17,6 @@ class C { // Computed properties static [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES5.ts, 4, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames41_ES5.ts, 4, 28)) >Foo : Symbol(Foo, Decl(computedPropertyNames41_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames41_ES6.symbols b/tests/baselines/reference/computedPropertyNames41_ES6.symbols index a075603e252c7..10ef48e4d16c9 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames41_ES6.symbols @@ -17,6 +17,6 @@ class C { // Computed properties static [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES6.ts, 4, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames41_ES6.ts, 4, 28)) >Foo : Symbol(Foo, Decl(computedPropertyNames41_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols index 9f4f5110e8fcb..cdb193e3bd394 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 0)) ["hello"]() { ->"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 9)) +>"hello" : Symbol(C["hello"], Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 9)) debugger; } get ["goodbye"]() { ->"goodbye" : Symbol(C[["goodbye"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 3, 5)) +>"goodbye" : Symbol(C["goodbye"], Decl(computedPropertyNamesSourceMap1_ES5.ts, 3, 5)) return 0; } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols index 447bbaebb7cc8..e8ebdab2fd8b4 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 0)) ["hello"]() { ->"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 9)) +>"hello" : Symbol(C["hello"], Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 9)) debugger; } get ["goodbye"]() { ->"goodbye" : Symbol(C[["goodbye"]], Decl(computedPropertyNamesSourceMap1_ES6.ts, 3, 2)) +>"goodbye" : Symbol(C["goodbye"], Decl(computedPropertyNamesSourceMap1_ES6.ts, 3, 2)) return 0; } diff --git a/tests/baselines/reference/decoratorOnClassMethod13.symbols b/tests/baselines/reference/decoratorOnClassMethod13.symbols index 7cd369be14421..5700e6a3bf3a0 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod13.symbols @@ -15,9 +15,9 @@ class C { @dec ["1"]() { } >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) ->"1" : Symbol(C[["1"]], Decl(decoratorOnClassMethod13.ts, 2, 9)) +>"1" : Symbol(C["1"], Decl(decoratorOnClassMethod13.ts, 2, 9)) @dec ["b"]() { } >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) ->"b" : Symbol(C[["b"]], Decl(decoratorOnClassMethod13.ts, 3, 20)) +>"b" : Symbol(C["b"], Decl(decoratorOnClassMethod13.ts, 3, 20)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod4.symbols b/tests/baselines/reference/decoratorOnClassMethod4.symbols index da0e9eafca7f6..30d300a937a79 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod4.symbols @@ -15,5 +15,5 @@ class C { @dec ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod4.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod4.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod4.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod5.symbols b/tests/baselines/reference/decoratorOnClassMethod5.symbols index bd895deeea808..004af8b9f8e8a 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod5.symbols @@ -15,5 +15,5 @@ class C { @dec() ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod5.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod5.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod5.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod7.symbols b/tests/baselines/reference/decoratorOnClassMethod7.symbols index 9ec0de0c205f9..90e538ebfc4f7 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod7.symbols @@ -15,5 +15,5 @@ class C { @dec public ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod7.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod7.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod7.ts, 2, 9)) } diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 8d46cb8b6f80f..f9391d417c441 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -100,7 +100,7 @@ namespace N { >T5 : T5 } export declare type T7 = { ->T7 : { a: number; 1: string; } +>T7 : { "a": number; "1": string; } [N.c2]: number; >N.c2 : "a" @@ -147,7 +147,7 @@ declare class T10 extends T9 { >T9 : T9 } declare type T11 = { ->T11 : { a: number; 1: string; } +>T11 : { "a": number; "1": string; } [c4]: number; >c4 : "a" @@ -239,9 +239,9 @@ let t6: N.T6; >T6 : N.T6 let t7: N.T7; ->t7 : { a: number; 1: string; } +>t7 : { "a": number; "1": string; } >N : any ->T7 : { a: number; 1: string; } +>T7 : { "a": number; "1": string; } let t8: T8; >t8 : T8 @@ -256,8 +256,8 @@ let t10: T10; >T10 : T10 let t11: T11; ->t11 : { a: number; 1: string; } ->T11 : { a: number; 1: string; } +>t11 : { "a": number; "1": string; } +>T11 : { "a": number; "1": string; } let t12: T12; >t12 : T12 @@ -329,13 +329,13 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { a: number; 1: string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { "a": number; "1": string; } >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { a: number; 1: string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { "a": number; "1": string; } >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7 : { a: number; 1: string; } +>t4 = t5, t4 = t6, t4 = t7 : { "a": number; "1": string; } >t4 = t5, t4 = t6 : N.T6 >t4 = t5 : N.T5 >t4 : N.T4 @@ -343,35 +343,35 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t6 : N.T6 >t4 : N.T4 >t6 : N.T6 ->t4 = t7 : { a: number; 1: string; } +>t4 = t7 : { "a": number; "1": string; } >t4 : N.T4 ->t7 : { a: number; 1: string; } +>t7 : { "a": number; "1": string; } >t5 = t4 : N.T4 >t5 : N.T5 >t4 : N.T4 >t5 = t6 : N.T6 >t5 : N.T5 >t6 : N.T6 ->t5 = t7 : { a: number; 1: string; } +>t5 = t7 : { "a": number; "1": string; } >t5 : N.T5 ->t7 : { a: number; 1: string; } +>t7 : { "a": number; "1": string; } >t6 = t4 : N.T4 >t6 : N.T6 >t4 : N.T4 >t6 = t5 : N.T5 >t6 : N.T6 >t5 : N.T5 ->t6 = t7 : { a: number; 1: string; } +>t6 = t7 : { "a": number; "1": string; } >t6 : N.T6 ->t7 : { a: number; 1: string; } +>t7 : { "a": number; "1": string; } >t7 = t4 : N.T4 ->t7 : { a: number; 1: string; } +>t7 : { "a": number; "1": string; } >t4 : N.T4 >t7 = t5 : N.T5 ->t7 : { a: number; 1: string; } +>t7 : { "a": number; "1": string; } >t5 : N.T5 >t7 = t6 : N.T6 ->t7 : { a: number; 1: string; } +>t7 : { "a": number; "1": string; } >t6 : N.T6 t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index 50af0addb9af3..90e33b02736eb 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -2,10 +2,10 @@ tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2300: Duplicate identif tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2300: Duplicate identifier '1'. tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2711: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T2' is not assignable to type 'T1'. - Types of property '1' are incompatible. + Types of property '"1"' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/compiler/dynamicNamesErrors.ts(26,1): error TS2322: Type 'T1' is not assignable to type 'T2'. - Types of property '1' are incompatible. + Types of property '"1"' are incompatible. Type 'number' is not assignable to type 'string'. @@ -43,10 +43,10 @@ tests/cases/compiler/dynamicNamesErrors.ts(26,1): error TS2322: Type 'T1' is not t1 = t2; ~~ !!! error TS2322: Type 'T2' is not assignable to type 'T1'. -!!! error TS2322: Types of property '1' are incompatible. +!!! error TS2322: Types of property '"1"' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. t2 = t1; ~~ !!! error TS2322: Type 'T1' is not assignable to type 'T2'. -!!! error TS2322: Types of property '1' are incompatible. +!!! error TS2322: Types of property '"1"' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols index 89c49123e7757..b6a267e596f52 100644 --- a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols @@ -19,27 +19,27 @@ class C { return "BYE"; } static get ["computedname"]() { ->"computedname" : Symbol(C[["computedname"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) +>"computedname" : Symbol(C["computedname"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) return ""; } get ["computedname1"]() { ->"computedname1" : Symbol(C[["computedname1"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 10, 5)) +>"computedname1" : Symbol(C["computedname1"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 10, 5)) return ""; } get ["computedname2"]() { ->"computedname2" : Symbol(C[["computedname2"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 13, 5)) +>"computedname2" : Symbol(C["computedname2"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 13, 5)) return ""; } set ["computedname3"](x: any) { ->"computedname3" : Symbol(C[["computedname3"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 16, 5)) +>"computedname3" : Symbol(C["computedname3"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 16, 5)) >x : Symbol(x, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 18, 26)) } set ["computedname4"](y: string) { ->"computedname4" : Symbol(C[["computedname4"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 19, 5)) +>"computedname4" : Symbol(C["computedname4"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 19, 5)) >y : Symbol(y, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 20, 26)) } @@ -52,6 +52,6 @@ class C { >b : Symbol(b, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 19)) static set ["computedname"](b: string) { } ->"computedname" : Symbol(C[["computedname"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) +>"computedname" : Symbol(C["computedname"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) >b : Symbol(b, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 25, 32)) } diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols index 54522c5834ad0..5328b892ded81 100644 --- a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols @@ -9,14 +9,14 @@ class D { >foo : Symbol(D.foo, Decl(emitClassDeclarationWithMethodInES6.ts, 1, 17)) ["computedName1"]() { } ->"computedName1" : Symbol(D[["computedName1"]], Decl(emitClassDeclarationWithMethodInES6.ts, 2, 13)) +>"computedName1" : Symbol(D["computedName1"], Decl(emitClassDeclarationWithMethodInES6.ts, 2, 13)) ["computedName2"](a: string) { } ->"computedName2" : Symbol(D[["computedName2"]], Decl(emitClassDeclarationWithMethodInES6.ts, 3, 27)) +>"computedName2" : Symbol(D["computedName2"], Decl(emitClassDeclarationWithMethodInES6.ts, 3, 27)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 4, 22)) ["computedName3"](a: string): number { return 1; } ->"computedName3" : Symbol(D[["computedName3"]], Decl(emitClassDeclarationWithMethodInES6.ts, 4, 36)) +>"computedName3" : Symbol(D["computedName3"], Decl(emitClassDeclarationWithMethodInES6.ts, 4, 36)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 5, 22)) bar(): string { @@ -35,14 +35,14 @@ class D { return "HELLO"; } static ["computedname4"]() { } ->"computedname4" : Symbol(D[["computedname4"]], Decl(emitClassDeclarationWithMethodInES6.ts, 11, 5)) +>"computedname4" : Symbol(D["computedname4"], Decl(emitClassDeclarationWithMethodInES6.ts, 11, 5)) static ["computedname5"](a: string) { } ->"computedname5" : Symbol(D[["computedname5"]], Decl(emitClassDeclarationWithMethodInES6.ts, 12, 34)) +>"computedname5" : Symbol(D["computedname5"], Decl(emitClassDeclarationWithMethodInES6.ts, 12, 34)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 13, 29)) static ["computedname6"](a: string): boolean { return true; } ->"computedname6" : Symbol(D[["computedname6"]], Decl(emitClassDeclarationWithMethodInES6.ts, 13, 43)) +>"computedname6" : Symbol(D["computedname6"], Decl(emitClassDeclarationWithMethodInES6.ts, 13, 43)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 14, 29)) static staticMethod() { diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties.ts b/tests/cases/fourslash/findAllRefsForComputedProperties.ts index 72c49104dedae..6587211b76d82 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties.ts @@ -14,13 +14,13 @@ const ranges = test.ranges(); const [r0, r1, r2] = ranges; -verify.referenceGroups(r0, [{ definition: '(property) I[["prop1"]]: () => void', ranges }]); +verify.referenceGroups(r0, [{ definition: '(property) I["prop1"]: () => void', ranges }]); verify.referenceGroups(r1, [ - { definition: '(property) I[["prop1"]]: () => void', ranges: [r0, r2] }, - { definition: '(property) C[["prop1"]]: any', ranges: [r1] } + { definition: '(property) I["prop1"]: () => void', ranges: [r0, r2] }, + { definition: '(property) C["prop1"]: any', ranges: [r1] } ]); verify.referenceGroups(r2, [ - { definition: '(property) I[["prop1"]]: () => void', ranges: [r0, r1] }, + { definition: '(property) I["prop1"]: () => void', ranges: [r0, r1] }, { definition: '(property) ["prop1"]: () => void', ranges: [r2] } ]); diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts index 4a7a17047ec79..ef28b2f9bd7ec 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts @@ -14,12 +14,12 @@ const ranges = test.ranges(); const [r0, r1, r2] = ranges; -verify.referenceGroups(r0, [{ definition: "(method) I[[42]](): void", ranges }]); +verify.referenceGroups(r0, [{ definition: "(method) I[42](): void", ranges }]); verify.referenceGroups(r1, [ - { definition: "(method) I[[42]](): void", ranges: [r0, r2] }, - { definition: "(property) C[[42]]: any", ranges: [r1] } + { definition: "(method) I[42](): void", ranges: [r0, r2] }, + { definition: "(property) C[42]: any", ranges: [r1] } ]); verify.referenceGroups(r2, [ - { definition: "(method) I[[42]](): void", ranges: [r0, r1] }, + { definition: "(method) I[42](): void", ranges: [r0, r1] }, { definition: '(property) ["42"]: () => void', ranges: [r2] } ]); From d8ae9c0e366a25a7fe55b8df35e5da848b3b2028 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 4 May 2017 14:40:03 -0700 Subject: [PATCH 08/43] Early support for unique symbol type --- src/compiler/checker.ts | 136 ++++++++++++++++++++++----- src/compiler/declarationEmitter.ts | 13 +-- src/compiler/diagnosticMessages.json | 9 ++ src/compiler/parser.ts | 21 ++++- src/compiler/types.ts | 46 +++++---- 5 files changed, 170 insertions(+), 55 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4491804c56d68..ea8269f57fd4a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2331,6 +2331,9 @@ namespace ts { if (type.flags & TypeFlags.BooleanLiteral) { return (type).intrinsicName === "true" ? createTrue() : createFalse(); } + if (type.flags & TypeFlags.Unique) { + return createToken(SyntaxKind.SymbolType); + } if (type.flags & TypeFlags.EnumLiteral) { const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); return createTypeReferenceNode(name, /*typeArguments*/ undefined); @@ -3080,6 +3083,11 @@ namespace ts { else if (getObjectFlags(type) & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { writeAnonymousType(type, nextFlags); } + else if (type.flags & TypeFlags.Unique) { + writeKeyword(writer, SyntaxKind.SymbolKeyword); + writePunctuation(writer, SyntaxKind.OpenParenToken); + writePunctuation(writer, SyntaxKind.CloseParenToken); + } else if (type.flags & TypeFlags.StringOrNumberLiteral) { writer.writeStringLiteral(literalTypeToString(type)); } @@ -5193,7 +5201,7 @@ namespace ts { resolveDynamicMembersOfNode(node, (node).members, symbolTable); break; case SyntaxKind.ObjectLiteralExpression: - resolveDynamicMembersOfNode(node, (node).properties, symbolTable); + resolveDynamicMembersOfNode(node, (node).properties, symbolTable); break; } } @@ -5234,9 +5242,10 @@ namespace ts { function resolveDynamicMember(symbolTable: SymbolTable, parent: Symbol, member: ClassElement | TypeElement | ObjectLiteralElement, includes: SymbolFlags, excludes: SymbolFlags) { Debug.assert(isComputedPropertyName(member.name)); const nameType = checkComputedPropertyName(member.name); - if (nameType.flags & TypeFlags.StringOrNumberLiteral) { - // TODO(rbuckton): ESSymbolLiteral - const memberName = (nameType).text; + if (nameType.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique)) { + const memberName = nameType.flags & TypeFlags.Unique + ? `__@@symbol@${nameType.symbol.id}@${nameType.symbol.name}` + : (nameType).text; let symbol = symbolTable.get(memberName); if (!symbol) { symbolTable.set(memberName, symbol = createSymbol(SymbolFlags.Dynamic, memberName)); @@ -5244,10 +5253,11 @@ namespace ts { const staticMember = parent.members && parent.members.get(memberName); if (symbol.flags & excludes || staticMember) { const declarations = staticMember ? concatenate(staticMember.declarations, symbol.declarations) : symbol.declarations; + const name = nameType.flags & TypeFlags.Unique ? `[${entityNameToString((member.name).expression)}]` : memberName; forEach(declarations, declaration => { - error(declaration.name || declaration, Diagnostics.Duplicate_identifier_0, memberName); + error(declaration.name || declaration, Diagnostics.Duplicate_identifier_0, name); }); - error(member.name || member, Diagnostics.Duplicate_identifier_0, memberName); + error(member.name || member, Diagnostics.Duplicate_identifier_0, name); symbol = createSymbol(SymbolFlags.Dynamic, memberName); } addDeclarationToSymbol(symbol, member, includes); @@ -5912,7 +5922,7 @@ namespace ts { t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : - t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : + t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : t.flags & TypeFlags.NonPrimitive ? emptyObjectType : t; } @@ -7404,7 +7414,7 @@ namespace ts { return getTypeOfSymbol(prop); } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbolLike)) { if (isTypeAny(objectType)) { return anyType; } @@ -7683,6 +7693,27 @@ namespace ts { return links.resolvedType; } + function getTypeFromSymbolTypeNode(node: SymbolTypeNode): Type { + const parent = node.parent; + if (parent.kind === SyntaxKind.VariableDeclaration || + parent.kind === SyntaxKind.PropertyDeclaration || + parent.kind === SyntaxKind.PropertySignature || + parent.kind === SyntaxKind.PropertyAssignment) { + const symbol = getSymbolOfNode(parent); + if (symbol) return getUniqueTypeForSymbol(symbol); + } + return esSymbolType; + } + + function getUniqueTypeForSymbol(symbol: Symbol) { + const links = getSymbolLinks(symbol); + if (!links.type) { + links.type = createType(TypeFlags.Unique); + links.type.symbol = symbol; + } + return links.type; + } + function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { const links = getNodeLinks(node); if (!links.resolvedType) { @@ -7753,6 +7784,8 @@ namespace ts { return getTypeFromLiteralTypeNode(node); case SyntaxKind.JSDocLiteralType: return getTypeFromLiteralTypeNode((node).literal); + case SyntaxKind.SymbolType: + return getTypeFromSymbolTypeNode(node); case SyntaxKind.TypeReference: case SyntaxKind.JSDocTypeReference: return getTypeFromTypeReference(node); @@ -8556,11 +8589,13 @@ namespace ts { if (source.flags & TypeFlags.StringLike && target.flags & TypeFlags.String) return true; if (source.flags & TypeFlags.NumberLike && target.flags & TypeFlags.Number) return true; if (source.flags & TypeFlags.BooleanLike && target.flags & TypeFlags.Boolean) return true; + if (source.flags & TypeFlags.ESSymbolLike && target.flags & TypeFlags.ESSymbol) return true; if (source.flags & TypeFlags.EnumLiteral && target.flags & TypeFlags.Enum && (source).baseType === target) return true; if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(source, target, errorReporter)) return true; if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true; if (source.flags & TypeFlags.Object && target.flags & TypeFlags.NonPrimitive) return true; + if (source.flags & TypeFlags.Unique || target.flags & TypeFlags.Unique) return false; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & TypeFlags.Any) return true; if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true; @@ -10772,7 +10807,7 @@ namespace ts { if (flags & TypeFlags.Null) { return TypeFacts.NullFacts; } - if (flags & TypeFlags.ESSymbol) { + if (flags & TypeFlags.ESSymbolLike) { return strictNullChecks ? TypeFacts.SymbolStrictFacts : TypeFacts.SymbolFacts; } if (flags & TypeFlags.NonPrimitive) { @@ -13130,7 +13165,7 @@ namespace ts { // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbolLike)) { error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -13174,7 +13209,7 @@ namespace ts { let offset = 0; for (let i = 0; i < node.properties.length; i++) { const memberDecl = node.properties[i]; - let member = memberDecl.symbol; + let member = getSymbolOfNode(memberDecl); if (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || isObjectLiteralMethod(memberDecl)) { @@ -13259,7 +13294,7 @@ namespace ts { checkNodeDeferred(memberDecl); } - if (hasDynamicName(memberDecl)) { + if (hasDynamicName(memberDecl) && !isLiteralDynamicName(memberDecl.name)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -14407,7 +14442,7 @@ namespace ts { } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & TypeFlags.ESSymbol) === 0) { + if ((expressionType.flags & TypeFlags.ESSymbolLike) === 0) { if (reportError) { error(expression, Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, getTextOfNode(expression)); } @@ -15011,7 +15046,7 @@ namespace ts { case SyntaxKind.ComputedPropertyName: const nameType = checkComputedPropertyName(element.name); - if (isTypeOfKind(nameType, TypeFlags.ESSymbol)) { + if (isTypeOfKind(nameType, TypeFlags.ESSymbolLike)) { return nameType; } else { @@ -15824,14 +15859,46 @@ namespace ts { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } - return getReturnTypeOfSignature(signature); + const returnType = getReturnTypeOfSignature(signature); + // Treat any call to the global 'Symbol' function that is part of a variable or property + // as a fresh unique symbol literal type. + if (returnType.flags & TypeFlags.ESSymbolLike && isSymbolOrSymbolForCall(node)) { + const parent = skipParentheses(node).parent; + if (parent.kind === SyntaxKind.VariableDeclaration || + parent.kind === SyntaxKind.PropertyDeclaration || + parent.kind === SyntaxKind.PropertyAssignment) { + const symbol = getSymbolOfNode(parent); + if (symbol) return getUniqueTypeForSymbol(symbol); + } + } + return returnType; + } + + function isSymbolOrSymbolForCall(node: Node) { + if (!isCallExpression(node)) return false; + let left = node.expression; + if (isPropertyAccessExpression(left) && left.name.text === "for") { + left = left.expression; + } + if (!isIdentifier(left) || left.text !== "Symbol") { + return false; + } + + // make sure `Symbol` is the global symbol + const globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + if (!globalESSymbol) { + return false; + } + + return globalESSymbol === resolveName(left, "Symbol", SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function isCommonJsRequire(node: Node) { if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { return false; } - // Make sure require is not a local function + + // Make sure require is not a local function const resolvedRequire = resolveName(node.expression, (node.expression).text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (!resolvedRequire) { // project does not contain symbol named 'require' - assume commonjs require @@ -16498,7 +16565,7 @@ namespace ts { case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, TypeFlags.ESSymbol)) { + if (maybeTypeOfKind(operandType, TypeFlags.ESSymbolLike)) { error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator)); } return numberType; @@ -16618,7 +16685,7 @@ namespace ts { // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbol))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbolLike))) { error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable | TypeFlags.NonPrimitive)) { @@ -17022,8 +17089,8 @@ namespace ts { // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { const offendingSymbolOperand = - maybeTypeOfKind(leftType, TypeFlags.ESSymbol) ? left : - maybeTypeOfKind(rightType, TypeFlags.ESSymbol) ? right : + maybeTypeOfKind(leftType, TypeFlags.ESSymbolLike) ? left : + maybeTypeOfKind(rightType, TypeFlags.ESSymbolLike) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); @@ -17303,7 +17370,7 @@ namespace ts { function getTypeOfExpression(node: Expression, cache?: boolean) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && !isSymbolOrSymbolForCall(node)) { const funcType = checkNonNullExpression((node).expression); const signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -18160,6 +18227,10 @@ namespace ts { checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } + function checkSymbolType(node: SymbolTypeNode) { + checkGrammarSymbolTypeNode(node); + } + function isPrivateWithinAmbient(node: Node): boolean { return (getModifierFlags(node) & ModifierFlags.Private) && isInAmbientContext(node); } @@ -21607,6 +21678,8 @@ namespace ts { return checkIndexedAccessType(node); case SyntaxKind.MappedType: return checkMappedType(node); + case SyntaxKind.SymbolType: + return checkSymbolType(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); case SyntaxKind.Block: @@ -22754,7 +22827,7 @@ namespace ts { else if (isTupleType(type)) { return TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeOfKind(type, TypeFlags.ESSymbol)) { + else if (isTypeOfKind(type, TypeFlags.ESSymbolLike)) { return TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -22840,9 +22913,8 @@ namespace ts { function isLiteralDynamicName(name: ComputedPropertyName) { name = getParseTreeNode(name, isComputedPropertyName); if (name) { - // TODO(rbuckton): ESSymbolLiteral const nameType = checkComputedPropertyName(name); - return (nameType.flags & TypeFlags.StringOrNumberLiteral) !== 0; + return (nameType.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique)) !== 0; } return false; } @@ -23897,10 +23969,24 @@ namespace ts { } } + function checkGrammarSymbolTypeNode(node: SymbolTypeNode) { + const parent = node.parent; + if (parent.kind !== SyntaxKind.VariableDeclaration && + parent.kind !== SyntaxKind.PropertyDeclaration && + parent.kind !== SyntaxKind.PropertySignature && + parent.kind !== SyntaxKind.PropertyAssignment) { + return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_are_only_allowed_on_variables_and_properties); + } + if (parent.kind === SyntaxKind.VariableDeclaration && + (parent).name.kind !== SyntaxKind.Identifier) { + return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); + } + } + function checkGrammarForNonSymbolComputedProperty(node: DeclarationName, message: DiagnosticMessage) { if (isDynamicName(node)) { if (!isEntityNameExpression((node).expression) || - (checkExpressionCached((node).expression).flags & TypeFlags.StringOrNumberLiteral) === 0) { + (checkExpressionCached((node).expression).flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique)) === 0) { return grammarErrorOnNode(node, message); } } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index ec123a7488d97..48b29c439824b 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -417,6 +417,8 @@ namespace ts { case SyntaxKind.ThisType: case SyntaxKind.LiteralType: return writeTextOfNode(currentText, type); + case SyntaxKind.SymbolType: + return write("symbol()"); case SyntaxKind.ExpressionWithTypeArguments: return emitExpressionWithTypeArguments(type); case SyntaxKind.TypeReference: @@ -1297,14 +1299,9 @@ namespace ts { function emitDynamicName(entityName: EntityNameExpression) { writer.getSymbolAccessibilityDiagnostic = getVariableDeclarationTypeVisibilityError; const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration); - if (visibilityResult.accessibility !== SymbolAccessibility.Accessible) { - resolver.writeTypeOfExpression(entityName, enclosingDeclaration, TypeFormatFlags.None, writer); - } - else { - handleSymbolAccessibilityError(visibilityResult); - recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); - writeTextOfNode(currentText, node.name); - } + handleSymbolAccessibilityError(visibilityResult); + recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); + writeTextOfNode(currentText, node.name); } function emitBindingPattern(bindingPattern: BindingPattern) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9dc6a7e583547..83b97c1a04c48 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -879,6 +879,15 @@ "category": "Error", "code": 1322 }, + "Unique 'symbol()' types are only allowed on variables and properties.": { + "category": "Error", + "code": 1323 + }, + "Unique 'symbol()' types may not be used on a variable declaration with a binding name.": { + "category": "Error", + "code": 1324 + }, + "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d355ff2458322..3c2f4dedadc1b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2499,6 +2499,19 @@ namespace ts { return token() === SyntaxKind.DotToken ? undefined : node; } + function parseSymbolType(): TypeNode | undefined { + const fullStart = scanner.getStartPos(); + parseExpected(SyntaxKind.SymbolKeyword); + if (token() === SyntaxKind.DotToken) return undefined; + if (parseOptional(SyntaxKind.OpenParenToken)) { + parseExpected(SyntaxKind.CloseParenToken); + return finishNode(createNode(SyntaxKind.SymbolType, fullStart)); + } + else { + return finishNode(createNode(SyntaxKind.SymbolKeyword, fullStart)); + } + } + function parseLiteralTypeNode(): LiteralTypeNode { const node = createNode(SyntaxKind.LiteralType); node.literal = parseSimpleUnaryExpression(); @@ -2516,13 +2529,15 @@ namespace ts { case SyntaxKind.StringKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: - case SyntaxKind.SymbolKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.ObjectKeyword: // If these are followed by a dot, then parse these out as a dotted type reference instead. - const node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return tryParse(parseKeywordAndNoDot) + || parseTypeReference(); + case SyntaxKind.SymbolKeyword: + return tryParse(parseSymbolType) + || parseTypeReference(); case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: case SyntaxKind.TrueKeyword: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f9fe5a849ce36..4c28598e0f84e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -242,6 +242,7 @@ namespace ts { IndexedAccessType, MappedType, LiteralType, + SymbolType, // Binding patterns ObjectBindingPattern, ArrayBindingPattern, @@ -406,7 +407,7 @@ namespace ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypePredicate, - LastTypeNode = LiteralType, + LastTypeNode = SymbolType, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = Unknown, @@ -959,6 +960,10 @@ namespace ts { literal: Expression; } + export interface SymbolTypeNode extends TypeNode { + kind: SyntaxKind.SymbolType; + } + export interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; /* @internal */ textSourceNode?: Identifier | StringLiteral | NumericLiteral; // Allows a StringLiteral to get its text from another node (used by transforms). @@ -2880,6 +2885,7 @@ namespace ts { exportsSomeValue?: boolean; // True if module exports some value (not just types) dynamicMembers?: SymbolTable; // Dynamic members with literal names resolved during check resolvedMembers?: SymbolTable; + uniqueType?: Type; // ESSymbol Unique type for a symbol. } /* @internal */ @@ -2974,31 +2980,32 @@ namespace ts { BooleanLiteral = 1 << 7, EnumLiteral = 1 << 8, ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6 - Void = 1 << 10, - Undefined = 1 << 11, - Null = 1 << 12, - Never = 1 << 13, // Never type - TypeParameter = 1 << 14, // Type parameter - Object = 1 << 15, // Object type - Union = 1 << 16, // Union (T | U) - Intersection = 1 << 17, // Intersection (T & U) - Index = 1 << 18, // keyof T - IndexedAccess = 1 << 19, // T[K] + Unique = 1 << 10, // symbol() + Void = 1 << 11, + Undefined = 1 << 12, + Null = 1 << 13, + Never = 1 << 14, // Never type + TypeParameter = 1 << 15, // Type parameter + Object = 1 << 16, // Object type + Union = 1 << 17, // Union (T | U) + Intersection = 1 << 18, // Intersection (T & U) + Index = 1 << 19, // keyof T + IndexedAccess = 1 << 20, // T[K] /* @internal */ - FreshLiteral = 1 << 20, // Fresh literal type + FreshLiteral = 1 << 21, // Fresh literal type /* @internal */ - ContainsWideningType = 1 << 21, // Type is or contains undefined or null widening type + ContainsWideningType = 1 << 22, // Type is or contains undefined or null widening type /* @internal */ - ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type + ContainsObjectLiteral = 1 << 23, // Type is or contains object literal type /* @internal */ - ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type - NonPrimitive = 1 << 24, // intrinsic object type + ContainsAnyFunctionType = 1 << 24, // Type is or contains object literal type + NonPrimitive = 1 << 25, // intrinsic object type /* @internal */ - JsxAttributes = 1 << 25, // Jsx attributes type + JsxAttributes = 1 << 26, // Jsx attributes type /* @internal */ Nullable = Undefined | Null, - Literal = StringLiteral | NumberLiteral | BooleanLiteral | EnumLiteral, + Literal = StringLiteral | NumberLiteral | BooleanLiteral | EnumLiteral | Unique, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, @@ -3011,6 +3018,7 @@ namespace ts { NumberLike = Number | NumberLiteral | Enum | EnumLiteral, BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, + ESSymbolLike = ESSymbol | Unique, UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess, @@ -3018,7 +3026,7 @@ namespace ts { // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | NonPrimitive, + Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | Unique | NonPrimitive, NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, From 83b5a750168a68f48865acdf128d44b78d04d677 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 4 May 2017 16:22:19 -0700 Subject: [PATCH 09/43] Add freshness to unique symbol types --- src/compiler/checker.ts | 159 ++++++++++++++++++++++++---------------- src/compiler/types.ts | 9 ++- 2 files changed, 103 insertions(+), 65 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ea8269f57fd4a..015c653532b86 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2332,7 +2332,9 @@ namespace ts { return (type).intrinsicName === "true" ? createTrue() : createFalse(); } if (type.flags & TypeFlags.Unique) { - return createToken(SyntaxKind.SymbolType); + return type.flags & TypeFlags.Fresh + ? createToken(SyntaxKind.SymbolType) + : createTypeQueryNodeFromSymbol(type.symbol); } if (type.flags & TypeFlags.EnumLiteral) { const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); @@ -2962,6 +2964,19 @@ namespace ts { } } + function appendPrototypeOfParentSymbolIfNeeded(parentSymbol: Symbol, symbol: Symbol, writer: SymbolWriter) { + if (parentSymbol.flags & SymbolFlags.Class && + symbol.flags & SymbolFlags.ClassMember && + symbol.valueDeclaration && + !(getDeclarationModifierFlagsFromSymbol(symbol) & ModifierFlags.Static)) { + const prototypeSymbol = parentSymbol.exports && parentSymbol.exports.get("prototype"); + if (prototypeSymbol) { + writePunctuation(writer, SyntaxKind.DotToken); + appendSymbolNameOnly(prototypeSymbol, writer); + } + } + } + /** * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope * Meaning needs to be specified if the enclosing declaration is given @@ -2980,6 +2995,7 @@ namespace ts { buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } + appendPrototypeOfParentSymbolIfNeeded(parentSymbol, symbol, writer); appendPropertyOrElementAccessForSymbol(symbol, writer); } else { @@ -3084,9 +3100,14 @@ namespace ts { writeAnonymousType(type, nextFlags); } else if (type.flags & TypeFlags.Unique) { - writeKeyword(writer, SyntaxKind.SymbolKeyword); - writePunctuation(writer, SyntaxKind.OpenParenToken); - writePunctuation(writer, SyntaxKind.CloseParenToken); + if (type.flags & TypeFlags.Fresh) { + writeKeyword(writer, SyntaxKind.SymbolKeyword); + writePunctuation(writer, SyntaxKind.OpenParenToken); + writePunctuation(writer, SyntaxKind.CloseParenToken); + } + else { + writeTypeOfSymbol(type.symbol, flags); + } } else if (type.flags & TypeFlags.StringOrNumberLiteral) { writer.writeStringLiteral(literalTypeToString(type)); @@ -3207,10 +3228,10 @@ namespace ts { // Always use 'typeof T' for type of class, enum, and module objects if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule)) { - writeTypeOfSymbol(type, flags); + writeTypeOfSymbol(type.symbol, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeOfSymbol(type, flags); + writeTypeOfSymbol(type.symbol, flags); } else if (contains(symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name @@ -3255,10 +3276,10 @@ namespace ts { } } - function writeTypeOfSymbol(type: ObjectType, typeFormatFlags?: TypeFormatFlags) { + function writeTypeOfSymbol(symbol: Symbol, typeFormatFlags?: TypeFormatFlags) { writeKeyword(writer, SyntaxKind.TypeOfKeyword); writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags); + buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags); } function writePropertyWithModifiers(prop: Symbol) { @@ -4335,6 +4356,12 @@ namespace ts { if (!popTypeResolution()) { type = reportCircularityError(symbol); } + + // If the type is a fresh, unique symbol type and is not the type for this symbol, get its regular type + if (type.flags & TypeFlags.Unique && type.flags & TypeFlags.Fresh && type.symbol !== symbol) { + type = (type).regularType; + } + links.type = type; } return links.type; @@ -7190,7 +7217,7 @@ namespace ts { const remove = t.flags & TypeFlags.StringLiteral && types.containsString || t.flags & TypeFlags.NumberLiteral && types.containsNumber || - t.flags & TypeFlags.StringOrNumberLiteral && t.flags & TypeFlags.FreshLiteral && containsType(types, (t).regularType); + t.flags & TypeFlags.StringOrNumberLiteral && t.flags & TypeFlags.Fresh && containsType(types, (t).regularType); if (remove) { orderedRemoveItemAt(types, i); } @@ -7660,20 +7687,22 @@ namespace ts { return type; } - function getFreshTypeOfLiteralType(type: Type) { - if (type.flags & TypeFlags.StringOrNumberLiteral && !(type.flags & TypeFlags.FreshLiteral)) { - if (!(type).freshType) { - const freshType = createLiteralType(type.flags | TypeFlags.FreshLiteral, (type).text); - freshType.regularType = type; - (type).freshType = freshType; + function getFreshTypeOfType(type: Type) { + if (type.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique) && !(type.flags & TypeFlags.Fresh)) { + if (!(type).freshType) { + const freshType = type.flags & TypeFlags.Unique + ? createUniqueType(type.symbol, TypeFlags.Fresh) + : createLiteralType(type.flags | TypeFlags.Fresh, (type).text); + freshType.regularType = type; + (type).freshType = freshType; } - return (type).freshType; + return (type).freshType; } return type; } - function getRegularTypeOfLiteralType(type: Type) { - return type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral ? (type).regularType : type; + function getRegularTypeOfType(type: Type) { + return type.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique) && type.flags & TypeFlags.Fresh ? (type).regularType : type; } function getLiteralTypeForText(flags: TypeFlags, text: string) { @@ -7688,14 +7717,14 @@ namespace ts { function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal)); + links.resolvedType = getRegularTypeOfType(checkExpression(node.literal)); } return links.resolvedType; } function getTypeFromSymbolTypeNode(node: SymbolTypeNode): Type { const parent = node.parent; - if (parent.kind === SyntaxKind.VariableDeclaration || + if (parent.kind === SyntaxKind.VariableDeclaration || parent.kind === SyntaxKind.PropertyDeclaration || parent.kind === SyntaxKind.PropertySignature || parent.kind === SyntaxKind.PropertyAssignment) { @@ -7705,13 +7734,19 @@ namespace ts { return esSymbolType; } + function getRegularTypeOfUniqueType(type: Type) { + return type.flags & TypeFlags.Unique && type.flags & TypeFlags.Fresh ? (type).regularType : type; + } + + function createUniqueType(symbol: Symbol, flags?: TypeFlags) { + const type = createType(TypeFlags.Unique | flags); + type.symbol = symbol; + return type; + } + function getUniqueTypeForSymbol(symbol: Symbol) { const links = getSymbolLinks(symbol); - if (!links.type) { - links.type = createType(TypeFlags.Unique); - links.type.symbol = symbol; - } - return links.type; + return links.type || (links.type = createUniqueType(symbol)); } function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { @@ -8615,12 +8650,8 @@ namespace ts { } function isTypeRelatedTo(source: Type, target: Type, relation: Map) { - if (source.flags & TypeFlags.StringOrNumberLiteral && source.flags & TypeFlags.FreshLiteral) { - source = (source).regularType; - } - if (target.flags & TypeFlags.StringOrNumberLiteral && target.flags & TypeFlags.FreshLiteral) { - target = (target).regularType; - } + source = getRegularTypeOfType(source); + target = getRegularTypeOfType(target); if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } @@ -8745,12 +8776,8 @@ namespace ts { */ function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { let result: Ternary; - if (source.flags & TypeFlags.StringOrNumberLiteral && source.flags & TypeFlags.FreshLiteral) { - source = (source).regularType; - } - if (target.flags & TypeFlags.StringOrNumberLiteral && target.flags & TypeFlags.FreshLiteral) { - target = (target).regularType; - } + source = getRegularTypeOfType(source); + target = getRegularTypeOfType(target); // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; @@ -8760,7 +8787,7 @@ namespace ts { if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True; - if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) { + if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.Fresh) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -9865,8 +9892,8 @@ namespace ts { } function getWidenedLiteralType(type: Type): Type { - return type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : - type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : + return type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.Fresh ? stringType : + type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.Fresh ? numberType : type.flags & TypeFlags.BooleanLiteral ? booleanType : type.flags & TypeFlags.EnumLiteral ? (type).baseType : type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(sameMap((type).types, getWidenedLiteralType)) : @@ -9962,7 +9989,7 @@ namespace ts { * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type: Type): Type { - if (!(getObjectFlags(type) & ObjectFlags.ObjectLiteral && type.flags & TypeFlags.FreshLiteral)) { + if (!(getObjectFlags(type) & ObjectFlags.ObjectLiteral && type.flags & TypeFlags.Fresh)) { return type; } const regularType = (type).regularType; @@ -9978,7 +10005,7 @@ namespace ts { resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~TypeFlags.FreshLiteral; + regularNew.flags = resolved.flags & ~TypeFlags.Fresh; regularNew.objectFlags |= ObjectFlags.ObjectLiteral; (type).regularType = regularNew; return regularNew; @@ -10981,7 +11008,7 @@ namespace ts { function getTypeOfSwitchClause(clause: CaseClause | DefaultClause) { if (clause.kind === SyntaxKind.CaseClause) { - const caseType = getRegularTypeOfLiteralType(getTypeOfExpression((clause).expression)); + const caseType = getRegularTypeOfType(getTypeOfExpression((clause).expression)); return isUnitType(caseType) ? caseType : undefined; } return neverType; @@ -11596,8 +11623,8 @@ namespace ts { return narrowedType.flags & TypeFlags.Never ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { - const regularType = getRegularTypeOfLiteralType(valueType); - return filterType(type, t => getRegularTypeOfLiteralType(t) !== regularType); + const regularType = getRegularTypeOfType(valueType); + return filterType(type, t => getRegularTypeOfType(t) !== regularType); } return type; } @@ -11654,7 +11681,7 @@ namespace ts { if (!hasDefaultClause) { return caseType; } - const defaultType = filterType(type, t => !(isUnitType(t) && contains(switchTypes, getRegularTypeOfLiteralType(t)))); + const defaultType = filterType(type, t => !(isUnitType(t) && contains(switchTypes, getRegularTypeOfType(t)))); return caseType.flags & TypeFlags.Never ? defaultType : getUnionType([caseType, defaultType]); } @@ -13341,7 +13368,7 @@ namespace ts { const stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; const numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; + const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.Fresh; result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); result.objectFlags |= ObjectFlags.ObjectLiteral; if (patternWithComputedProperties) { @@ -13517,7 +13544,7 @@ namespace ts { */ function createJsxAttributesType(symbol: Symbol, attributesTable: Map) { const result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; + const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.Fresh; result.flags |= TypeFlags.JsxAttributes | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag; result.objectFlags |= ObjectFlags.ObjectLiteral; return result; @@ -15860,15 +15887,15 @@ namespace ts { } const returnType = getReturnTypeOfSignature(signature); - // Treat any call to the global 'Symbol' function that is part of a variable or property + // Treat any call to the global 'Symbol' function that is part of a variable or property // as a fresh unique symbol literal type. if (returnType.flags & TypeFlags.ESSymbolLike && isSymbolOrSymbolForCall(node)) { const parent = skipParentheses(node).parent; - if (parent.kind === SyntaxKind.VariableDeclaration || + if (parent.kind === SyntaxKind.VariableDeclaration || parent.kind === SyntaxKind.PropertyDeclaration || parent.kind === SyntaxKind.PropertyAssignment) { const symbol = getSymbolOfNode(parent); - if (symbol) return getUniqueTypeForSymbol(symbol); + if (symbol) return getFreshTypeOfType(getUniqueTypeForSymbol(symbol)); } } return returnType; @@ -15897,7 +15924,7 @@ namespace ts { if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { return false; } - + // Make sure require is not a local function const resolvedRequire = resolveName(node.expression, (node.expression).text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (!resolvedRequire) { @@ -16122,7 +16149,7 @@ namespace ts { const functionFlags = getFunctionFlags(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { - type = checkExpressionCached(func.body, checkMode); + type = getRegularTypeOfUniqueType(checkExpressionCached(func.body, checkMode)); if (functionFlags & FunctionFlags.Async) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -16162,7 +16189,7 @@ namespace ts { } } // Return a union of the return expression types. - type = getUnionType(types, /*subtypeReduction*/ true); + type = getUnionType(map(types, getRegularTypeOfUniqueType), /*subtypeReduction*/ true); if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function type = functionFlags & FunctionFlags.Async @@ -16175,11 +16202,12 @@ namespace ts { reportErrorsFromWidening(func, type); } - if (isUnitType(type) && - !(contextualSignature && + if (isUnitType(type)) { + if (!(contextualSignature && isLiteralContextualType( contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { - type = getWidenedLiteralType(type); + type = getWidenedLiteralType(type); + } } const widenedType = getWidenedType(type); @@ -16228,7 +16256,7 @@ namespace ts { if (!switchTypes.length) { return false; } - return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); + return eachTypeContainedIn(mapType(type, getRegularTypeOfType), switchTypes); } function functionHasImplicitReturn(func: FunctionLikeDeclaration) { @@ -16558,7 +16586,7 @@ namespace ts { return silentNeverType; } if (node.operator === SyntaxKind.MinusToken && node.operand.kind === SyntaxKind.NumericLiteral) { - return getFreshTypeOfLiteralType(getLiteralTypeForText(TypeFlags.NumberLiteral, "" + -(node.operand).text)); + return getFreshTypeOfType(getLiteralTypeForText(TypeFlags.NumberLiteral, "" + -(node.operand).text)); } switch (node.operator) { case SyntaxKind.PlusToken: @@ -17234,9 +17262,9 @@ namespace ts { } switch (node.kind) { case SyntaxKind.StringLiteral: - return getFreshTypeOfLiteralType(getLiteralTypeForText(TypeFlags.StringLiteral, (node).text)); + return getFreshTypeOfType(getLiteralTypeForText(TypeFlags.StringLiteral, (node).text)); case SyntaxKind.NumericLiteral: - return getFreshTypeOfLiteralType(getLiteralTypeForText(TypeFlags.NumberLiteral, (node).text)); + return getFreshTypeOfType(getLiteralTypeForText(TypeFlags.NumberLiteral, (node).text)); case SyntaxKind.TrueKeyword: return trueType; case SyntaxKind.FalseKeyword: @@ -22422,7 +22450,7 @@ namespace ts { if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { expr = expr.parent; } - return getRegularTypeOfLiteralType(getTypeOfExpression(expr)); + return getRegularTypeOfType(getTypeOfExpression(expr)); } /** @@ -22847,6 +22875,9 @@ namespace ts { let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (type.flags & TypeFlags.Unique && type.symbol !== symbol) { + type = getRegularTypeOfUniqueType(type); + } if (flags & TypeFormatFlags.AddUndefined) { type = includeFalsyTypes(type, TypeFlags.Undefined); } @@ -22922,7 +22953,7 @@ namespace ts { function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { if (isConst(node)) { const type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral); + return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.Fresh); } return false; } @@ -23972,7 +24003,7 @@ namespace ts { function checkGrammarSymbolTypeNode(node: SymbolTypeNode) { const parent = node.parent; if (parent.kind !== SyntaxKind.VariableDeclaration && - parent.kind !== SyntaxKind.PropertyDeclaration && + parent.kind !== SyntaxKind.PropertyDeclaration && parent.kind !== SyntaxKind.PropertySignature && parent.kind !== SyntaxKind.PropertyAssignment) { return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_are_only_allowed_on_variables_and_properties); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4c28598e0f84e..7771808c267f0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2992,7 +2992,7 @@ namespace ts { Index = 1 << 19, // keyof T IndexedAccess = 1 << 20, // T[K] /* @internal */ - FreshLiteral = 1 << 21, // Fresh literal type + Fresh = 1 << 21, // Fresh literal or unique type /* @internal */ ContainsWideningType = 1 << 22, // Type is or contains undefined or null widening type /* @internal */ @@ -3060,6 +3060,13 @@ namespace ts { regularType?: LiteralType; // Regular version of type } + // Unique symbol types (TypeFlags.Unique) + export interface UniqueType extends Type { + symbol: Symbol; + freshType?: UniqueType; // Fresh version of the type + regularType?: UniqueType; // Regular version of the type + } + // Enum types (TypeFlags.Enum) export interface EnumType extends Type { memberTypes: EnumLiteralType[]; From 57674dd2429e865093e67bec27535dead6a8e419 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 4 May 2017 18:23:17 -0700 Subject: [PATCH 10/43] Emit dynamic names for object literal types --- src/compiler/checker.ts | 25 ++++++++--- src/compiler/declarationEmitter.ts | 11 ++--- src/compiler/types.ts | 2 + src/compiler/utilities.ts | 2 +- src/services/utilities.ts | 2 +- tests/baselines/reference/dynamicNames.js | 6 +-- .../baselines/reference/dynamicNames.symbols | 27 +++++------- tests/baselines/reference/dynamicNames.types | 44 +++++++++---------- .../reference/dynamicNamesErrors.errors.txt | 24 ++++++---- .../baselines/reference/dynamicNamesErrors.js | 9 +++- tests/cases/compiler/dynamicNames.ts | 3 +- tests/cases/compiler/dynamicNamesErrors.ts | 10 +++-- 12 files changed, 90 insertions(+), 75 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4491804c56d68..0b42dd1b3cf7b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2897,9 +2897,6 @@ namespace ts { } function getNameOfSymbol(symbol: Symbol): string { - if (symbol.flags & SymbolFlags.Dynamic) { - return `"${escapeString(unescapeIdentifier(symbol.name))}"`; - } if (symbol.declarations && symbol.declarations.length) { const declaration = symbol.declarations[0]; if (declaration.name) { @@ -3258,6 +3255,9 @@ namespace ts { writeKeyword(writer, SyntaxKind.ReadonlyKeyword); writeSpace(writer); } + if (prop.flags & SymbolFlags.Dynamic && (prop).dynamicSource) { + writer.trackSymbol((prop).dynamicSource, enclosingDeclaration, SymbolFlags.Value); + } buildSymbolDisplay(prop, writer); if (prop.flags & SymbolFlags.Optional) { writePunctuation(writer, SyntaxKind.QuestionToken); @@ -5193,7 +5193,7 @@ namespace ts { resolveDynamicMembersOfNode(node, (node).members, symbolTable); break; case SyntaxKind.ObjectLiteralExpression: - resolveDynamicMembersOfNode(node, (node).properties, symbolTable); + resolveDynamicMembersOfNode(node, (node).properties, symbolTable); break; } } @@ -13191,7 +13191,20 @@ namespace ts { } typeFlags |= type.flags; - const prop = createSymbol(SymbolFlags.Property | member.flags, member.name); + + let prop: TransientSymbol; + if (hasDynamicName(memberDecl) && isEntityNameExpression((memberDecl.name).expression)) { + const nameType = checkComputedPropertyName(memberDecl.name); + if (nameType && nameType.flags & TypeFlags.StringOrNumberLiteral) { + prop = createSymbol(SymbolFlags.Property | SymbolFlags.Dynamic | member.flags, (nameType).text); + prop.dynamicSource = resolveEntityName((memberDecl.name).expression, SymbolFlags.Value); + } + } + + if (!prop) { + prop = createSymbol(SymbolFlags.Property | member.flags, member.name); + } + if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. @@ -13259,7 +13272,7 @@ namespace ts { checkNodeDeferred(memberDecl); } - if (hasDynamicName(memberDecl)) { + if (hasDynamicName(memberDecl) && !(member && member.flags & SymbolFlags.Dynamic)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index ec123a7488d97..e4fb1cf976065 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -1297,14 +1297,9 @@ namespace ts { function emitDynamicName(entityName: EntityNameExpression) { writer.getSymbolAccessibilityDiagnostic = getVariableDeclarationTypeVisibilityError; const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration); - if (visibilityResult.accessibility !== SymbolAccessibility.Accessible) { - resolver.writeTypeOfExpression(entityName, enclosingDeclaration, TypeFormatFlags.None, writer); - } - else { - handleSymbolAccessibilityError(visibilityResult); - recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); - writeTextOfNode(currentText, node.name); - } + handleSymbolAccessibilityError(visibilityResult); + recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); + writeTextOfNode(currentText, node.name); } function emitBindingPattern(bindingPattern: BindingPattern) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f9fe5a849ce36..d8a4cdc651bb5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2610,6 +2610,7 @@ namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; reportIllegalExtends(): void; + } export const enum TypeFormatFlags { @@ -2880,6 +2881,7 @@ namespace ts { exportsSomeValue?: boolean; // True if module exports some value (not just types) dynamicMembers?: SymbolTable; // Dynamic members with literal names resolved during check resolvedMembers?: SymbolTable; + dynamicSource?: Symbol; } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5314bdacb436e..f1ee91acd82c8 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -68,7 +68,7 @@ namespace ts { clear: () => str = "", trackSymbol: noop, reportInaccessibleThisError: noop, - reportIllegalExtends: noop + reportIllegalExtends: noop, }; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index e884b342feff1..43b67b0dd5fe8 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1174,7 +1174,7 @@ namespace ts { clear: resetWriter, trackSymbol: noop, reportInaccessibleThisError: noop, - reportIllegalExtends: noop + reportIllegalExtends: noop, }; function writeIndent() { diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index 173c02b444821..e4a661d6d3f02 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -3,7 +3,6 @@ //// [module.ts] export const c0 = "a"; export const c1 = 1; -const c2 = "a"; export interface T0 { [c0]: number; [c1]: string; @@ -15,7 +14,7 @@ export declare class T1 implements T2 { export declare class T2 extends T1 { } export declare type T3 = { - [c2]: number; + [c0]: number; [c1]: string; }; @@ -107,7 +106,6 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; Object.defineProperty(exports, "__esModule", { value: true }); exports.c0 = "a"; exports.c1 = 1; -const c2 = "a"; //// [main.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -158,7 +156,7 @@ export declare class T1 implements T2 { export declare class T2 extends T1 { } export declare type T3 = { - "a": number; + [c0]: number; [c1]: string; }; //// [main.d.ts] diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index 12dd6576b740c..1663172d125bd 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -5,11 +5,8 @@ export const c0 = "a"; export const c1 = 1; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) -const c2 = "a"; ->c2 : Symbol(c2, Decl(module.ts, 2, 5)) - export interface T0 { ->T0 : Symbol(T0, Decl(module.ts, 2, 15)) +>T0 : Symbol(T0, Decl(module.ts, 1, 20)) [c0]: number; >c0 : Symbol(c0, Decl(module.ts, 0, 12)) @@ -18,8 +15,8 @@ export interface T0 { >c1 : Symbol(c1, Decl(module.ts, 1, 12)) } export declare class T1 implements T2 { ->T1 : Symbol(T1, Decl(module.ts, 6, 1)) ->T2 : Symbol(T2, Decl(module.ts, 10, 1)) +>T1 : Symbol(T1, Decl(module.ts, 5, 1)) +>T2 : Symbol(T2, Decl(module.ts, 9, 1)) [c0]: number; >c0 : Symbol(c0, Decl(module.ts, 0, 12)) @@ -28,14 +25,14 @@ export declare class T1 implements T2 { >c1 : Symbol(c1, Decl(module.ts, 1, 12)) } export declare class T2 extends T1 { ->T2 : Symbol(T2, Decl(module.ts, 10, 1)) ->T1 : Symbol(T1, Decl(module.ts, 6, 1)) +>T2 : Symbol(T2, Decl(module.ts, 9, 1)) +>T1 : Symbol(T1, Decl(module.ts, 5, 1)) } export declare type T3 = { ->T3 : Symbol(T3, Decl(module.ts, 12, 1)) +>T3 : Symbol(T3, Decl(module.ts, 11, 1)) - [c2]: number; ->c2 : Symbol(c2, Decl(module.ts, 2, 5)) + [c0]: number; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) [c1]: string; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) @@ -199,22 +196,22 @@ let t3: T3; let t0_1: M.T0; >t0_1 : Symbol(t0_1, Decl(main.ts, 60, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T0 : Symbol(T0, Decl(module.ts, 2, 15)) +>T0 : Symbol(T0, Decl(module.ts, 1, 20)) let t1_1: M.T1; >t1_1 : Symbol(t1_1, Decl(main.ts, 61, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T1 : Symbol(T1, Decl(module.ts, 6, 1)) +>T1 : Symbol(T1, Decl(module.ts, 5, 1)) let t2_1: M.T2; >t2_1 : Symbol(t2_1, Decl(main.ts, 62, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T2 : Symbol(T2, Decl(module.ts, 10, 1)) +>T2 : Symbol(T2, Decl(module.ts, 9, 1)) let t3_1: M.T3; >t3_1 : Symbol(t3_1, Decl(main.ts, 63, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T3 : Symbol(T3, Decl(module.ts, 12, 1)) +>T3 : Symbol(T3, Decl(module.ts, 11, 1)) let t4: N.T4; >t4 : Symbol(t4, Decl(main.ts, 64, 3)) diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index f9391d417c441..6a6ce65416ff4 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -7,10 +7,6 @@ export const c1 = 1; >c1 : 1 >1 : 1 -const c2 = "a"; ->c2 : "a" ->"a" : "a" - export interface T0 { >T0 : T0 @@ -37,8 +33,8 @@ export declare class T2 extends T1 { export declare type T3 = { >T3 : T3 - [c2]: number; ->c2 : "a" + [c0]: number; +>c0 : "a" [c1]: string; >c1 : 1 @@ -100,7 +96,7 @@ namespace N { >T5 : T5 } export declare type T7 = { ->T7 : { "a": number; "1": string; } +>T7 : { [N.c2]: number; [N.c3]: string; } [N.c2]: number; >N.c2 : "a" @@ -147,7 +143,7 @@ declare class T10 extends T9 { >T9 : T9 } declare type T11 = { ->T11 : { "a": number; "1": string; } +>T11 : { [c4]: number; [c5]: string; } [c4]: number; >c4 : "a" @@ -239,9 +235,9 @@ let t6: N.T6; >T6 : N.T6 let t7: N.T7; ->t7 : { "a": number; "1": string; } +>t7 : { [N.c2]: number; [N.c3]: string; } >N : any ->T7 : { "a": number; "1": string; } +>T7 : { [N.c2]: number; [N.c3]: string; } let t8: T8; >t8 : T8 @@ -256,8 +252,8 @@ let t10: T10; >T10 : T10 let t11: T11; ->t11 : { "a": number; "1": string; } ->T11 : { "a": number; "1": string; } +>t11 : { [c4]: number; [c5]: string; } +>T11 : { [c4]: number; [c5]: string; } let t12: T12; >t12 : T12 @@ -329,13 +325,13 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { "a": number; "1": string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { [N.c2]: number; [N.c3]: string; } >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { "a": number; "1": string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { [N.c2]: number; [N.c3]: string; } >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7 : { "a": number; "1": string; } +>t4 = t5, t4 = t6, t4 = t7 : { [N.c2]: number; [N.c3]: string; } >t4 = t5, t4 = t6 : N.T6 >t4 = t5 : N.T5 >t4 : N.T4 @@ -343,35 +339,35 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t6 : N.T6 >t4 : N.T4 >t6 : N.T6 ->t4 = t7 : { "a": number; "1": string; } +>t4 = t7 : { [N.c2]: number; [N.c3]: string; } >t4 : N.T4 ->t7 : { "a": number; "1": string; } +>t7 : { [N.c2]: number; [N.c3]: string; } >t5 = t4 : N.T4 >t5 : N.T5 >t4 : N.T4 >t5 = t6 : N.T6 >t5 : N.T5 >t6 : N.T6 ->t5 = t7 : { "a": number; "1": string; } +>t5 = t7 : { [N.c2]: number; [N.c3]: string; } >t5 : N.T5 ->t7 : { "a": number; "1": string; } +>t7 : { [N.c2]: number; [N.c3]: string; } >t6 = t4 : N.T4 >t6 : N.T6 >t4 : N.T4 >t6 = t5 : N.T5 >t6 : N.T6 >t5 : N.T5 ->t6 = t7 : { "a": number; "1": string; } +>t6 = t7 : { [N.c2]: number; [N.c3]: string; } >t6 : N.T6 ->t7 : { "a": number; "1": string; } +>t7 : { [N.c2]: number; [N.c3]: string; } >t7 = t4 : N.T4 ->t7 : { "a": number; "1": string; } +>t7 : { [N.c2]: number; [N.c3]: string; } >t4 : N.T4 >t7 = t5 : N.T5 ->t7 : { "a": number; "1": string; } +>t7 : { [N.c2]: number; [N.c3]: string; } >t5 : N.T5 >t7 = t6 : N.T6 ->t7 : { "a": number; "1": string; } +>t7 : { [N.c2]: number; [N.c3]: string; } >t6 : N.T6 t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index 90e33b02736eb..124f9746757db 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -1,15 +1,16 @@ tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2300: Duplicate identifier '1'. tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2300: Duplicate identifier '1'. tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2711: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. -tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T2' is not assignable to type 'T1'. - Types of property '"1"' are incompatible. +tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'. + Types of property '[c0]' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/dynamicNamesErrors.ts(26,1): error TS2322: Type 'T1' is not assignable to type 'T2'. - Types of property '"1"' are incompatible. +tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not assignable to type 'T2'. + Types of property '[c0]' are incompatible. Type 'number' is not assignable to type 'string'. +tests/cases/compiler/dynamicNamesErrors.ts(28,6): error TS4033: Property '[c0]' of exported interface has or is using private name 'c0'. -==== tests/cases/compiler/dynamicNamesErrors.ts (5 errors) ==== +==== tests/cases/compiler/dynamicNamesErrors.ts (6 errors) ==== const c0 = "1"; const c1 = 1; @@ -37,16 +38,21 @@ tests/cases/compiler/dynamicNamesErrors.ts(26,1): error TS2322: Type 'T1' is not !!! error TS2711: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. } - let t1: T1; let t2: T2; t1 = t2; ~~ !!! error TS2322: Type 'T2' is not assignable to type 'T1'. -!!! error TS2322: Types of property '"1"' are incompatible. +!!! error TS2322: Types of property '[c0]' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. t2 = t1; ~~ !!! error TS2322: Type 'T1' is not assignable to type 'T2'. -!!! error TS2322: Types of property '"1"' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Types of property '[c0]' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + export interface T4 { + [c0]: number; + ~~ +!!! error TS4033: Property '[c0]' of exported interface has or is using private name 'c0'. + } \ No newline at end of file diff --git a/tests/baselines/reference/dynamicNamesErrors.js b/tests/baselines/reference/dynamicNamesErrors.js index 186ae8870d7ab..ec4fb8114cbf2 100644 --- a/tests/baselines/reference/dynamicNamesErrors.js +++ b/tests/baselines/reference/dynamicNamesErrors.js @@ -20,13 +20,18 @@ interface T3 { [c1]: string; } - let t1: T1; let t2: T2; t1 = t2; -t2 = t1; +t2 = t1; + +export interface T4 { + [c0]: number; +} //// [dynamicNamesErrors.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const c0 = "1"; const c1 = 1; let t1; diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index 473d5bc3a8d23..6330a7b304421 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -4,7 +4,6 @@ // @filename: module.ts export const c0 = "a"; export const c1 = 1; -const c2 = "a"; export interface T0 { [c0]: number; [c1]: string; @@ -16,7 +15,7 @@ export declare class T1 implements T2 { export declare class T2 extends T1 { } export declare type T3 = { - [c2]: number; + [c0]: number; [c1]: string; }; diff --git a/tests/cases/compiler/dynamicNamesErrors.ts b/tests/cases/compiler/dynamicNamesErrors.ts index c819619a58193..cb8377677327a 100644 --- a/tests/cases/compiler/dynamicNamesErrors.ts +++ b/tests/cases/compiler/dynamicNamesErrors.ts @@ -1,5 +1,6 @@ // @target: esnext - +// @module: commonjs +// @declaration: true const c0 = "1"; const c1 = 1; @@ -21,8 +22,11 @@ interface T3 { [c1]: string; } - let t1: T1; let t2: T2; t1 = t2; -t2 = t1; \ No newline at end of file +t2 = t1; + +export interface T4 { + [c0]: number; +} \ No newline at end of file From fe414a28235d6cea39a1047125e74da865f5c75b Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 5 May 2017 17:22:56 -0700 Subject: [PATCH 11/43] Ensure we get the correct symbol for nodes, clean up --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 334 +++++++++------- src/compiler/diagnosticMessages.json | 4 + src/compiler/parser.ts | 4 +- src/compiler/types.ts | 15 +- src/compiler/utilities.ts | 12 + tests/baselines/reference/dynamicNames.js | 61 ++- .../baselines/reference/dynamicNames.symbols | 365 +++++++++++------- tests/baselines/reference/dynamicNames.types | 134 +++++-- .../reference/dynamicNamesErrors.errors.txt | 8 +- tests/cases/compiler/dynamicNames.ts | 33 +- 11 files changed, 626 insertions(+), 346 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 27b3067278c2b..3d27a53b09938 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -221,7 +221,7 @@ namespace ts { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } - } + } } // Should not be called on a declaration with a computed property name, diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a2aa0cb2ec3df..0775dcea29445 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -27,6 +27,9 @@ namespace ts { return symbol.id; } + type LateBoundName = ComputedPropertyName & { expression: EntityNameExpression; }; + type LateBoundDeclaration = Declaration & { name: LateBoundName; }; + export function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker { // Cancellation that controls whether or not we can cancel in the middle of type checking. // In general cancelling is *not* safe for the type checker. We might be in the middle of @@ -1815,11 +1818,11 @@ namespace ts { } function getSymbolOfNode(node: Node): Symbol { - return getMergedSymbol(node.symbol && node.symbol.name === "__computed" && node.id && getNodeLinks(node).resolvedSymbol || node.symbol); + return getMergedSymbol(getLateBoundSymbol(node.symbol)); } function getParentOfSymbol(symbol: Symbol): Symbol { - return getMergedSymbol(symbol.parent); + return getMergedSymbol(getLateBoundSymbol(symbol.parent)); } function getExportSymbolOfValueSymbolIfExported(symbol: Symbol): Symbol { @@ -2961,19 +2964,6 @@ namespace ts { } } - function appendPrototypeOfParentSymbolIfNeeded(parentSymbol: Symbol, symbol: Symbol, writer: SymbolWriter) { - if (parentSymbol.flags & SymbolFlags.Class && - symbol.flags & SymbolFlags.ClassMember && - symbol.valueDeclaration && - !(getDeclarationModifierFlagsFromSymbol(symbol) & ModifierFlags.Static)) { - const prototypeSymbol = parentSymbol.exports && parentSymbol.exports.get("prototype"); - if (prototypeSymbol) { - writePunctuation(writer, SyntaxKind.DotToken); - appendSymbolNameOnly(prototypeSymbol, writer); - } - } - } - /** * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope * Meaning needs to be specified if the enclosing declaration is given @@ -2992,7 +2982,6 @@ namespace ts { buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - appendPrototypeOfParentSymbolIfNeeded(parentSymbol, symbol, writer); appendPropertyOrElementAccessForSymbol(symbol, writer); } else { @@ -3284,8 +3273,12 @@ namespace ts { writeKeyword(writer, SyntaxKind.ReadonlyKeyword); writeSpace(writer); } - if (prop.flags & SymbolFlags.Dynamic && (prop).dynamicSource) { - writer.trackSymbol((prop).dynamicSource, enclosingDeclaration, SymbolFlags.Value); + if (prop.flags & SymbolFlags.Late) { + const decl = firstOrUndefined(prop.declarations); + const name = hasLateBoundName(decl) && resolveEntityName(decl.name.expression, SymbolFlags.Value); + if (name) { + writer.trackSymbol(name, enclosingDeclaration, SymbolFlags.Value); + } } buildSymbolDisplay(prop, writer); if (prop.flags & SymbolFlags.Optional) { @@ -4104,8 +4097,8 @@ namespace ts { if (declaration.kind === SyntaxKind.Parameter) { const func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === SyntaxKind.SetAccessor && !hasDynamicName(func)) { - const getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); + if (func.kind === SyntaxKind.SetAccessor && !hasUnboundDynamicName(func)) { + const getter = getDeclarationOfKind(getSymbolOfNode(declaration.parent), SyntaxKind.GetAccessor); if (getter) { const getterSignature = getSignatureFromDeclaration(getter); const thisParameter = getAccessorThisParameter(func as AccessorDeclaration); @@ -5186,117 +5179,159 @@ namespace ts { return type; } + /** + * Gets a SymbolTable containing both the early- and late-bound members of a symbol. + */ function getMembersOfSymbol(symbol: Symbol) { const links = getSymbolLinks(symbol); if (!links.resolvedMembers) { links.resolvedMembers = emptySymbols; - const dynamicMembers = getDynamicMembersOfSymbol(symbol); - if (!dynamicMembers || dynamicMembers.size === 0) { + const lateMembers = getLateBoundMembersOfSymbol(symbol); + if (lateMembers) { + for (const decl of symbol.declarations) { + lateBindMembers(lateMembers, decl); + } + } + if (!lateMembers || lateMembers.size === 0) { return links.resolvedMembers = symbol.members || emptySymbols; } if (!symbol.members || symbol.members.size === 0) { - return links.resolvedMembers = dynamicMembers; + return links.resolvedMembers = lateMembers; } const resolvedMembers = createMap(); mergeSymbolTable(resolvedMembers, symbol.members); - mergeSymbolTable(resolvedMembers, dynamicMembers); + mergeSymbolTable(resolvedMembers, lateMembers); return links.resolvedMembers = resolvedMembers; } return links.resolvedMembers; } - function getDynamicMembersOfSymbol(symbol: Symbol) { + /** + * Gets the late-bound members of a symbol. + */ + function getLateBoundMembersOfSymbol(symbol: Symbol) { if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral)) { const links = getSymbolLinks(symbol); - if (!links.dynamicMembers) { - const members = createMap(); - for (const decl of symbol.declarations) { - resolveDynamicMembersOfSymbol(decl, members); + return links.lateMembers || (links.lateMembers = createMap()); + } + } + + /** + * Tests whether a declaration has a late-bound dynamic name. + */ + function hasLateBoundName(node: Declaration): node is LateBoundDeclaration { + return node.name && isLateBoundName(node.name); + } + + /** + * Tests whether a declaration name is definately late-bindable. + */ + function isLateBoundName(node: DeclarationName): node is LateBoundName { + return isComputedPropertyName(node) + && isEntityNameExpression(node.expression) + && (checkComputedPropertyName(node).flags & TypeFlags.PossiblyBindable) !== 0; + } + + /** + * Performs late-binding of the dynamic members of a declaration. + */ + function lateBindMembers(lateMembers: Map, node: Declaration) { + const members = getMembersOfDeclaration(node); + if (members) { + for (const member of members) { + if (hasLateBoundName(member)) { + lateBindMember(lateMembers, node.symbol, member); } - links.dynamicMembers = members; } - return links.dynamicMembers; } } - function resolveDynamicMembersOfSymbol(node: Declaration, symbolTable: SymbolTable) { - switch (node.kind) { - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - case SyntaxKind.TypeLiteral: - resolveDynamicMembersOfNode(node, (node).members, symbolTable); - break; - case SyntaxKind.ObjectLiteralExpression: - resolveDynamicMembersOfNode(node, (node).properties, symbolTable); - break; + /** + * Tests whether a declaration has a dynamic name that cannot be late-bound. + */ + function hasUnboundDynamicName(node: Declaration) { + return hasDynamicName(node) && !hasLateBoundName(node); + } + + /** + * Tests whether a declaration name is a dynamic name that cannot be late-bound. + */ + function isUnboundDynamicName(node: DeclarationName) { + return isDynamicName(node) && !isLateBoundName(node); + } + + /** + * Gets the symbolic name for a late-bound member from its type. + */ + function getLateBoundNameFromType(type: Type) { + if (type.flags & TypeFlags.Unique) { + return `__@${type.symbol.name}@${getSymbolId(type.symbol)}`; + } + if (type.flags & TypeFlags.StringOrNumberLiteral) { + return escapeIdentifier((type).text); } } - function resolveDynamicMembersOfNode(node: Declaration, members: NodeArray, symbolTable: SymbolTable) { - for (const member of members) { - if (member.name && isComputedPropertyName(member.name) && isEntityNameExpression(member.name.expression)) { - bindDynamicMember(symbolTable, node.symbol, member); + /** + * Gets the late-bound symbol for a symbol (if it has one). + */ + function getLateBoundSymbol(symbol: Symbol) { + if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.name === "__computed") { + const links = getSymbolLinks(symbol); + if (!links.lateSymbol) { + links.lateSymbol = symbol; + const parent = symbol.parent; + if (parent && (parent.flags & SymbolFlags.HasMembers)) { + const lateMembers = getLateBoundMembersOfSymbol(parent); + for (const decl of symbol.declarations) { + if (hasLateBoundName(decl)) { + lateBindMember(lateMembers, parent, decl); + } + } + } } + return links.lateSymbol; } + return symbol; } - function bindDynamicMember(symbolTable: SymbolTable, parent: Symbol, member: ClassElement | TypeElement | ObjectLiteralElement) { + /** + * Performs late-binding of a dynamic member. + */ + function lateBindMember(lateMembers: Map, parent: Symbol, member: LateBoundDeclaration) { const links = getNodeLinks(member); if (!links.resolvedSymbol) { - switch (member.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - return resolveDynamicMember(symbolTable, parent, member, - SymbolFlags.Property | ((member).questionToken ? SymbolFlags.Optional : SymbolFlags.None), - SymbolFlags.PropertyExcludes); - case SyntaxKind.PropertyAssignment: - return resolveDynamicMember(symbolTable, parent, member, SymbolFlags.Property, SymbolFlags.PropertyExcludes); - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - return resolveDynamicMember(symbolTable, parent, member, - SymbolFlags.Method | ((member).questionToken ? SymbolFlags.Optional : SymbolFlags.None), - isObjectLiteralMethod(member) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); - case SyntaxKind.GetAccessor: - return resolveDynamicMember(symbolTable, parent, member, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); - case SyntaxKind.SetAccessor: - return resolveDynamicMember(symbolTable, parent, member, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); + const memberSymbol = member.symbol; + links.resolvedSymbol = memberSymbol || unknownSymbol; + const type = checkComputedPropertyName(member.name); + if (type.flags & TypeFlags.PossiblyBindable) { + const memberName = getLateBoundNameFromType(type); + let symbol = lateMembers.get(memberName); + if (!symbol) { + lateMembers.set(memberName, symbol = createSymbol(SymbolFlags.Late, memberName)); + } + const staticMember = parent.members && parent.members.get(memberName); + if (symbol.flags & getExcludedSymbolFlags(memberSymbol.flags) || staticMember) { + const declarations = staticMember ? concatenate(staticMember.declarations, symbol.declarations) : symbol.declarations; + const name = declarationNameToString(member.name); + forEach(declarations, declaration => error(declaration.name || declaration, Diagnostics.Duplicate_declaration_0, name)); + error(member.name || member, Diagnostics.Duplicate_declaration_0, name); + symbol = createSymbol(SymbolFlags.Late, memberName); + } + addDeclarationToLateBoundMember(symbol, member, memberSymbol.flags); + symbol.parent = parent; + return links.resolvedSymbol = symbol; } } return links.resolvedSymbol; } - function resolveDynamicMember(symbolTable: SymbolTable, parent: Symbol, member: ClassElement | TypeElement | ObjectLiteralElement, includes: SymbolFlags, excludes: SymbolFlags) { - Debug.assert(isComputedPropertyName(member.name)); - const nameType = checkComputedPropertyName(member.name); - if (nameType.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique)) { - const memberName = nameType.flags & TypeFlags.Unique - ? `__@@symbol@${nameType.symbol.id}@${nameType.symbol.name}` - : (nameType).text; - let symbol = symbolTable.get(memberName); - if (!symbol) { - symbolTable.set(memberName, symbol = createSymbol(SymbolFlags.Dynamic, memberName)); - } - const staticMember = parent.members && parent.members.get(memberName); - if (symbol.flags & excludes || staticMember) { - const declarations = staticMember ? concatenate(staticMember.declarations, symbol.declarations) : symbol.declarations; - const name = nameType.flags & TypeFlags.Unique ? `[${entityNameToString((member.name).expression)}]` : memberName; - forEach(declarations, declaration => { - error(declaration.name || declaration, Diagnostics.Duplicate_identifier_0, name); - }); - error(member.name || member, Diagnostics.Duplicate_identifier_0, name); - symbol = createSymbol(SymbolFlags.Dynamic, memberName); - } - addDeclarationToSymbol(symbol, member, includes); - symbol.parent = parent; - return symbol; - } - return getNodeLinks(member).resolvedSymbol = member.symbol || unknownSymbol; - } - - function addDeclarationToSymbol(symbol: Symbol, member: ClassElement | TypeElement | ObjectLiteralElement, symbolFlags: SymbolFlags) { + /** + * Adds a declaration to a late-bound dynamic member. + */ + function addDeclarationToLateBoundMember(symbol: TransientSymbol, member: LateBoundDeclaration, symbolFlags: SymbolFlags) { symbol.flags |= symbolFlags; - getNodeLinks(member).resolvedSymbol = symbol; + getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { symbol.declarations = [member]; } @@ -6329,10 +6364,10 @@ namespace ts { // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation if ((declaration.kind === SyntaxKind.GetAccessor || declaration.kind === SyntaxKind.SetAccessor) && - !hasDynamicName(declaration) && + !hasUnboundDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { const otherKind = declaration.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const other = getDeclarationOfKind(declaration.symbol, otherKind); + const other = getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } @@ -6374,8 +6409,8 @@ namespace ts { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === SyntaxKind.GetAccessor && !hasDynamicName(declaration)) { - const setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); + if (declaration.kind === SyntaxKind.GetAccessor && !hasUnboundDynamicName(declaration)) { + const setter = getDeclarationOfKind(getSymbolOfNode(declaration), SyntaxKind.SetAccessor); return getAnnotatedAccessorType(setter); } @@ -7687,7 +7722,7 @@ namespace ts { return type; } - function getFreshTypeOfType(type: Type) { + function getFreshTypeOfLiteralOrUniqueType(type: Type) { if (type.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique) && !(type.flags & TypeFlags.Fresh)) { if (!(type).freshType) { const freshType = type.flags & TypeFlags.Unique @@ -7701,7 +7736,7 @@ namespace ts { return type; } - function getRegularTypeOfType(type: Type) { + function getRegularTypeOfLiteralOrUniqueType(type: Type) { return type.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique) && type.flags & TypeFlags.Fresh ? (type).regularType : type; } @@ -7717,7 +7752,7 @@ namespace ts { function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getRegularTypeOfType(checkExpression(node.literal)); + links.resolvedType = getRegularTypeOfLiteralOrUniqueType(checkExpression(node.literal)); } return links.resolvedType; } @@ -8650,8 +8685,8 @@ namespace ts { } function isTypeRelatedTo(source: Type, target: Type, relation: Map) { - source = getRegularTypeOfType(source); - target = getRegularTypeOfType(target); + source = getRegularTypeOfLiteralOrUniqueType(source); + target = getRegularTypeOfLiteralOrUniqueType(target); if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } @@ -8776,8 +8811,8 @@ namespace ts { */ function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { let result: Ternary; - source = getRegularTypeOfType(source); - target = getRegularTypeOfType(target); + source = getRegularTypeOfLiteralOrUniqueType(source); + target = getRegularTypeOfLiteralOrUniqueType(target); // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; @@ -9894,10 +9929,11 @@ namespace ts { function getWidenedLiteralType(type: Type): Type { return type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.Fresh ? stringType : type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.Fresh ? numberType : - type.flags & TypeFlags.BooleanLiteral ? booleanType : - type.flags & TypeFlags.EnumLiteral ? (type).baseType : - type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(sameMap((type).types, getWidenedLiteralType)) : - type; + type.flags & TypeFlags.Unique && type.flags & TypeFlags.Fresh ? esSymbolType : + type.flags & TypeFlags.BooleanLiteral ? booleanType : + type.flags & TypeFlags.EnumLiteral ? (type).baseType : + type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(sameMap((type).types, getWidenedLiteralType)) : + type; } /** @@ -11008,7 +11044,7 @@ namespace ts { function getTypeOfSwitchClause(clause: CaseClause | DefaultClause) { if (clause.kind === SyntaxKind.CaseClause) { - const caseType = getRegularTypeOfType(getTypeOfExpression((clause).expression)); + const caseType = getRegularTypeOfLiteralOrUniqueType(getTypeOfExpression((clause).expression)); return isUnitType(caseType) ? caseType : undefined; } return neverType; @@ -11623,8 +11659,8 @@ namespace ts { return narrowedType.flags & TypeFlags.Never ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { - const regularType = getRegularTypeOfType(valueType); - return filterType(type, t => getRegularTypeOfType(t) !== regularType); + const regularType = getRegularTypeOfLiteralOrUniqueType(valueType); + return filterType(type, t => getRegularTypeOfLiteralOrUniqueType(t) !== regularType); } return type; } @@ -11681,7 +11717,7 @@ namespace ts { if (!hasDefaultClause) { return caseType; } - const defaultType = filterType(type, t => !(isUnitType(t) && contains(switchTypes, getRegularTypeOfType(t)))); + const defaultType = filterType(type, t => !(isUnitType(t) && contains(switchTypes, getRegularTypeOfLiteralOrUniqueType(t)))); return caseType.flags & TypeFlags.Never ? defaultType : getUnionType([caseType, defaultType]); } @@ -12797,7 +12833,7 @@ namespace ts { const objectLiteral = element.parent; const type = getApparentTypeOfContextualType(objectLiteral); if (type) { - if (!hasDynamicName(element)) { + if (!hasUnboundDynamicName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -13255,11 +13291,10 @@ namespace ts { typeFlags |= type.flags; let prop: TransientSymbol; - if (hasDynamicName(memberDecl) && isEntityNameExpression((memberDecl.name).expression)) { - const nameType = checkComputedPropertyName(memberDecl.name); - if (nameType && nameType.flags & TypeFlags.StringOrNumberLiteral) { - prop = createSymbol(SymbolFlags.Property | SymbolFlags.Dynamic | member.flags, (nameType).text); - prop.dynamicSource = resolveEntityName((memberDecl.name).expression, SymbolFlags.Value); + if (hasLateBoundName(memberDecl)) { + const nameType = checkComputedPropertyName(memberDecl.name); + if (nameType && nameType.flags & TypeFlags.PossiblyBindable) { + prop = createSymbol(SymbolFlags.Property | SymbolFlags.Late | member.flags, getLateBoundNameFromType(nameType)); } } @@ -13334,7 +13369,7 @@ namespace ts { checkNodeDeferred(memberDecl); } - if (hasDynamicName(memberDecl) && !(member && member.flags & SymbolFlags.Dynamic)) { + if (hasUnboundDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -15900,15 +15935,14 @@ namespace ts { } const returnType = getReturnTypeOfSignature(signature); - // Treat any call to the global 'Symbol' function that is part of a variable or property + // 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; - if (parent.kind === SyntaxKind.VariableDeclaration || - parent.kind === SyntaxKind.PropertyDeclaration || - parent.kind === SyntaxKind.PropertyAssignment) { + if ((parent.kind === SyntaxKind.VariableDeclaration && parent.parent.flags & NodeFlags.Const) || + (parent.kind === SyntaxKind.PropertyDeclaration && hasModifier(parent, ModifierFlags.Readonly))) { const symbol = getSymbolOfNode(parent); - if (symbol) return getFreshTypeOfType(getUniqueTypeForSymbol(symbol)); + if (symbol) return getFreshTypeOfLiteralOrUniqueType(getUniqueTypeForSymbol(symbol)); } } return returnType; @@ -16269,7 +16303,7 @@ namespace ts { if (!switchTypes.length) { return false; } - return eachTypeContainedIn(mapType(type, getRegularTypeOfType), switchTypes); + return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralOrUniqueType), switchTypes); } function functionHasImplicitReturn(func: FunctionLikeDeclaration) { @@ -16599,7 +16633,7 @@ namespace ts { return silentNeverType; } if (node.operator === SyntaxKind.MinusToken && node.operand.kind === SyntaxKind.NumericLiteral) { - return getFreshTypeOfType(getLiteralTypeForText(TypeFlags.NumberLiteral, "" + -(node.operand).text)); + return getFreshTypeOfLiteralOrUniqueType(getLiteralTypeForText(TypeFlags.NumberLiteral, "" + -(node.operand).text)); } switch (node.operator) { case SyntaxKind.PlusToken: @@ -17275,9 +17309,9 @@ namespace ts { } switch (node.kind) { case SyntaxKind.StringLiteral: - return getFreshTypeOfType(getLiteralTypeForText(TypeFlags.StringLiteral, (node).text)); + return getFreshTypeOfLiteralOrUniqueType(getLiteralTypeForText(TypeFlags.StringLiteral, (node).text)); case SyntaxKind.NumericLiteral: - return getFreshTypeOfType(getLiteralTypeForText(TypeFlags.NumberLiteral, (node).text)); + return getFreshTypeOfLiteralOrUniqueType(getLiteralTypeForText(TypeFlags.NumberLiteral, (node).text)); case SyntaxKind.TrueKeyword: return trueType; case SyntaxKind.FalseKeyword: @@ -17333,7 +17367,7 @@ namespace ts { function checkDeclarationInitializer(declaration: VariableLikeDeclaration) { const type = getTypeOfExpression(declaration.initializer, /*cache*/ true); return getCombinedNodeFlags(declaration) & NodeFlags.Const || - getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) || + (getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration)) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); } @@ -18120,11 +18154,11 @@ namespace ts { if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkComputedPropertyName(node.name); } - if (!hasDynamicName(node)) { + if (!hasUnboundDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const otherAccessor = getDeclarationOfKind(node.symbol, otherKind); + const otherAccessor = getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { if ((getModifierFlags(node) & ModifierFlags.AccessibilityModifier) !== (getModifierFlags(otherAccessor) & ModifierFlags.AccessibilityModifier)) { error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); @@ -19029,7 +19063,7 @@ namespace ts { checkComputedPropertyName(node.name); } - if (!hasDynamicName(node)) { + if (!hasUnboundDynamicName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -20422,10 +20456,11 @@ namespace ts { // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(getModifierFlags(member) & ModifierFlags.Static) && hasDynamicName(member)) { - const propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); + if (!(getModifierFlags(member) & ModifierFlags.Static) && hasUnboundDynamicName(member)) { + const symbol = getSymbolOfNode(member); + const propType = getTypeOfSymbol(symbol); + checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); + checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); } } } @@ -22463,7 +22498,7 @@ namespace ts { if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { expr = expr.parent; } - return getRegularTypeOfType(getTypeOfExpression(expr)); + return getRegularTypeOfLiteralOrUniqueType(getTypeOfExpression(expr)); } /** @@ -22885,11 +22920,17 @@ namespace ts { function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { // Get type of the symbol if this is the valid symbol otherwise get type at location const symbol = getSymbolOfNode(declaration); - let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) - ? getWidenedLiteralType(getTypeOfSymbol(symbol)) - : unknownType; - if (type.flags & TypeFlags.Unique && type.symbol !== symbol) { - type = getRegularTypeOfUniqueType(type); + let type: Type = unknownType; + if (symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature))) { + type = getTypeOfSymbol(symbol); + if (type.flags & TypeFlags.Unique) { + if (type.symbol !== symbol) { + type = getRegularTypeOfUniqueType(type); + } + } + else { + type = getWidenedLiteralType(type); + } } if (flags & TypeFormatFlags.AddUndefined) { type = includeFalsyTypes(type, TypeFlags.Undefined); @@ -24028,11 +24069,8 @@ namespace ts { } function checkGrammarForNonSymbolComputedProperty(node: DeclarationName, message: DiagnosticMessage) { - if (isDynamicName(node)) { - if (!isEntityNameExpression((node).expression) || - (checkExpressionCached((node).expression).flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique)) === 0) { - return grammarErrorOnNode(node, message); - } + if (isUnboundDynamicName(node)) { + return grammarErrorOnNode(node, message); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 83b97c1a04c48..b4c25aecef799 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2136,6 +2136,10 @@ "category": "Error", "code": 2711 }, + "Duplicate declaration '{0}'.": { + "category": "Error", + "code": 2712 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3c2f4dedadc1b..19aadad95fd1a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2533,10 +2533,10 @@ namespace ts { case SyntaxKind.NeverKeyword: case SyntaxKind.ObjectKeyword: // If these are followed by a dot, then parse these out as a dotted type reference instead. - return tryParse(parseKeywordAndNoDot) + return tryParse(parseKeywordAndNoDot) || parseTypeReference(); case SyntaxKind.SymbolKeyword: - return tryParse(parseSymbolType) + return tryParse(parseSymbolType) || parseTypeReference(); case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1ea3946a87ad7..f4461ff6a7c39 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2788,7 +2788,7 @@ namespace ts { ExportStar = 1 << 25, // Export * declaration Optional = 1 << 26, // Optional property Transient = 1 << 27, // Transient symbol (created during type check) - Dynamic = 1 << 28, // Dynamically resolved symbol from computed property + Late = 1 << 28, // Late-bound symbol from computed property with a dynamic name (created during type check) Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, @@ -2872,7 +2872,7 @@ namespace ts { instantiations?: Map; // Instantiations of generic type alias (undefined if non-generic) mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value - containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property + containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property leftSpread?: Symbol; // Left source for synthetic spread property rightSpread?: Symbol; // Right source for synthetic spread property syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property @@ -2880,13 +2880,12 @@ namespace ts { resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked. - isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration + isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) - dynamicMembers?: SymbolTable; // Dynamic members with literal names resolved during check - resolvedMembers?: SymbolTable; - dynamicSource?: Symbol; - uniqueType?: Type; // ESSymbol Unique type for a symbol. + lateSymbol?: Symbol; // Late-bound symbol for a computed property + lateMembers?: Map; // Late-bound members resolved during check + resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol } /* @internal */ @@ -3009,6 +3008,8 @@ namespace ts { Literal = StringLiteral | NumberLiteral | BooleanLiteral | EnumLiteral | Unique, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ + PossiblyBindable = StringOrNumberLiteral | Unique, + /* @internal */ DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean, /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f1ee91acd82c8..d87e7384cd9e0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -831,6 +831,18 @@ namespace ts { } } + export function getMembersOfDeclaration(node: Declaration): NodeArray | undefined { + switch (node.kind) { + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.TypeLiteral: + return (node).members; + case SyntaxKind.ObjectLiteralExpression: + return (node).properties; + } + } + export function isVariableLike(node: Node): node is VariableLikeDeclaration { if (node) { switch (node.kind) { diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index e4a661d6d3f02..4f79d7df0fc89 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -3,76 +3,91 @@ //// [module.ts] export const c0 = "a"; export const c1 = 1; +export const s0 = Symbol(); export interface T0 { [c0]: number; [c1]: string; + [s0]: boolean; } export declare class T1 implements T2 { [c0]: number; [c1]: string; + [s0]: boolean; } export declare class T2 extends T1 { } export declare type T3 = { [c0]: number; [c1]: string; + [s0]: boolean; }; //// [main.ts] -import { c0, c1, T0, T1, T2, T3 } from "./module"; +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; import * as M from "./module"; namespace N { export const c2 = "a"; export const c3 = 1; + export const s1 = s0; export interface T4 { [N.c2]: number; [N.c3]: string; + [N.s1]: boolean; } export declare class T5 implements T4 { [N.c2]: number; [N.c3]: string; + [N.s1]: boolean; } export declare class T6 extends T5 { } export declare type T7 = { [N.c2]: number; [N.c3]: string; + [N.s1]: boolean; }; } -const c4 = "a"; -const c5 = 1; +export const c4 = "a"; +export const c5 = 1; +export const s2 = s0; interface T8 { [c4]: number; [c5]: string; + [s2]: boolean; } declare class T9 implements T8 { [c4]: number; [c5]: string; + [s2]: boolean; } declare class T10 extends T9 { } declare type T11 = { [c4]: number; [c5]: string; + [s2]: boolean; }; interface T12 { a: number; 1: string; + [s2]: boolean; } declare class T13 implements T2 { a: number; 1: string; + [s2]: boolean; } declare class T14 extends T13 { } declare type T15 = { a: number; 1: string; + [s2]: boolean; }; let t0: T0; @@ -99,23 +114,36 @@ let t15: T15; // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; -t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; + +// object literals +export const o1 = { + [c4]: 1, + [c5]: "a", + [s2]: true +}; + +export const o2: T0 = o1; //// [module.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.c0 = "a"; exports.c1 = 1; +exports.s0 = Symbol(); //// [main.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const module_1 = require("./module"); var N; (function (N) { N.c2 = "a"; N.c3 = 1; + N.s1 = module_1.s0; })(N || (N = {})); -const c4 = "a"; -const c5 = 1; +exports.c4 = "a"; +exports.c5 = 1; +exports.s2 = module_1.s0; let t0; let t1; let t2; @@ -140,23 +168,44 @@ let t15; t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +// object literals +exports.o1 = { + [exports.c4]: 1, + [exports.c5]: "a", + [exports.s2]: true +}; +exports.o2 = exports.o1; //// [module.d.ts] export declare const c0 = "a"; export declare const c1 = 1; +export declare const s0: symbol(); export interface T0 { [c0]: number; [c1]: string; + [s0]: boolean; } export declare class T1 implements T2 { [c0]: number; [c1]: string; + [s0]: boolean; } export declare class T2 extends T1 { } export declare type T3 = { [c0]: number; [c1]: string; + [s0]: boolean; }; //// [main.d.ts] +import { s0, T0 } from "./module"; +export declare const c4 = "a"; +export declare const c5 = 1; +export declare const s2: typeof s0; +export declare const o1: { + [c4]: number; + [c5]: string; + [s2]: boolean; +}; +export declare const o2: T0; diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index 1663172d125bd..5d917aa1e6fe9 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -5,31 +5,41 @@ export const c0 = "a"; export const c1 = 1; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) +export const s0 = Symbol(); +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + export interface T0 { ->T0 : Symbol(T0, Decl(module.ts, 1, 20)) +>T0 : Symbol(T0, Decl(module.ts, 2, 27)) [c0]: number; >c0 : Symbol(c0, Decl(module.ts, 0, 12)) [c1]: string; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) + + [s0]: boolean; +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) } export declare class T1 implements T2 { ->T1 : Symbol(T1, Decl(module.ts, 5, 1)) ->T2 : Symbol(T2, Decl(module.ts, 9, 1)) +>T1 : Symbol(T1, Decl(module.ts, 7, 1)) +>T2 : Symbol(T2, Decl(module.ts, 12, 1)) [c0]: number; >c0 : Symbol(c0, Decl(module.ts, 0, 12)) [c1]: string; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) + + [s0]: boolean; +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) } export declare class T2 extends T1 { ->T2 : Symbol(T2, Decl(module.ts, 9, 1)) ->T1 : Symbol(T1, Decl(module.ts, 5, 1)) +>T2 : Symbol(T2, Decl(module.ts, 12, 1)) +>T1 : Symbol(T1, Decl(module.ts, 7, 1)) } export declare type T3 = { ->T3 : Symbol(T3, Decl(module.ts, 11, 1)) +>T3 : Symbol(T3, Decl(module.ts, 14, 1)) [c0]: number; >c0 : Symbol(c0, Decl(module.ts, 0, 12)) @@ -37,16 +47,20 @@ export declare type T3 = { [c1]: string; >c1 : Symbol(c1, Decl(module.ts, 1, 12)) + [s0]: boolean; +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) + }; === tests/cases/compiler/main.ts === -import { c0, c1, T0, T1, T2, T3 } from "./module"; +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; >c0 : Symbol(c0, Decl(main.ts, 0, 8)) >c1 : Symbol(c1, Decl(main.ts, 0, 12)) ->T0 : Symbol(T0, Decl(main.ts, 0, 16)) ->T1 : Symbol(T1, Decl(main.ts, 0, 20)) ->T2 : Symbol(T2, Decl(main.ts, 0, 24)) ->T3 : Symbol(T3, Decl(main.ts, 0, 28)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) +>T0 : Symbol(T0, Decl(main.ts, 0, 20)) +>T1 : Symbol(T1, Decl(main.ts, 0, 24)) +>T2 : Symbol(T2, Decl(main.ts, 0, 28)) +>T3 : Symbol(T3, Decl(main.ts, 0, 32)) import * as M from "./module"; >M : Symbol(M, Decl(main.ts, 1, 6)) @@ -60,8 +74,12 @@ namespace N { export const c3 = 1; >c3 : Symbol(c3, Decl(main.ts, 5, 16)) + export const s1 = s0; +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) + export interface T4 { ->T4 : Symbol(T4, Decl(main.ts, 5, 24)) +>T4 : Symbol(T4, Decl(main.ts, 6, 25)) [N.c2]: number; >N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) @@ -72,10 +90,15 @@ namespace N { >N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) >N : Symbol(N, Decl(main.ts, 1, 30)) >c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + [N.s1]: boolean; +>N.s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) } export declare class T5 implements T4 { ->T5 : Symbol(T5, Decl(main.ts, 10, 5)) ->T4 : Symbol(T4, Decl(main.ts, 5, 24)) +>T5 : Symbol(T5, Decl(main.ts, 12, 5)) +>T4 : Symbol(T4, Decl(main.ts, 6, 25)) [N.c2]: number; >N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) @@ -86,13 +109,18 @@ namespace N { >N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) >N : Symbol(N, Decl(main.ts, 1, 30)) >c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + [N.s1]: boolean; +>N.s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) } export declare class T6 extends T5 { ->T6 : Symbol(T6, Decl(main.ts, 14, 5)) ->T5 : Symbol(T5, Decl(main.ts, 10, 5)) +>T6 : Symbol(T6, Decl(main.ts, 17, 5)) +>T5 : Symbol(T5, Decl(main.ts, 12, 5)) } export declare type T7 = { ->T7 : Symbol(T7, Decl(main.ts, 16, 5)) +>T7 : Symbol(T7, Decl(main.ts, 19, 5)) [N.c2]: number; >N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) @@ -104,235 +132,280 @@ namespace N { >N : Symbol(N, Decl(main.ts, 1, 30)) >c3 : Symbol(c3, Decl(main.ts, 5, 16)) + [N.s1]: boolean; +>N.s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) + }; } -const c4 = "a"; ->c4 : Symbol(c4, Decl(main.ts, 23, 5)) +export const c4 = "a"; +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + +export const c5 = 1; +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) -const c5 = 1; ->c5 : Symbol(c5, Decl(main.ts, 24, 5)) +export const s2 = s0; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) interface T8 { ->T8 : Symbol(T8, Decl(main.ts, 24, 13)) +>T8 : Symbol(T8, Decl(main.ts, 29, 21)) [c4]: number; ->c4 : Symbol(c4, Decl(main.ts, 23, 5)) +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) [c5]: string; ->c5 : Symbol(c5, Decl(main.ts, 24, 5)) +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) } declare class T9 implements T8 { ->T9 : Symbol(T9, Decl(main.ts, 29, 1)) ->T8 : Symbol(T8, Decl(main.ts, 24, 13)) +>T9 : Symbol(T9, Decl(main.ts, 35, 1)) +>T8 : Symbol(T8, Decl(main.ts, 29, 21)) [c4]: number; ->c4 : Symbol(c4, Decl(main.ts, 23, 5)) +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) [c5]: string; ->c5 : Symbol(c5, Decl(main.ts, 24, 5)) +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) } declare class T10 extends T9 { ->T10 : Symbol(T10, Decl(main.ts, 33, 1)) ->T9 : Symbol(T9, Decl(main.ts, 29, 1)) +>T10 : Symbol(T10, Decl(main.ts, 40, 1)) +>T9 : Symbol(T9, Decl(main.ts, 35, 1)) } declare type T11 = { ->T11 : Symbol(T11, Decl(main.ts, 35, 1)) +>T11 : Symbol(T11, Decl(main.ts, 42, 1)) [c4]: number; ->c4 : Symbol(c4, Decl(main.ts, 23, 5)) +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) [c5]: string; ->c5 : Symbol(c5, Decl(main.ts, 24, 5)) +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) }; interface T12 { ->T12 : Symbol(T12, Decl(main.ts, 39, 2)) +>T12 : Symbol(T12, Decl(main.ts, 47, 2)) a: number; ->a : Symbol(T12.a, Decl(main.ts, 41, 15)) +>a : Symbol(T12.a, Decl(main.ts, 49, 15)) 1: string; + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) } declare class T13 implements T2 { ->T13 : Symbol(T13, Decl(main.ts, 44, 1)) ->T2 : Symbol(T2, Decl(main.ts, 0, 24)) +>T13 : Symbol(T13, Decl(main.ts, 53, 1)) +>T2 : Symbol(T2, Decl(main.ts, 0, 28)) a: number; ->a : Symbol(T13.a, Decl(main.ts, 45, 33)) +>a : Symbol(T13.a, Decl(main.ts, 54, 33)) 1: string; + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) } declare class T14 extends T13 { ->T14 : Symbol(T14, Decl(main.ts, 48, 1)) ->T13 : Symbol(T13, Decl(main.ts, 44, 1)) +>T14 : Symbol(T14, Decl(main.ts, 58, 1)) +>T13 : Symbol(T13, Decl(main.ts, 53, 1)) } declare type T15 = { ->T15 : Symbol(T15, Decl(main.ts, 50, 1)) +>T15 : Symbol(T15, Decl(main.ts, 60, 1)) a: number; ->a : Symbol(a, Decl(main.ts, 51, 20)) +>a : Symbol(a, Decl(main.ts, 61, 20)) 1: string; + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) + }; let t0: T0; ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->T0 : Symbol(T0, Decl(main.ts, 0, 16)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>T0 : Symbol(T0, Decl(main.ts, 0, 20)) let t1: T1; ->t1 : Symbol(t1, Decl(main.ts, 57, 3)) ->T1 : Symbol(T1, Decl(main.ts, 0, 20)) +>t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>T1 : Symbol(T1, Decl(main.ts, 0, 24)) let t2: T2; ->t2 : Symbol(t2, Decl(main.ts, 58, 3)) ->T2 : Symbol(T2, Decl(main.ts, 0, 24)) +>t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>T2 : Symbol(T2, Decl(main.ts, 0, 28)) let t3: T3; ->t3 : Symbol(t3, Decl(main.ts, 59, 3)) ->T3 : Symbol(T3, Decl(main.ts, 0, 28)) +>t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>T3 : Symbol(T3, Decl(main.ts, 0, 32)) let t0_1: M.T0; ->t0_1 : Symbol(t0_1, Decl(main.ts, 60, 3)) +>t0_1 : Symbol(t0_1, Decl(main.ts, 71, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T0 : Symbol(T0, Decl(module.ts, 1, 20)) +>T0 : Symbol(T0, Decl(module.ts, 2, 27)) let t1_1: M.T1; ->t1_1 : Symbol(t1_1, Decl(main.ts, 61, 3)) +>t1_1 : Symbol(t1_1, Decl(main.ts, 72, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T1 : Symbol(T1, Decl(module.ts, 5, 1)) +>T1 : Symbol(T1, Decl(module.ts, 7, 1)) let t2_1: M.T2; ->t2_1 : Symbol(t2_1, Decl(main.ts, 62, 3)) +>t2_1 : Symbol(t2_1, Decl(main.ts, 73, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T2 : Symbol(T2, Decl(module.ts, 9, 1)) +>T2 : Symbol(T2, Decl(module.ts, 12, 1)) let t3_1: M.T3; ->t3_1 : Symbol(t3_1, Decl(main.ts, 63, 3)) +>t3_1 : Symbol(t3_1, Decl(main.ts, 74, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) ->T3 : Symbol(T3, Decl(module.ts, 11, 1)) +>T3 : Symbol(T3, Decl(module.ts, 14, 1)) let t4: N.T4; ->t4 : Symbol(t4, Decl(main.ts, 64, 3)) +>t4 : Symbol(t4, Decl(main.ts, 75, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) ->T4 : Symbol(N.T4, Decl(main.ts, 5, 24)) +>T4 : Symbol(N.T4, Decl(main.ts, 6, 25)) let t5: N.T5; ->t5 : Symbol(t5, Decl(main.ts, 65, 3)) +>t5 : Symbol(t5, Decl(main.ts, 76, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) ->T5 : Symbol(N.T5, Decl(main.ts, 10, 5)) +>T5 : Symbol(N.T5, Decl(main.ts, 12, 5)) let t6: N.T6; ->t6 : Symbol(t6, Decl(main.ts, 66, 3)) +>t6 : Symbol(t6, Decl(main.ts, 77, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) ->T6 : Symbol(N.T6, Decl(main.ts, 14, 5)) +>T6 : Symbol(N.T6, Decl(main.ts, 17, 5)) let t7: N.T7; ->t7 : Symbol(t7, Decl(main.ts, 67, 3)) +>t7 : Symbol(t7, Decl(main.ts, 78, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) ->T7 : Symbol(N.T7, Decl(main.ts, 16, 5)) +>T7 : Symbol(N.T7, Decl(main.ts, 19, 5)) let t8: T8; ->t8 : Symbol(t8, Decl(main.ts, 68, 3)) ->T8 : Symbol(T8, Decl(main.ts, 24, 13)) +>t8 : Symbol(t8, Decl(main.ts, 79, 3)) +>T8 : Symbol(T8, Decl(main.ts, 29, 21)) let t9: T9; ->t9 : Symbol(t9, Decl(main.ts, 69, 3)) ->T9 : Symbol(T9, Decl(main.ts, 29, 1)) +>t9 : Symbol(t9, Decl(main.ts, 80, 3)) +>T9 : Symbol(T9, Decl(main.ts, 35, 1)) let t10: T10; ->t10 : Symbol(t10, Decl(main.ts, 70, 3)) ->T10 : Symbol(T10, Decl(main.ts, 33, 1)) +>t10 : Symbol(t10, Decl(main.ts, 81, 3)) +>T10 : Symbol(T10, Decl(main.ts, 40, 1)) let t11: T11; ->t11 : Symbol(t11, Decl(main.ts, 71, 3)) ->T11 : Symbol(T11, Decl(main.ts, 35, 1)) +>t11 : Symbol(t11, Decl(main.ts, 82, 3)) +>T11 : Symbol(T11, Decl(main.ts, 42, 1)) let t12: T12; ->t12 : Symbol(t12, Decl(main.ts, 72, 3)) ->T12 : Symbol(T12, Decl(main.ts, 39, 2)) +>t12 : Symbol(t12, Decl(main.ts, 83, 3)) +>T12 : Symbol(T12, Decl(main.ts, 47, 2)) let t13: T13; ->t13 : Symbol(t13, Decl(main.ts, 73, 3)) ->T13 : Symbol(T13, Decl(main.ts, 44, 1)) +>t13 : Symbol(t13, Decl(main.ts, 84, 3)) +>T13 : Symbol(T13, Decl(main.ts, 53, 1)) let t14: T14; ->t14 : Symbol(t14, Decl(main.ts, 74, 3)) ->T14 : Symbol(T14, Decl(main.ts, 48, 1)) +>t14 : Symbol(t14, Decl(main.ts, 85, 3)) +>T14 : Symbol(T14, Decl(main.ts, 58, 1)) let t15: T15; ->t15 : Symbol(t15, Decl(main.ts, 75, 3)) ->T15 : Symbol(T15, Decl(main.ts, 50, 1)) +>t15 : Symbol(t15, Decl(main.ts, 86, 3)) +>T15 : Symbol(T15, Decl(main.ts, 60, 1)) // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t1 : Symbol(t1, Decl(main.ts, 57, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t2 : Symbol(t2, Decl(main.ts, 58, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t3 : Symbol(t3, Decl(main.ts, 59, 3)) ->t1 : Symbol(t1, Decl(main.ts, 57, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t1 : Symbol(t1, Decl(main.ts, 57, 3)) ->t2 : Symbol(t2, Decl(main.ts, 58, 3)) ->t1 : Symbol(t1, Decl(main.ts, 57, 3)) ->t3 : Symbol(t3, Decl(main.ts, 59, 3)) ->t2 : Symbol(t2, Decl(main.ts, 58, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t2 : Symbol(t2, Decl(main.ts, 58, 3)) ->t1 : Symbol(t1, Decl(main.ts, 57, 3)) ->t2 : Symbol(t2, Decl(main.ts, 58, 3)) ->t3 : Symbol(t3, Decl(main.ts, 59, 3)) ->t3 : Symbol(t3, Decl(main.ts, 59, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t3 : Symbol(t3, Decl(main.ts, 59, 3)) ->t1 : Symbol(t1, Decl(main.ts, 57, 3)) ->t3 : Symbol(t3, Decl(main.ts, 59, 3)) ->t2 : Symbol(t2, Decl(main.ts, 58, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>t2 : Symbol(t2, Decl(main.ts, 69, 3)) t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; ->t4 : Symbol(t4, Decl(main.ts, 64, 3)) ->t5 : Symbol(t5, Decl(main.ts, 65, 3)) ->t4 : Symbol(t4, Decl(main.ts, 64, 3)) ->t6 : Symbol(t6, Decl(main.ts, 66, 3)) ->t4 : Symbol(t4, Decl(main.ts, 64, 3)) ->t7 : Symbol(t7, Decl(main.ts, 67, 3)) ->t5 : Symbol(t5, Decl(main.ts, 65, 3)) ->t4 : Symbol(t4, Decl(main.ts, 64, 3)) ->t5 : Symbol(t5, Decl(main.ts, 65, 3)) ->t6 : Symbol(t6, Decl(main.ts, 66, 3)) ->t5 : Symbol(t5, Decl(main.ts, 65, 3)) ->t7 : Symbol(t7, Decl(main.ts, 67, 3)) ->t6 : Symbol(t6, Decl(main.ts, 66, 3)) ->t4 : Symbol(t4, Decl(main.ts, 64, 3)) ->t6 : Symbol(t6, Decl(main.ts, 66, 3)) ->t5 : Symbol(t5, Decl(main.ts, 65, 3)) ->t6 : Symbol(t6, Decl(main.ts, 66, 3)) ->t7 : Symbol(t7, Decl(main.ts, 67, 3)) ->t7 : Symbol(t7, Decl(main.ts, 67, 3)) ->t4 : Symbol(t4, Decl(main.ts, 64, 3)) ->t7 : Symbol(t7, Decl(main.ts, 67, 3)) ->t5 : Symbol(t5, Decl(main.ts, 65, 3)) ->t7 : Symbol(t7, Decl(main.ts, 67, 3)) ->t6 : Symbol(t6, Decl(main.ts, 66, 3)) +>t4 : Symbol(t4, Decl(main.ts, 75, 3)) +>t5 : Symbol(t5, Decl(main.ts, 76, 3)) +>t4 : Symbol(t4, Decl(main.ts, 75, 3)) +>t6 : Symbol(t6, Decl(main.ts, 77, 3)) +>t4 : Symbol(t4, Decl(main.ts, 75, 3)) +>t7 : Symbol(t7, Decl(main.ts, 78, 3)) +>t5 : Symbol(t5, Decl(main.ts, 76, 3)) +>t4 : Symbol(t4, Decl(main.ts, 75, 3)) +>t5 : Symbol(t5, Decl(main.ts, 76, 3)) +>t6 : Symbol(t6, Decl(main.ts, 77, 3)) +>t5 : Symbol(t5, Decl(main.ts, 76, 3)) +>t7 : Symbol(t7, Decl(main.ts, 78, 3)) +>t6 : Symbol(t6, Decl(main.ts, 77, 3)) +>t4 : Symbol(t4, Decl(main.ts, 75, 3)) +>t6 : Symbol(t6, Decl(main.ts, 77, 3)) +>t5 : Symbol(t5, Decl(main.ts, 76, 3)) +>t6 : Symbol(t6, Decl(main.ts, 77, 3)) +>t7 : Symbol(t7, Decl(main.ts, 78, 3)) +>t7 : Symbol(t7, Decl(main.ts, 78, 3)) +>t4 : Symbol(t4, Decl(main.ts, 75, 3)) +>t7 : Symbol(t7, Decl(main.ts, 78, 3)) +>t5 : Symbol(t5, Decl(main.ts, 76, 3)) +>t7 : Symbol(t7, Decl(main.ts, 78, 3)) +>t6 : Symbol(t6, Decl(main.ts, 77, 3)) t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t12 : Symbol(t12, Decl(main.ts, 72, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t13 : Symbol(t13, Decl(main.ts, 73, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t14 : Symbol(t14, Decl(main.ts, 74, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t15 : Symbol(t15, Decl(main.ts, 75, 3)) ->t12 : Symbol(t12, Decl(main.ts, 72, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t13 : Symbol(t13, Decl(main.ts, 73, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t14 : Symbol(t14, Decl(main.ts, 74, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) ->t15 : Symbol(t15, Decl(main.ts, 75, 3)) ->t0 : Symbol(t0, Decl(main.ts, 56, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t12 : Symbol(t12, Decl(main.ts, 83, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t13 : Symbol(t13, Decl(main.ts, 84, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t14 : Symbol(t14, Decl(main.ts, 85, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t15 : Symbol(t15, Decl(main.ts, 86, 3)) +>t12 : Symbol(t12, Decl(main.ts, 83, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t13 : Symbol(t13, Decl(main.ts, 84, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t14 : Symbol(t14, Decl(main.ts, 85, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t15 : Symbol(t15, Decl(main.ts, 86, 3)) +>t0 : Symbol(t0, Decl(main.ts, 67, 3)) + +// object literals +export const o1 = { +>o1 : Symbol(o1, Decl(main.ts, 94, 12)) + + [c4]: 1, +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + + [c5]: "a", +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: true +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) + +}; + +export const o2: T0 = o1; +>o2 : Symbol(o2, Decl(main.ts, 100, 12)) +>T0 : Symbol(T0, Decl(main.ts, 0, 20)) +>o1 : Symbol(o1, Decl(main.ts, 94, 12)) diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 6a6ce65416ff4..af5e34d44049c 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -7,6 +7,11 @@ export const c1 = 1; >c1 : 1 >1 : 1 +export const s0 = Symbol(); +>s0 : symbol() +>Symbol() : typeof s0 +>Symbol : SymbolConstructor + export interface T0 { >T0 : T0 @@ -15,6 +20,9 @@ export interface T0 { [c1]: string; >c1 : 1 + + [s0]: boolean; +>s0 : typeof s0 } export declare class T1 implements T2 { >T1 : T1 @@ -25,6 +33,9 @@ export declare class T1 implements T2 { [c1]: string; >c1 : 1 + + [s0]: boolean; +>s0 : typeof s0 } export declare class T2 extends T1 { >T2 : T2 @@ -39,12 +50,16 @@ export declare type T3 = { [c1]: string; >c1 : 1 + [s0]: boolean; +>s0 : typeof s0 + }; === tests/cases/compiler/main.ts === -import { c0, c1, T0, T1, T2, T3 } from "./module"; +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; >c0 : "a" >c1 : 1 +>s0 : symbol() >T0 : any >T1 : typeof T1 >T2 : typeof T2 @@ -64,6 +79,10 @@ namespace N { >c3 : 1 >1 : 1 + export const s1 = s0; +>s1 : typeof s0 +>s0 : typeof s0 + export interface T4 { >T4 : T4 @@ -76,6 +95,11 @@ namespace N { >N.c3 : 1 >N : typeof N >c3 : 1 + + [N.s1]: boolean; +>N.s1 : typeof s0 +>N : typeof N +>s1 : typeof s0 } export declare class T5 implements T4 { >T5 : T5 @@ -90,13 +114,18 @@ namespace N { >N.c3 : 1 >N : typeof N >c3 : 1 + + [N.s1]: boolean; +>N.s1 : typeof s0 +>N : typeof N +>s1 : typeof s0 } export declare class T6 extends T5 { >T6 : T6 >T5 : T5 } export declare type T7 = { ->T7 : { [N.c2]: number; [N.c3]: string; } +>T7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } [N.c2]: number; >N.c2 : "a" @@ -108,17 +137,26 @@ namespace N { >N : typeof N >c3 : 1 + [N.s1]: boolean; +>N.s1 : typeof s0 +>N : typeof N +>s1 : typeof s0 + }; } -const c4 = "a"; +export const c4 = "a"; >c4 : "a" >"a" : "a" -const c5 = 1; +export const c5 = 1; >c5 : 1 >1 : 1 +export const s2 = s0; +>s2 : typeof s0 +>s0 : typeof s0 + interface T8 { >T8 : T8 @@ -127,6 +165,9 @@ interface T8 { [c5]: string; >c5 : 1 + + [s2]: boolean; +>s2 : typeof s0 } declare class T9 implements T8 { >T9 : T9 @@ -137,13 +178,16 @@ declare class T9 implements T8 { [c5]: string; >c5 : 1 + + [s2]: boolean; +>s2 : typeof s0 } declare class T10 extends T9 { >T10 : T10 >T9 : T9 } declare type T11 = { ->T11 : { [c4]: number; [c5]: string; } +>T11 : { [c4]: number; [c5]: string; [s2]: boolean; } [c4]: number; >c4 : "a" @@ -151,6 +195,9 @@ declare type T11 = { [c5]: string; >c5 : 1 + [s2]: boolean; +>s2 : typeof s0 + }; interface T12 { @@ -160,6 +207,8 @@ interface T12 { >a : number 1: string; + [s2]: boolean; +>s2 : typeof s0 } declare class T13 implements T2 { >T13 : T13 @@ -169,18 +218,23 @@ declare class T13 implements T2 { >a : number 1: string; + [s2]: boolean; +>s2 : typeof s0 } declare class T14 extends T13 { >T14 : T14 >T13 : T13 } declare type T15 = { ->T15 : { a: number; 1: string; } +>T15 : { a: number; 1: string; [s2]: boolean; } a: number; >a : number 1: string; + [s2]: boolean; +>s2 : typeof s0 + }; let t0: T0; @@ -235,9 +289,9 @@ let t6: N.T6; >T6 : N.T6 let t7: N.T7; ->t7 : { [N.c2]: number; [N.c3]: string; } +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >N : any ->T7 : { [N.c2]: number; [N.c3]: string; } +>T7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } let t8: T8; >t8 : T8 @@ -252,8 +306,8 @@ let t10: T10; >T10 : T10 let t11: T11; ->t11 : { [c4]: number; [c5]: string; } ->T11 : { [c4]: number; [c5]: string; } +>t11 : { [c4]: number; [c5]: string; [s2]: boolean; } +>T11 : { [c4]: number; [c5]: string; [s2]: boolean; } let t12: T12; >t12 : T12 @@ -268,8 +322,8 @@ let t14: T14; >T14 : T14 let t15: T15; ->t15 : { a: number; 1: string; } ->T15 : { a: number; 1: string; } +>t15 : { a: number; 1: string; [s2]: boolean; } +>T15 : { a: number; 1: string; [s2]: boolean; } // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; @@ -325,13 +379,13 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { [N.c2]: number; [N.c3]: string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { [N.c2]: number; [N.c3]: string; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7 : { [N.c2]: number; [N.c3]: string; } +>t4 = t5, t4 = t6, t4 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t4 = t5, t4 = t6 : N.T6 >t4 = t5 : N.T5 >t4 : N.T4 @@ -339,35 +393,35 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t6 : N.T6 >t4 : N.T4 >t6 : N.T6 ->t4 = t7 : { [N.c2]: number; [N.c3]: string; } +>t4 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t4 : N.T4 ->t7 : { [N.c2]: number; [N.c3]: string; } +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t5 = t4 : N.T4 >t5 : N.T5 >t4 : N.T4 >t5 = t6 : N.T6 >t5 : N.T5 >t6 : N.T6 ->t5 = t7 : { [N.c2]: number; [N.c3]: string; } +>t5 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t5 : N.T5 ->t7 : { [N.c2]: number; [N.c3]: string; } +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t6 = t4 : N.T4 >t6 : N.T6 >t4 : N.T4 >t6 = t5 : N.T5 >t6 : N.T6 >t5 : N.T5 ->t6 = t7 : { [N.c2]: number; [N.c3]: string; } +>t6 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t6 : N.T6 ->t7 : { [N.c2]: number; [N.c3]: string; } +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t7 = t4 : N.T4 ->t7 : { [N.c2]: number; [N.c3]: string; } +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t4 : N.T4 >t7 = t5 : N.T5 ->t7 : { [N.c2]: number; [N.c3]: string; } +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t5 : N.T5 >t7 = t6 : N.T6 ->t7 : { [N.c2]: number; [N.c3]: string; } +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } >t6 : N.T6 t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; @@ -375,7 +429,7 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; >t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0 : T0 >t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0 : T0 >t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0 : T0 ->t0 = t12, t0 = t13, t0 = t14, t0 = t15 : { a: number; 1: string; } +>t0 = t12, t0 = t13, t0 = t14, t0 = t15 : { a: number; 1: string; [s2]: boolean; } >t0 = t12, t0 = t13, t0 = t14 : T14 >t0 = t12, t0 = t13 : T13 >t0 = t12 : T12 @@ -387,9 +441,9 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; >t0 = t14 : T14 >t0 : T0 >t14 : T14 ->t0 = t15 : { a: number; 1: string; } +>t0 = t15 : { a: number; 1: string; [s2]: boolean; } >t0 : T0 ->t15 : { a: number; 1: string; } +>t15 : { a: number; 1: string; [s2]: boolean; } >t12 = t0 : T0 >t12 : T12 >t0 : T0 @@ -400,6 +454,30 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; >t14 : T14 >t0 : T0 >t15 = t0 : T0 ->t15 : { a: number; 1: string; } +>t15 : { a: number; 1: string; [s2]: boolean; } >t0 : T0 +// object literals +export const o1 = { +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>{ [c4]: 1, [c5]: "a", [s2]: true} : { [c4]: number; [c5]: string; [s2]: boolean; } + + [c4]: 1, +>c4 : "a" +>1 : 1 + + [c5]: "a", +>c5 : 1 +>"a" : "a" + + [s2]: true +>s2 : typeof s0 +>true : true + +}; + +export const o2: T0 = o1; +>o2 : T0 +>T0 : T0 +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } + diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index 124f9746757db..16ef6dc86747f 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2300: Duplicate identifier '1'. -tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2300: Duplicate identifier '1'. +tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2712: Duplicate declaration '[c0]'. +tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2712: Duplicate declaration '[c0]'. tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2711: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '[c0]' are incompatible. @@ -17,10 +17,10 @@ tests/cases/compiler/dynamicNamesErrors.ts(28,6): error TS4033: Property '[c0]' interface T0 { [c0]: number; ~~~~ -!!! error TS2300: Duplicate identifier '1'. +!!! error TS2712: Duplicate declaration '[c0]'. 1: number; ~ -!!! error TS2300: Duplicate identifier '1'. +!!! error TS2712: Duplicate declaration '[c0]'. } interface T1 { diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index 6330a7b304421..e8db8fe7404ab 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -1,79 +1,95 @@ // @target: esnext +// @lib: esnext // @module: commonjs // @declaration: true // @filename: module.ts export const c0 = "a"; export const c1 = 1; +export const s0 = Symbol(); export interface T0 { [c0]: number; [c1]: string; + [s0]: boolean; } export declare class T1 implements T2 { [c0]: number; [c1]: string; + [s0]: boolean; } export declare class T2 extends T1 { } export declare type T3 = { [c0]: number; [c1]: string; + [s0]: boolean; }; // @filename: main.ts -import { c0, c1, T0, T1, T2, T3 } from "./module"; +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; import * as M from "./module"; namespace N { export const c2 = "a"; export const c3 = 1; + export const s1 = s0; export interface T4 { [N.c2]: number; [N.c3]: string; + [N.s1]: boolean; } export declare class T5 implements T4 { [N.c2]: number; [N.c3]: string; + [N.s1]: boolean; } export declare class T6 extends T5 { } export declare type T7 = { [N.c2]: number; [N.c3]: string; + [N.s1]: boolean; }; } -const c4 = "a"; -const c5 = 1; +export const c4 = "a"; +export const c5 = 1; +export const s2 = s0; interface T8 { [c4]: number; [c5]: string; + [s2]: boolean; } declare class T9 implements T8 { [c4]: number; [c5]: string; + [s2]: boolean; } declare class T10 extends T9 { } declare type T11 = { [c4]: number; [c5]: string; + [s2]: boolean; }; interface T12 { a: number; 1: string; + [s2]: boolean; } declare class T13 implements T2 { a: number; 1: string; + [s2]: boolean; } declare class T14 extends T13 { } declare type T15 = { a: number; 1: string; + [s2]: boolean; }; let t0: T0; @@ -100,4 +116,13 @@ let t15: T15; // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; -t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; \ No newline at end of file +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; + +// object literals +export const o1 = { + [c4]: 1, + [c5]: "a", + [s2]: true +}; + +export const o2: T0 = o1; \ No newline at end of file From 93ea56bd25657eca7719fdb728161bb814844f83 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 5 May 2017 17:58:30 -0700 Subject: [PATCH 12/43] Improve union type reduction for symbol() --- src/compiler/checker.ts | 23 +++++++++++++---------- src/compiler/types.ts | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0775dcea29445..f38176696dcbf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5229,7 +5229,7 @@ namespace ts { function isLateBoundName(node: DeclarationName): node is LateBoundName { return isComputedPropertyName(node) && isEntityNameExpression(node.expression) - && (checkComputedPropertyName(node).flags & TypeFlags.PossiblyBindable) !== 0; + && (checkComputedPropertyName(node).flags & TypeFlags.StringOrNumberLiteralOrUnique) !== 0; } /** @@ -5304,7 +5304,7 @@ namespace ts { const memberSymbol = member.symbol; links.resolvedSymbol = memberSymbol || unknownSymbol; const type = checkComputedPropertyName(member.name); - if (type.flags & TypeFlags.PossiblyBindable) { + if (type.flags & TypeFlags.StringOrNumberLiteralOrUnique) { const memberName = getLateBoundNameFromType(type); let symbol = lateMembers.get(memberName); if (!symbol) { @@ -7131,7 +7131,8 @@ namespace ts { containsNonWideningType?: boolean; containsString?: boolean; containsNumber?: boolean; - containsStringOrNumberLiteral?: boolean; + containsESSymbol?: boolean; + containsStringOrNumberLiteralOrUnique?: boolean; containsObjectType?: boolean; containsEmptyObject?: boolean; unionIndex?: number; @@ -7177,7 +7178,8 @@ namespace ts { else if (!(flags & TypeFlags.Never)) { if (flags & TypeFlags.String) typeSet.containsString = true; if (flags & TypeFlags.Number) typeSet.containsNumber = true; - if (flags & TypeFlags.StringOrNumberLiteral) typeSet.containsStringOrNumberLiteral = true; + if (flags & TypeFlags.ESSymbol) typeSet.containsESSymbol = true; + if (flags & TypeFlags.StringOrNumberLiteralOrUnique) typeSet.containsStringOrNumberLiteralOrUnique = true; const len = typeSet.length; const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { @@ -7252,7 +7254,8 @@ namespace ts { const remove = t.flags & TypeFlags.StringLiteral && types.containsString || t.flags & TypeFlags.NumberLiteral && types.containsNumber || - t.flags & TypeFlags.StringOrNumberLiteral && t.flags & TypeFlags.Fresh && containsType(types, (t).regularType); + t.flags & TypeFlags.Unique && types.containsESSymbol || + t.flags & TypeFlags.StringOrNumberLiteralOrUnique && t.flags & TypeFlags.Fresh && containsType(types, getRegularTypeOfLiteralOrUniqueType(t)); if (remove) { orderedRemoveItemAt(types, i); } @@ -7281,7 +7284,7 @@ namespace ts { if (subtypeReduction) { removeSubtypes(typeSet); } - else if (typeSet.containsStringOrNumberLiteral) { + else if (typeSet.containsStringOrNumberLiteralOrUnique) { removeRedundantLiteralTypes(typeSet); } if (typeSet.length === 0) { @@ -7723,7 +7726,7 @@ namespace ts { } function getFreshTypeOfLiteralOrUniqueType(type: Type) { - if (type.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique) && !(type.flags & TypeFlags.Fresh)) { + if (type.flags & TypeFlags.StringOrNumberLiteralOrUnique && !(type.flags & TypeFlags.Fresh)) { if (!(type).freshType) { const freshType = type.flags & TypeFlags.Unique ? createUniqueType(type.symbol, TypeFlags.Fresh) @@ -7737,7 +7740,7 @@ namespace ts { } function getRegularTypeOfLiteralOrUniqueType(type: Type) { - return type.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique) && type.flags & TypeFlags.Fresh ? (type).regularType : type; + return type.flags & TypeFlags.StringOrNumberLiteralOrUnique && type.flags & TypeFlags.Fresh ? (type).regularType : type; } function getLiteralTypeForText(flags: TypeFlags, text: string) { @@ -13293,7 +13296,7 @@ namespace ts { let prop: TransientSymbol; if (hasLateBoundName(memberDecl)) { const nameType = checkComputedPropertyName(memberDecl.name); - if (nameType && nameType.flags & TypeFlags.PossiblyBindable) { + if (nameType && nameType.flags & TypeFlags.StringOrNumberLiteralOrUnique) { prop = createSymbol(SymbolFlags.Property | SymbolFlags.Late | member.flags, getLateBoundNameFromType(nameType)); } } @@ -22999,7 +23002,7 @@ namespace ts { name = getParseTreeNode(name, isComputedPropertyName); if (name) { const nameType = checkComputedPropertyName(name); - return (nameType.flags & (TypeFlags.StringOrNumberLiteral | TypeFlags.Unique)) !== 0; + return (nameType.flags & TypeFlags.StringOrNumberLiteralOrUnique) !== 0; } return false; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f4461ff6a7c39..d18e4c4e635ea 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3008,7 +3008,7 @@ namespace ts { Literal = StringLiteral | NumberLiteral | BooleanLiteral | EnumLiteral | Unique, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ - PossiblyBindable = StringOrNumberLiteral | Unique, + StringOrNumberLiteralOrUnique = StringOrNumberLiteral | Unique, /* @internal */ DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean, From 5854e8747686a57d5f5465b60731c746d25f59d7 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 8 Jun 2017 17:02:22 -0700 Subject: [PATCH 13/43] comment typo --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f85dc1e552ab..b9a167491d0e4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5415,7 +5415,7 @@ namespace ts { } /** - * Tests whether a declaration name is definately late-bindable. + * Tests whether a declaration name is definitely late-bindable. */ function isLateBoundName(node: DeclarationName): node is LateBoundName { return isComputedPropertyName(node) From 3f83b55899c3035738a61cb0ca3ba1e74cd8b4f9 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 8 Jun 2017 17:05:51 -0700 Subject: [PATCH 14/43] Added comments for fresh/regular unique symbol types --- src/compiler/checker.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b9a167491d0e4..edbe017be7ca3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4537,6 +4537,10 @@ namespace ts { } // If the type is a fresh, unique symbol type and is not the type for this symbol, get its regular type + // For example: + // + // const x = Symbol(); // fresh type, e.g. 'symbol()' + // const y = x; // regular type, e.g. 'typeof x' if (type.flags & TypeFlags.Unique && type.flags & TypeFlags.Fresh && type.symbol !== symbol) { type = (type).regularType; } From 38ee4751bf5f5e8e3b82730b1a1a3878df4a3cd1 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 9 Jun 2017 14:58:19 -0700 Subject: [PATCH 15/43] Fix escaping and follow symbols for element access --- src/compiler/checker.ts | 6 +++--- tests/baselines/reference/dynamicNames.js | 12 ++++++++++++ .../baselines/reference/dynamicNames.symbols | 18 +++++++++++++++++- tests/baselines/reference/dynamicNames.types | 19 +++++++++++++++++++ tests/cases/compiler/dynamicNames.ts | 5 +++++ 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index edbe017be7ca3..173bcc555fe4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5463,7 +5463,7 @@ namespace ts { return `__@${type.symbol.name}@${getSymbolId(type.symbol)}`; } if (type.flags & TypeFlags.StringOrNumberLiteral) { - return escapeIdentifier("" + (type).value); + return "" + (type).value; } } @@ -7686,8 +7686,8 @@ namespace ts { function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode, cacheSymbol: boolean) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; - const propName = indexType.flags & TypeFlags.StringOrNumberLiteral ? - "" + (indexType).value : + const propName = indexType.flags & TypeFlags.StringOrNumberLiteralOrUnique ? + getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? getPropertyNameForKnownSymbolName(((accessExpression.argumentExpression).name).text) : undefined; diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index 4f79d7df0fc89..41b57f57908ae 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -123,6 +123,11 @@ export const o1 = { [s2]: true }; +// check element access types +export const o1_c4 = o1[c4]; +export const o1_c5 = o1[c5]; +export const o1_s2 = o1[s2]; + export const o2: T0 = o1; //// [module.js] @@ -174,6 +179,10 @@ exports.o1 = { [exports.c5]: "a", [exports.s2]: true }; +// check element access types +exports.o1_c4 = exports.o1[exports.c4]; +exports.o1_c5 = exports.o1[exports.c5]; +exports.o1_s2 = exports.o1[exports.s2]; exports.o2 = exports.o1; @@ -208,4 +217,7 @@ export declare const o1: { [c5]: string; [s2]: boolean; }; +export declare const o1_c4: number; +export declare const o1_c5: string; +export declare const o1_s2: boolean; export declare const o2: T0; diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index 5d917aa1e6fe9..056c77843fee7 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -404,8 +404,24 @@ export const o1 = { }; +// check element access types +export const o1_c4 = o1[c4]; +>o1_c4 : Symbol(o1_c4, Decl(main.ts, 101, 12)) +>o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + +export const o1_c5 = o1[c5]; +>o1_c5 : Symbol(o1_c5, Decl(main.ts, 102, 12)) +>o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + +export const o1_s2 = o1[s2]; +>o1_s2 : Symbol(o1_s2, Decl(main.ts, 103, 12)) +>o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) + export const o2: T0 = o1; ->o2 : Symbol(o2, Decl(main.ts, 100, 12)) +>o2 : Symbol(o2, Decl(main.ts, 105, 12)) >T0 : Symbol(T0, Decl(main.ts, 0, 20)) >o1 : Symbol(o1, Decl(main.ts, 94, 12)) diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index af5e34d44049c..058585be7da58 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -476,6 +476,25 @@ export const o1 = { }; +// check element access types +export const o1_c4 = o1[c4]; +>o1_c4 : number +>o1[c4] : number +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>c4 : "a" + +export const o1_c5 = o1[c5]; +>o1_c5 : string +>o1[c5] : string +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>c5 : 1 + +export const o1_s2 = o1[s2]; +>o1_s2 : boolean +>o1[s2] : boolean +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>s2 : typeof s0 + export const o2: T0 = o1; >o2 : T0 >T0 : T0 diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index e8db8fe7404ab..3bf663892a73b 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -125,4 +125,9 @@ export const o1 = { [s2]: true }; +// check element access types +export const o1_c4 = o1[c4]; +export const o1_c5 = o1[c5]; +export const o1_s2 = o1[s2]; + export const o2: T0 = o1; \ No newline at end of file From 891e71d44f888a2afdb563a40ec6f4527fd0c01d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 22 Sep 2017 15:08:55 -0700 Subject: [PATCH 16/43] Remove freshness, more comprehensive grammar checks and diagnostic messages --- src/compiler/checker.ts | 349 ++++++++------- src/compiler/declarationEmitter.ts | 2 +- src/compiler/diagnosticMessages.json | 50 ++- src/compiler/emitter.ts | 2 +- src/compiler/factory.ts | 4 + src/compiler/parser.ts | 2 +- src/compiler/types.ts | 30 +- src/compiler/utilities.ts | 5 + ...pturedParametersInInitializers2.errors.txt | 4 +- .../classWithDuplicateIdentifier.errors.txt | 4 +- .../reference/complicatedPrivacy.errors.txt | 4 +- .../computedPropertyNames12_ES5.errors.txt | 36 +- .../computedPropertyNames12_ES6.errors.txt | 36 +- .../computedPropertyNames35_ES5.errors.txt | 4 +- .../computedPropertyNames35_ES6.errors.txt | 4 +- ...opertyNamesDeclarationEmit3_ES5.errors.txt | 4 +- ...opertyNamesDeclarationEmit3_ES6.errors.txt | 4 +- ...opertyNamesDeclarationEmit4_ES5.errors.txt | 4 +- ...opertyNamesDeclarationEmit4_ES6.errors.txt | 4 +- ...tedPropertyNamesOnOverloads_ES5.errors.txt | 8 +- ...tedPropertyNamesOnOverloads_ES6.errors.txt | 8 +- .../duplicateClassElements.errors.txt | 4 +- tests/baselines/reference/dynamicNames.js | 4 +- .../baselines/reference/dynamicNames.symbols | 18 +- tests/baselines/reference/dynamicNames.types | 50 ++- .../reference/dynamicNamesErrors.errors.txt | 12 +- .../gettersAndSettersErrors.errors.txt | 4 +- tests/baselines/reference/giant.errors.txt | 32 +- ...SignatureMustHaveTypeAnnotation.errors.txt | 8 +- .../indexSignatureWithInitializer.errors.txt | 8 +- .../indexWithoutParamType2.errors.txt | 4 +- .../interfaceDeclaration1.errors.txt | 4 +- ...cesWithConflictingPropertyNames.errors.txt | 12 +- ...cStringNamedPropertyEquivalence.errors.txt | 4 +- .../parserComputedPropertyName10.errors.txt | 4 +- .../parserComputedPropertyName11.errors.txt | 4 +- .../parserComputedPropertyName13.errors.txt | 4 +- .../parserComputedPropertyName14.errors.txt | 4 +- .../parserComputedPropertyName15.errors.txt | 4 +- .../parserComputedPropertyName18.errors.txt | 4 +- .../parserComputedPropertyName19.errors.txt | 4 +- .../parserComputedPropertyName20.errors.txt | 4 +- .../parserComputedPropertyName21.errors.txt | 4 +- .../parserComputedPropertyName22.errors.txt | 4 +- .../parserComputedPropertyName25.errors.txt | 4 +- .../parserComputedPropertyName28.errors.txt | 8 +- .../parserComputedPropertyName29.errors.txt | 8 +- .../parserComputedPropertyName31.errors.txt | 8 +- .../parserComputedPropertyName32.errors.txt | 4 +- .../parserComputedPropertyName36.errors.txt | 4 +- .../parserComputedPropertyName7.errors.txt | 4 +- .../parserComputedPropertyName8.errors.txt | 4 +- .../parserComputedPropertyName9.errors.txt | 4 +- .../parserES5ComputedPropertyName1.errors.txt | 4 +- ...parserES5ComputedPropertyName10.errors.txt | 4 +- ...parserES5ComputedPropertyName11.errors.txt | 4 +- .../parserES5ComputedPropertyName5.errors.txt | 4 +- .../parserES5ComputedPropertyName7.errors.txt | 4 +- .../parserES5ComputedPropertyName8.errors.txt | 4 +- .../parserES5ComputedPropertyName9.errors.txt | 4 +- .../parserIndexSignature11.errors.txt | 4 +- .../parserIndexSignature4.errors.txt | 4 +- .../parserIndexSignature5.errors.txt | 4 +- .../reference/propertyAssignment.errors.txt | 4 +- .../reference/reassignStaticProp.errors.txt | 4 +- .../reference/symbolProperty7.errors.txt | 8 +- tests/baselines/reference/uniqueSymbols.js | 275 ++++++++++++ .../baselines/reference/uniqueSymbols.symbols | 398 +++++++++++++++++ tests/baselines/reference/uniqueSymbols.types | 416 ++++++++++++++++++ .../reference/uniqueSymbolsErrors.errors.txt | 265 +++++++++++ .../reference/uniqueSymbolsErrors.js | 110 +++++ tests/cases/compiler/dynamicNames.ts | 4 +- .../types/uniqueSymbol/uniqueSymbols.ts | 117 +++++ .../types/uniqueSymbol/uniqueSymbolsErrors.ts | 86 ++++ 74 files changed, 2156 insertions(+), 391 deletions(-) create mode 100644 tests/baselines/reference/uniqueSymbols.js create mode 100644 tests/baselines/reference/uniqueSymbols.symbols create mode 100644 tests/baselines/reference/uniqueSymbols.types create mode 100644 tests/baselines/reference/uniqueSymbolsErrors.errors.txt create mode 100644 tests/baselines/reference/uniqueSymbolsErrors.js create mode 100644 tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts create mode 100644 tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f250404356676..d4baf3fe67150 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -630,6 +630,15 @@ namespace ts { } } + function combineSymbolTables(first: SymbolTable | undefined, second: SymbolTable | undefined): SymbolTable | undefined { + if (!first || first.size === 0) return second; + if (!second || second.size === 0) return first; + const combined = createSymbolTable(); + mergeSymbolTable(combined, first); + mergeSymbolTable(combined, second); + return combined; + } + function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { source.forEach((sourceSymbol, id) => { let targetSymbol = target.get(id); @@ -751,7 +760,7 @@ namespace ts { const classDeclaration = parameter.parent.parent; const parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, SymbolFlags.Value); - const propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, SymbolFlags.Value); + const propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, SymbolFlags.Value); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; @@ -2479,10 +2488,8 @@ namespace ts { if (type.flags & TypeFlags.BooleanLiteral) { return (type).intrinsicName === "true" ? createTrue() : createFalse(); } - if (type.flags & TypeFlags.Unique) { - return type.flags & TypeFlags.Fresh - ? createToken(SyntaxKind.SymbolType) - : createTypeQueryNodeFromSymbol(type.symbol, SymbolFlags.Value); + if (type.flags & TypeFlags.UniqueESSymbol) { + return createESSymbolTypeNode(); } if (type.flags & TypeFlags.Void) { return createKeywordTypeNode(SyntaxKind.VoidKeyword); @@ -3297,15 +3304,10 @@ namespace ts { else if (getObjectFlags(type) & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { writeAnonymousType(type, nextFlags); } - else if (type.flags & TypeFlags.Unique) { - if (type.flags & TypeFlags.Fresh) { - writeKeyword(writer, SyntaxKind.SymbolKeyword); - writePunctuation(writer, SyntaxKind.OpenParenToken); - writePunctuation(writer, SyntaxKind.CloseParenToken); - } - else { - writeTypeOfSymbol(type.symbol, flags); - } + else if (type.flags & TypeFlags.UniqueESSymbol) { + writeKeyword(writer, SyntaxKind.SymbolKeyword); + writePunctuation(writer, SyntaxKind.OpenParenToken); + writePunctuation(writer, SyntaxKind.CloseParenToken); } else if (type.flags & TypeFlags.StringOrNumberLiteral) { writer.writeStringLiteral(literalTypeToString(type)); @@ -4522,6 +4524,12 @@ namespace ts { if (reportErrors) { reportErrorsFromWidening(declaration, type); } + + // always widen a unique 'symbol()' type if the type was created for a different declaration. + if (type.flags & TypeFlags.UniqueESSymbol && !declaration.type && type.symbol !== getSymbolOfNode(declaration)) { + type = esSymbolType; + } + // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. @@ -4590,16 +4598,6 @@ namespace ts { if (!popTypeResolution()) { type = reportCircularityError(symbol); } - - // If the type is a fresh, unique symbol type and is not the type for this symbol, get its regular type - // For example: - // - // const x = Symbol(); // fresh type, e.g. 'symbol()' - // const y = x; // regular type, e.g. 'typeof x' - if (type.flags & TypeFlags.Unique && type.flags & TypeFlags.Fresh && type.symbol !== symbol) { - type = (type).regularType; - } - links.type = type; } return links.type; @@ -5417,9 +5415,10 @@ namespace ts { function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers { if (!(type).declaredProperties) { const symbol = type.symbol; + const members = getMembersOfSymbol(symbol); (type).declaredProperties = getNamedMembers(getMembersOfSymbol(symbol)); - (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.Call)); - (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.New)); + (type).declaredCallSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.Call)); + (type).declaredConstructSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.New)); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); (type).declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); } @@ -5439,16 +5438,7 @@ namespace ts { lateBindMembers(lateMembers, decl); } } - if (!lateMembers || lateMembers.size === 0) { - return links.resolvedMembers = symbol.members || emptySymbols; - } - if (!symbol.members || symbol.members.size === 0) { - return links.resolvedMembers = lateMembers; - } - const resolvedMembers = createUnderscoreEscapedMap(); - mergeSymbolTable(resolvedMembers, symbol.members); - mergeSymbolTable(resolvedMembers, lateMembers); - return links.resolvedMembers = resolvedMembers; + links.resolvedMembers = combineSymbolTables(symbol.members, lateMembers) || emptySymbols; } return links.resolvedMembers; } @@ -5456,7 +5446,7 @@ namespace ts { /** * Gets the late-bound members of a symbol. */ - function getLateBoundMembersOfSymbol(symbol: Symbol) { + function getLateBoundMembersOfSymbol(symbol: Symbol): UnderscoreEscapedMap | undefined { if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral)) { const links = getSymbolLinks(symbol); return links.lateMembers || (links.lateMembers = createUnderscoreEscapedMap()); @@ -5477,7 +5467,11 @@ namespace ts { function isLateBoundName(node: DeclarationName): node is LateBoundName { return isComputedPropertyName(node) && isEntityNameExpression(node.expression) - && (checkComputedPropertyName(node).flags & TypeFlags.StringOrNumberLiteralOrUnique) !== 0; + && isLateBoundNameType(checkComputedPropertyName(node)); + } + + function isLateBoundNameType(type: Type): type is LiteralType | UniqueESSymbolType { + return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique); } /** @@ -5511,8 +5505,8 @@ namespace ts { /** * Gets the symbolic name for a late-bound member from its type. */ - function getLateBoundNameFromType(type: Type) { - if (type.flags & TypeFlags.Unique) { + function getLateBoundNameFromType(type: LiteralType | UniqueESSymbolType) { + if (type.flags & TypeFlags.UniqueESSymbol) { return `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String; } if (type.flags & TypeFlags.StringOrNumberLiteral) { @@ -5552,7 +5546,7 @@ namespace ts { const memberSymbol = member.symbol; links.resolvedSymbol = memberSymbol || unknownSymbol; const type = checkComputedPropertyName(member.name); - if (type.flags & TypeFlags.StringOrNumberLiteralOrUnique) { + if (isLateBoundNameType(type)) { const memberName = getLateBoundNameFromType(type); let symbol = lateMembers.get(memberName); if (!symbol) { @@ -5633,7 +5627,7 @@ namespace ts { } const baseTypes = getBaseTypes(source); if (baseTypes.length) { - if (source.symbol && members === source.symbol.members) { + if (source.symbol && members === getMembersOfSymbol(source.symbol)) { members = createSymbolTable(source.declaredProperties); } const thisArgument = lastOrUndefined(typeArguments); @@ -7464,7 +7458,7 @@ namespace ts { containsString?: boolean; containsNumber?: boolean; containsESSymbol?: boolean; - containsStringOrNumberLiteralOrUnique?: boolean; + containsStringOrNumberLiteralOrUniqueESSymbol?: boolean; containsObjectType?: boolean; containsEmptyObject?: boolean; unionIndex?: number; @@ -7531,7 +7525,7 @@ namespace ts { if (flags & TypeFlags.String) typeSet.containsString = true; if (flags & TypeFlags.Number) typeSet.containsNumber = true; if (flags & TypeFlags.ESSymbol) typeSet.containsESSymbol = true; - if (flags & TypeFlags.StringOrNumberLiteralOrUnique) typeSet.containsStringOrNumberLiteralOrUnique = true; + if (flags & TypeFlags.StringOrNumberLiteralOrUnique) typeSet.containsStringOrNumberLiteralOrUniqueESSymbol = true; const len = typeSet.length; const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { @@ -7606,8 +7600,8 @@ namespace ts { const remove = t.flags & TypeFlags.StringLiteral && types.containsString || t.flags & TypeFlags.NumberLiteral && types.containsNumber || - t.flags & TypeFlags.Unique && types.containsESSymbol || - t.flags & TypeFlags.StringOrNumberLiteralOrUnique && t.flags & TypeFlags.Fresh && containsType(types, getRegularTypeOfLiteralOrUniqueType(t)); + t.flags & TypeFlags.UniqueESSymbol && types.containsESSymbol || + t.flags & TypeFlags.StringOrNumberLiteral && t.flags & TypeFlags.FreshLiteral && containsType(types, (t).regularType); if (remove) { orderedRemoveItemAt(types, i); } @@ -7636,7 +7630,7 @@ namespace ts { if (subtypeReduction) { removeSubtypes(typeSet); } - else if (typeSet.containsStringOrNumberLiteralOrUnique) { + else if (typeSet.containsStringOrNumberLiteralOrUniqueESSymbol) { removeRedundantLiteralTypes(typeSet); } if (typeSet.length === 0) { @@ -7823,8 +7817,7 @@ namespace ts { function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode, cacheSymbol: boolean) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; - const propName = indexType.flags & TypeFlags.StringOrNumberLiteralOrUnique ? - getLateBoundNameFromType(indexType) : + const propName = isLateBoundNameType(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? getPropertyNameForKnownSymbolName(unescapeLeadingUnderscores(((accessExpression.argumentExpression).name).escapedText)) : undefined; @@ -8137,22 +8130,20 @@ namespace ts { return type; } - function getFreshTypeOfLiteralOrUniqueType(type: Type) { - if (type.flags & TypeFlags.StringOrNumberLiteralOrUnique && !(type.flags & TypeFlags.Fresh)) { - if (!(type).freshType) { - const freshType = type.flags & TypeFlags.Unique - ? createUniqueType(type.symbol, TypeFlags.Fresh) - : createLiteralType(type.flags | TypeFlags.Fresh, (type).value, (type).symbol); - freshType.regularType = type; - (type).freshType = freshType; + function getFreshTypeOfLiteralType(type: Type) { + if (type.flags & TypeFlags.StringOrNumberLiteral && !(type.flags & TypeFlags.FreshLiteral)) { + if (!(type).freshType) { + const freshType = createLiteralType(type.flags | TypeFlags.FreshLiteral, (type).value, (type).symbol); + freshType.regularType = type; + (type).freshType = freshType; } - return (type).freshType; + return (type).freshType; } return type; } - function getRegularTypeOfLiteralOrUniqueType(type: Type) { - return type.flags & TypeFlags.StringOrNumberLiteralOrUnique && type.flags & TypeFlags.Fresh ? (type).regularType : type; + function getRegularTypeOfLiteralType(type: Type) { + return type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral ? (type).regularType : type; } function getLiteralType(value: string | number, enumId?: number, symbol?: Symbol) { @@ -8173,36 +8164,63 @@ namespace ts { function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getRegularTypeOfLiteralOrUniqueType(checkExpression(node.literal)); + links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal)); } return links.resolvedType; } - function getTypeFromSymbolTypeNode(node: SymbolTypeNode): Type { - const parent = node.parent; - if (parent.kind === SyntaxKind.VariableDeclaration || - parent.kind === SyntaxKind.PropertyDeclaration || - parent.kind === SyntaxKind.PropertySignature || - parent.kind === SyntaxKind.PropertyAssignment) { - const symbol = getSymbolOfNode(parent); - if (symbol) return getUniqueTypeForSymbol(symbol); - } - return esSymbolType; - } - - function getRegularTypeOfUniqueType(type: Type) { - return type.flags & TypeFlags.Unique && type.flags & TypeFlags.Fresh ? (type).regularType : type; + function getWidenedTypeOfUniqueESSymbolType(type: Type): Type { + return type.flags & TypeFlags.UniqueESSymbol ? esSymbolType : + type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedTypeOfUniqueESSymbolType)) : + type.flags & TypeFlags.Intersection ? getIntersectionType(sameMap((type).types, getWidenedTypeOfUniqueESSymbolType)) : + type; } - function createUniqueType(symbol: Symbol, flags?: TypeFlags) { - const type = createType(TypeFlags.Unique | flags); + function createUniqueESSymbolType(symbol: Symbol) { + const type = createType(TypeFlags.UniqueESSymbol); type.symbol = symbol; return type; } - function getUniqueTypeForSymbol(symbol: Symbol) { - const links = getSymbolLinks(symbol); - return links.type || (links.type = createUniqueType(symbol)); + function isReferenceToValidDeclarationForUniqueESSymbol(symbol: Symbol) { + if (symbol.valueDeclaration) { + switch (symbol.valueDeclaration.kind) { + case SyntaxKind.VariableDeclaration: + return getNameOfDeclaration(symbol.valueDeclaration).kind === SyntaxKind.Identifier + && symbol.valueDeclaration.parent.kind === SyntaxKind.VariableDeclarationList + && symbol.valueDeclaration.parent.parent.kind === SyntaxKind.VariableStatement + && !!(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)) { + const links = getSymbolLinks(symbol); + return links.type || (links.type = createUniqueESSymbolType(symbol)); + } + return esSymbolType; + } + + function getTypeFromESSymbolTypeNode(node: ESSymbolTypeNode): Type { + const links = getNodeLinks(node); + if (!links.resolvedType) { + const parent = skipParentheses(node).parent; + const symbol = getSymbolOfNode(parent); + if (symbol) { + links.resolvedType = getUniqueESSymbolTypeForSymbol(symbol); + } + else { + links.resolvedType = esSymbolType; + } + } + return links.resolvedType; } function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { @@ -8264,8 +8282,8 @@ namespace ts { return getTypeFromThisTypeNode(node as ThisExpression | ThisTypeNode); case SyntaxKind.LiteralType: return getTypeFromLiteralTypeNode(node); - case SyntaxKind.SymbolType: - return getTypeFromSymbolTypeNode(node); + case SyntaxKind.ESSymbolType: + return getTypeFromESSymbolTypeNode(node); case SyntaxKind.TypeReference: return getTypeFromTypeReference(node); case SyntaxKind.TypePredicate: @@ -9003,7 +9021,7 @@ namespace ts { if (s & TypeFlags.Undefined && (!strictNullChecks || t & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (s & TypeFlags.Null && (!strictNullChecks || t & TypeFlags.Null)) return true; if (s & TypeFlags.Object && t & TypeFlags.NonPrimitive) return true; - if (s & TypeFlags.Unique || t & TypeFlags.Unique) return false; + if (s & TypeFlags.UniqueESSymbol || t & TypeFlags.UniqueESSymbol) return false; if (relation === assignableRelation || relation === comparableRelation) { if (s & TypeFlags.Any) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any @@ -9016,8 +9034,8 @@ namespace ts { } function isTypeRelatedTo(source: Type, target: Type, relation: Map) { - source = getRegularTypeOfLiteralOrUniqueType(source); - target = getRegularTypeOfLiteralOrUniqueType(target); + source = getRegularTypeOfLiteralType(source); + target = getRegularTypeOfLiteralType(target); if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } @@ -9148,8 +9166,8 @@ namespace ts { * * Ternary.False if they are not related. */ function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { - source = getRegularTypeOfLiteralOrUniqueType(source); - target = getRegularTypeOfLiteralOrUniqueType(target); + source = getRegularTypeOfLiteralType(source); + target = getRegularTypeOfLiteralType(target); // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; @@ -9159,7 +9177,7 @@ namespace ts { if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True; - if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.Fresh) { + if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -10315,9 +10333,8 @@ namespace ts { function getWidenedLiteralType(type: Type): Type { return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : - type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.Fresh ? stringType : - type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.Fresh ? numberType : - type.flags & TypeFlags.Unique && type.flags & TypeFlags.Fresh ? esSymbolType : + type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : + type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : type.flags & TypeFlags.BooleanLiteral ? booleanType : type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedLiteralType)) : type; @@ -10425,7 +10442,7 @@ namespace ts { * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type: Type): Type { - if (!(getObjectFlags(type) & ObjectFlags.ObjectLiteral && type.flags & TypeFlags.Fresh)) { + if (!(getObjectFlags(type) & ObjectFlags.ObjectLiteral && type.flags & TypeFlags.FreshLiteral)) { return type; } const regularType = (type).regularType; @@ -10441,7 +10458,7 @@ namespace ts { resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~TypeFlags.Fresh; + regularNew.flags = resolved.flags & ~TypeFlags.FreshLiteral; regularNew.objectFlags |= ObjectFlags.ObjectLiteral; (type).regularType = regularNew; return regularNew; @@ -11067,7 +11084,7 @@ namespace ts { } } } - return inferredType; + return getWidenedTypeOfUniqueESSymbolType(inferredType); } function getDefaultTypeArgumentType(isInJavaScriptFile: boolean): Type { @@ -11515,7 +11532,7 @@ namespace ts { function getTypeOfSwitchClause(clause: CaseClause | DefaultClause) { if (clause.kind === SyntaxKind.CaseClause) { - const caseType = getRegularTypeOfLiteralOrUniqueType(getTypeOfExpression((clause).expression)); + const caseType = getRegularTypeOfLiteralType(getTypeOfExpression((clause).expression)); return isUnitType(caseType) ? caseType : undefined; } return neverType; @@ -12160,8 +12177,8 @@ namespace ts { return narrowedType.flags & TypeFlags.Never ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { - const regularType = getRegularTypeOfLiteralOrUniqueType(valueType); - return filterType(type, t => getRegularTypeOfLiteralOrUniqueType(t) !== regularType); + const regularType = getRegularTypeOfLiteralType(valueType); + return filterType(type, t => getRegularTypeOfLiteralType(t) !== regularType); } return type; } @@ -12218,7 +12235,7 @@ namespace ts { if (!hasDefaultClause) { return caseType; } - const defaultType = filterType(type, t => !(isUnitType(t) && contains(switchTypes, getRegularTypeOfLiteralOrUniqueType(t)))); + const defaultType = filterType(type, t => !(isUnitType(t) && contains(switchTypes, getRegularTypeOfLiteralType(t)))); return caseType.flags & TypeFlags.Never ? defaultType : getUnionType([caseType, defaultType]); } @@ -13700,7 +13717,7 @@ namespace ts { else { const elementContextualType = getContextualTypeForElementExpression(contextualType, index); const type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); - elementTypes.push(type); + elementTypes.push(getWidenedTypeOfUniqueESSymbolType(type)); } hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElement; } @@ -13882,7 +13899,7 @@ namespace ts { let prop: TransientSymbol; if (hasLateBoundName(memberDecl)) { const nameType = checkComputedPropertyName(memberDecl.name); - if (nameType && nameType.flags & TypeFlags.StringOrNumberLiteralOrUnique) { + if (nameType && isLateBoundNameType(nameType)) { prop = createSymbol(SymbolFlags.Property | SymbolFlags.Late | member.flags, getLateBoundNameFromType(nameType)); } } @@ -13994,7 +14011,7 @@ namespace ts { if (spread.flags & TypeFlags.Object) { // only set the symbol and flags if this is a (fresh) object type spread.flags |= propagatedFlags; - spread.flags |= TypeFlags.Fresh; + spread.flags |= TypeFlags.FreshLiteral; (spread as ObjectType).objectFlags |= ObjectFlags.ObjectLiteral; spread.symbol = node.symbol; } @@ -14007,7 +14024,7 @@ namespace ts { const stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; const numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.Fresh; + const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); result.objectFlags |= ObjectFlags.ObjectLiteral; if (patternWithComputedProperties) { @@ -16832,11 +16849,8 @@ namespace ts { // as a fresh unique symbol literal type. if (returnType.flags & TypeFlags.ESSymbolLike && isSymbolOrSymbolForCall(node)) { const parent = skipParentheses(node).parent; - if ((parent.kind === SyntaxKind.VariableDeclaration && parent.parent.flags & NodeFlags.Const) || - (parent.kind === SyntaxKind.PropertyDeclaration && hasModifier(parent, ModifierFlags.Readonly))) { - const symbol = getSymbolOfNode(parent); - if (symbol) return getFreshTypeOfLiteralOrUniqueType(getUniqueTypeForSymbol(symbol)); - } + const symbol = getSymbolOfNode(parent); + if (symbol) return getUniqueESSymbolTypeForSymbol(symbol); } return returnType; } @@ -17117,7 +17131,7 @@ namespace ts { const functionFlags = getFunctionFlags(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { - type = getRegularTypeOfUniqueType(checkExpressionCached(func.body, checkMode)); + type = checkExpressionCached(func.body, checkMode); if (functionFlags & FunctionFlags.Async) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -17125,6 +17139,9 @@ namespace ts { // the native Promise type later in this function. type = checkAwaitedType(type, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } + + // widen 'symbol()' types when we infer the return type. + type = getWidenedTypeOfUniqueESSymbolType(type); } else { let types: Type[]; @@ -17157,7 +17174,10 @@ namespace ts { } } // Return a union of the return expression types. - type = getUnionType(map(types, getRegularTypeOfUniqueType), /*subtypeReduction*/ true); + type = getUnionType(types, /*subtypeReduction*/ true); + + // widen 'symbol()' types when we infer the return type. + type = getWidenedTypeOfUniqueESSymbolType(type); if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function type = functionFlags & FunctionFlags.Async @@ -17170,12 +17190,11 @@ namespace ts { reportErrorsFromWidening(func, type); } - if (isUnitType(type)) { - if (!(contextualSignature && + if (isUnitType(type) && + !(contextualSignature && isLiteralContextualType( contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { - type = getWidenedLiteralType(type); - } + type = getWidenedLiteralType(type); } const widenedType = getWidenedType(type); @@ -17222,7 +17241,7 @@ namespace ts { if (!switchTypes.length) { return false; } - return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralOrUniqueType), switchTypes); + return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func: FunctionLikeDeclaration) { @@ -17549,10 +17568,10 @@ namespace ts { } if (node.operand.kind === SyntaxKind.NumericLiteral) { if (node.operator === SyntaxKind.MinusToken) { - return getFreshTypeOfLiteralOrUniqueType(getLiteralType(-(node.operand).text)); + return getFreshTypeOfLiteralType(getLiteralType(-(node.operand).text)); } else if (node.operator === SyntaxKind.PlusToken) { - return getFreshTypeOfLiteralOrUniqueType(getLiteralType(+(node.operand).text)); + return getFreshTypeOfLiteralType(getLiteralType(+(node.operand).text)); } } switch (node.operator) { @@ -18431,10 +18450,10 @@ namespace ts { return nullWideningType; case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.StringLiteral: - return getFreshTypeOfLiteralOrUniqueType(getLiteralType((node as LiteralExpression).text)); + return getFreshTypeOfLiteralType(getLiteralType((node as LiteralExpression).text)); case SyntaxKind.NumericLiteral: checkGrammarNumericLiteral(node as NumericLiteral); - return getFreshTypeOfLiteralOrUniqueType(getLiteralType(+(node as NumericLiteral).text)); + return getFreshTypeOfLiteralType(getLiteralType(+(node as NumericLiteral).text)); case SyntaxKind.TrueKeyword: return trueType; case SyntaxKind.FalseKeyword: @@ -19236,8 +19255,8 @@ namespace ts { checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } - function checkSymbolType(node: SymbolTypeNode) { - checkGrammarSymbolTypeNode(node); + function checkSymbolType(node: ESSymbolTypeNode) { + checkGrammarESSymbolTypeNode(node); } function isPrivateWithinAmbient(node: Node): boolean { @@ -22795,8 +22814,8 @@ namespace ts { return checkIndexedAccessType(node); case SyntaxKind.MappedType: return checkMappedType(node); - case SyntaxKind.SymbolType: - return checkSymbolType(node); + case SyntaxKind.ESSymbolType: + return checkSymbolType(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); case SyntaxKind.Block: @@ -23548,7 +23567,7 @@ namespace ts { if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { expr = expr.parent; } - return getRegularTypeOfLiteralOrUniqueType(getTypeOfExpression(expr)); + return getRegularTypeOfLiteralType(getTypeOfExpression(expr)); } /** @@ -23991,14 +24010,7 @@ namespace ts { let type: Type = unknownType; if (symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature))) { type = getTypeOfSymbol(symbol); - if (type.flags & TypeFlags.Unique) { - if (type.symbol !== symbol) { - type = getRegularTypeOfUniqueType(type); - } - } - else { - type = getWidenedLiteralType(type); - } + type = getWidenedLiteralType(type); } if (flags & TypeFormatFlags.AddUndefined) { type = getNullableType(type, TypeFlags.Undefined); @@ -24065,7 +24077,7 @@ namespace ts { function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { if (isConst(node)) { const type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.Fresh); + return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral); } return false; } @@ -25116,21 +25128,58 @@ namespace ts { } } - function checkGrammarSymbolTypeNode(node: SymbolTypeNode) { - const parent = node.parent; - if (parent.kind !== SyntaxKind.VariableDeclaration && - parent.kind !== SyntaxKind.PropertyDeclaration && - parent.kind !== SyntaxKind.PropertySignature && - parent.kind !== SyntaxKind.PropertyAssignment) { - return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_are_only_allowed_on_variables_and_properties); + function checkGrammarESSymbolTypeNode(node: ESSymbolTypeNode) { + let parent = node.parent; + while (parent.kind === SyntaxKind.ParenthesizedType) { + parent = parent.parent; } - if (parent.kind === SyntaxKind.VariableDeclaration && - (parent).name.kind !== SyntaxKind.Identifier) { - return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); + + switch (parent.kind) { + case SyntaxKind.VariableDeclaration: + const decl = parent as VariableDeclaration; + if (decl.name.kind !== SyntaxKind.Identifier) { + return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); + } + if (!isVariableDeclarationInVariableStatement(decl)) { + return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); + } + if (!(decl.parent.flags & NodeFlags.Const)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); + } + break; + + case SyntaxKind.PropertyDeclaration: + if (!hasModifier(parent, ModifierFlags.Static) || + !hasModifier(parent, ModifierFlags.Readonly)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); + } + break; + + case SyntaxKind.PropertySignature: + if (!hasModifier(parent, ModifierFlags.Readonly)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); + } + break; + + // report specific errors for cases where a `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); } } - function checkGrammarForNonSymbolComputedProperty(node: DeclarationName, message: DiagnosticMessage) { + function checkGrammarForInvalidDynamicName(node: DeclarationName, message: DiagnosticMessage) { if (isUnboundDynamicName(node)) { return grammarErrorOnNode(node, message); } @@ -25159,17 +25208,17 @@ namespace ts { // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. if (isInAmbientContext(node)) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (!node.body) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (node.parent.kind === SyntaxKind.TypeLiteral) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -25421,12 +25470,12 @@ namespace ts { function checkGrammarProperty(node: PropertyDeclaration) { if (isClassLike(node.parent)) { - if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { + if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } } else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { - if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { + if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } if (node.initializer) { @@ -25434,7 +25483,7 @@ namespace ts { } } else if (node.parent.kind === SyntaxKind.TypeLiteral) { - if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { + if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } if (node.initializer) { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 32acc02839705..3fb1a5d976e13 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -425,7 +425,7 @@ namespace ts { case SyntaxKind.ThisType: case SyntaxKind.LiteralType: return writeTextOfNode(currentText, type); - case SyntaxKind.SymbolType: + case SyntaxKind.ESSymbolType: return write("symbol()"); case SyntaxKind.ExpressionWithTypeArguments: return emitExpressionWithTypeArguments(type); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 39bc5c0382bd6..908e18d3786e0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -491,23 +491,23 @@ "category": "Error", "code": 1164 }, - "A computed property name in an ambient context must directly refer to a built-in symbol.": { + "A computed property name in an ambient context must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { "category": "Error", "code": 1165 }, - "A computed property name in a class property declaration must directly refer to a built-in symbol.": { + "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { "category": "Error", "code": 1166 }, - "A computed property name in a method overload must directly refer to a built-in symbol.": { + "A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { "category": "Error", "code": 1168 }, - "A computed property name in an interface must directly refer to a built-in symbol.": { + "A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { "category": "Error", "code": 1169 }, - "A computed property name in a type literal must directly refer to a built-in symbol.": { + "A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { "category": "Error", "code": 1170 }, @@ -907,14 +907,50 @@ "category": "Error", "code": 1328 }, - "Unique 'symbol()' types are only allowed on variables and properties.": { + "Unique 'symbol()' types are not allowed in a union type.": { "category": "Error", "code": 1329 }, - "Unique 'symbol()' types may not be used on a variable declaration with a binding name.": { + "Unique 'symbol()' types are not allowed in an intersection type.": { "category": "Error", "code": 1330 }, + "Unique 'symbol()' types are not allowed in an array type.": { + "category": "Error", + "code": 1331 + }, + "Unique 'symbol()' types are not allowed in a tuple type.": { + "category": "Error", + "code": 1332 + }, + "Unique 'symbol()' types are not allowed in a mapped type.": { + "category": "Error", + "code": 1333 + }, + "A property of an interface or type literal whose type is a unique 'symbol()' type must be 'readonly'.": { + "category": "Error", + "code": 1334 + }, + "A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'.": { + "category": "Error", + "code": 1335 + }, + "A variable whose type is a unique 'symbol()' type must be 'const'.": { + "category": "Error", + "code": 1336 + }, + "Unique 'symbol()' types may not be used on a variable declaration with a binding name.": { + "category": "Error", + "code": 1337 + }, + "Unique 'symbol()' types are only allowed on variables in a variable statement.": { + "category": "Error", + "code": 1338 + }, + "Unique 'symbol()' types are not allowed here.": { + "category": "Error", + "code": 1339 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 729335916f025..32f0f3ce1d5a6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -574,7 +574,7 @@ namespace ts { return emitMappedType(node); case SyntaxKind.LiteralType: return emitLiteralType(node); - case SyntaxKind.SymbolType: + case SyntaxKind.ESSymbolType: return write("symbol()"); // Binding patterns diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 1b412198e5efa..8749d6375c340 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -785,6 +785,10 @@ namespace ts { : node; } + export function createESSymbolTypeNode() { + return createSynthesizedNode(SyntaxKind.ESSymbolType); + } + // Binding Patterns export function createObjectBindingPattern(elements: ReadonlyArray) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5f8121c90957b..34ed0889ca389 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2615,7 +2615,7 @@ namespace ts { if (token() === SyntaxKind.DotToken) return undefined; if (parseOptional(SyntaxKind.OpenParenToken)) { parseExpected(SyntaxKind.CloseParenToken); - return finishNode(createNode(SyntaxKind.SymbolType, fullStart)); + return finishNode(createNode(SyntaxKind.ESSymbolType, fullStart)); } else { return finishNode(createNode(SyntaxKind.SymbolKeyword, fullStart)); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d629bb60904fb..1d2d95ec6f444 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -240,7 +240,7 @@ namespace ts { IndexedAccessType, MappedType, LiteralType, - SymbolType, + ESSymbolType, // Binding patterns ObjectBindingPattern, ArrayBindingPattern, @@ -399,7 +399,7 @@ namespace ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypePredicate, - LastTypeNode = SymbolType, + LastTypeNode = ESSymbolType, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = Unknown, @@ -1053,8 +1053,9 @@ namespace ts { literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - export interface SymbolTypeNode extends TypeNode { - kind: SyntaxKind.SymbolType; + // Represents a unique `symbol()` type + export interface ESSymbolTypeNode extends TypeNode { + kind: SyntaxKind.ESSymbolType; } export interface StringLiteral extends LiteralExpression { @@ -2738,6 +2739,7 @@ namespace ts { // State InObjectTypeLiteral = 1 << 20, InTypeAlias = 1 << 23, // Writing type in type alias declaration + IsDeclarationOfUniqueESSymbolType = 1 << 24, } /* @internal */ @@ -3051,10 +3053,10 @@ namespace ts { isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) + enumKind?: EnumKind; // Enum declaration classification lateSymbol?: Symbol; // Late-bound symbol for a computed property lateMembers?: UnderscoreEscapedMap; // Late-bound members resolved during check resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol - enumKind?: EnumKind; // Enum declaration classification } /* @internal */ @@ -3204,7 +3206,7 @@ namespace ts { BooleanLiteral = 1 << 7, EnumLiteral = 1 << 8, // Always combined with StringLiteral, NumberLiteral, or Union ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6 - Unique = 1 << 10, // symbol() + UniqueESSymbol = 1 << 10, // symbol() Void = 1 << 11, Undefined = 1 << 12, Null = 1 << 13, @@ -3216,7 +3218,7 @@ namespace ts { Index = 1 << 19, // keyof T IndexedAccess = 1 << 20, // T[K] /* @internal */ - Fresh = 1 << 21, // Fresh literal or unique type + FreshLiteral = 1 << 21, // Fresh literal or unique type /* @internal */ ContainsWideningType = 1 << 22, // Type is or contains undefined or null widening type /* @internal */ @@ -3229,11 +3231,11 @@ namespace ts { /* @internal */ Nullable = Undefined | Null, - Literal = StringLiteral | NumberLiteral | BooleanLiteral | Unique, + Literal = StringLiteral | NumberLiteral | BooleanLiteral | UniqueESSymbol, Unit = Literal | Nullable, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ - StringOrNumberLiteralOrUnique = StringOrNumberLiteral | Unique, + StringOrNumberLiteralOrUnique = StringOrNumberLiteral | UniqueESSymbol, /* @internal */ DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean, @@ -3245,7 +3247,7 @@ namespace ts { NumberLike = Number | NumberLiteral | Enum, BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, - ESSymbolLike = ESSymbol | Unique, + ESSymbolLike = ESSymbol | UniqueESSymbol, UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess, @@ -3253,7 +3255,7 @@ namespace ts { // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | Unique | NonPrimitive, + Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive, NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, @@ -3288,11 +3290,9 @@ namespace ts { regularType?: LiteralType; // Regular version of type } - // Unique symbol types (TypeFlags.Unique) - export interface UniqueType extends Type { + // Unique symbol types (TypeFlags.UniqueESSymbol) + export interface UniqueESSymbolType extends Type { symbol: Symbol; - freshType?: UniqueType; // Fresh version of the type - regularType?: UniqueType; // Regular version of the type } export interface StringLiteralType extends LiteralType { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 02c58d4383205..f9f5e9fb7cfc1 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -926,6 +926,11 @@ namespace ts { return false; } + export function isVariableDeclarationInVariableStatement(node: VariableDeclaration) { + return node.parent.kind === SyntaxKind.VariableDeclarationList + && node.parent.parent.kind === SyntaxKind.VariableStatement; + } + export function introducesArgumentsExoticObject(node: Node) { switch (node.kind) { case SyntaxKind.MethodDeclaration: diff --git a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt index 9e9f48e539086..0cf6c7f07c1e7 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt +++ b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(1,36): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. -tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/compiler/capturedParametersInInitializers2.ts (2 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A } function foo2(y = class {[x] = x}, x = 1) { ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. } \ No newline at end of file diff --git a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt index 65ae28303db59..958ec02f00243 100644 --- a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt +++ b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(3,5): error TS2300: Duplica tests/cases/compiler/classWithDuplicateIdentifier.ts(6,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(7,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2300: Duplicate identifier 'c'. -tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2713: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2715: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. ==== tests/cases/compiler/classWithDuplicateIdentifier.ts (5 errors) ==== @@ -26,6 +26,6 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2713: Subseq ~ !!! error TS2300: Duplicate identifier 'c'. ~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/complicatedPrivacy.errors.txt b/tests/baselines/reference/complicatedPrivacy.errors.txt index 661b0693807c4..2848a11b2a47a 100644 --- a/tests/baselines/reference/complicatedPrivacy.errors.txt +++ b/tests/baselines/reference/complicatedPrivacy.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/complicatedPrivacy.ts(11,24): error TS1054: A 'get' accessor cannot have parameters. -tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/complicatedPrivacy.ts(35,6): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo5' has no exported member 'i6'. @@ -43,7 +43,7 @@ tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo { [number]: C1; // Used to be indexer, now it is a computed property ~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~~~~~~ !!! error TS2693: 'number' only refers to a type, but is being used as a value here. }) { diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt index 71f81c27245f9..bee9a01bcd4e7 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts (9 errors) ==== @@ -16,31 +16,31 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15 class C { [s]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [n] = n; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [s + s]: string; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [s + n] = 2; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [+s]: typeof s; ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [""]: number; [0]: number; [a]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [true]: number; ~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [`hello bye`] = 0; ~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [`hello ${a} bye`] = 0 ~~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt index 8d8cce7e1408d..a81279994c2dc 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts (9 errors) ==== @@ -16,31 +16,31 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15 class C { [s]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [n] = n; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [s + s]: string; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [s + n] = 2; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [+s]: typeof s; ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [""]: number; [0]: number; [a]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [true]: number; ~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [`hello bye`] = 0; ~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. static [`hello ${a} bye`] = 0 ~~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt index aaf5648702865..730594d0df99b 100644 --- a/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,10): error TS2467: A computed property name cannot reference a type parameter from its containing type. @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4, bar(): string; [foo()](): void; ~~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2467: A computed property name cannot reference a type parameter from its containing type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt index c8ef5efac31f5..11e9b35eeb6fb 100644 --- a/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,10): error TS2467: A computed property name cannot reference a type parameter from its containing type. @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4, bar(): string; [foo()](): void; ~~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2467: A computed property name cannot reference a type parameter from its containing type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt index b6effe98a91ec..888f29c4dde6c 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts (1 errors) ==== interface I { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt index 99832a42e37ac..70b2a3e2e16df 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts (1 errors) ==== interface I { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt index fd84ac72270b9..b9fad3157a973 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts(2,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts (1 errors) ==== var v: { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt index 7cdd26576cb99..94b904274ec1c 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts(2,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts (1 errors) ==== var v: { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt index 2a17d7da81570..cf6c9801074a3 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(4,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(5,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts (2 errors) ==== @@ -8,9 +8,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ class C { [methodName](v: string); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. [methodName](); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. [methodName](v?: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt index 381ee7c17bac9..656a1d2b17e61 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(4,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(5,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts (2 errors) ==== @@ -8,9 +8,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ class C { [methodName](v: string); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. [methodName](); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. [methodName](v?: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateClassElements.errors.txt b/tests/baselines/reference/duplicateClassElements.errors.txt index cd44aab2d2a52..17110937e0388 100644 --- a/tests/baselines/reference/duplicateClassElements.errors.txt +++ b/tests/baselines/reference/duplicateClassElements.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/duplicateClassElements.ts(26,9): error TS2300: Duplicate id tests/cases/compiler/duplicateClassElements.ts(29,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2300: Duplicate identifier 'x2'. -tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2713: Subsequent property declarations must have the same type. Property 'x2' must be of type 'number', but here has type 'any'. +tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2715: Subsequent property declarations must have the same type. Property 'x2' must be of type 'number', but here has type 'any'. tests/cases/compiler/duplicateClassElements.ts(36,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(36,9): error TS2300: Duplicate identifier 'z2'. tests/cases/compiler/duplicateClassElements.ts(39,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -96,7 +96,7 @@ tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate i ~~ !!! error TS2300: Duplicate identifier 'x2'. ~~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'x2' must be of type 'number', but here has type 'any'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'x2' must be of type 'number', but here has type 'any'. get z2() { ~~ diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index 41b57f57908ae..979ed0c1beb41 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -29,7 +29,7 @@ import * as M from "./module"; namespace N { export const c2 = "a"; export const c3 = 1; - export const s1 = s0; + export const s1: typeof s0 = s0; export interface T4 { [N.c2]: number; @@ -52,7 +52,7 @@ namespace N { export const c4 = "a"; export const c5 = 1; -export const s2 = s0; +export const s2: typeof s0 = s0; interface T8 { [c4]: number; diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index 056c77843fee7..6ac8b66baa6d7 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -74,12 +74,13 @@ namespace N { export const c3 = 1; >c3 : Symbol(c3, Decl(main.ts, 5, 16)) - export const s1 = s0; + export const s1: typeof s0 = s0; >s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) >s0 : Symbol(s0, Decl(main.ts, 0, 16)) export interface T4 { ->T4 : Symbol(T4, Decl(main.ts, 6, 25)) +>T4 : Symbol(T4, Decl(main.ts, 6, 36)) [N.c2]: number; >N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) @@ -98,7 +99,7 @@ namespace N { } export declare class T5 implements T4 { >T5 : Symbol(T5, Decl(main.ts, 12, 5)) ->T4 : Symbol(T4, Decl(main.ts, 6, 25)) +>T4 : Symbol(T4, Decl(main.ts, 6, 36)) [N.c2]: number; >N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) @@ -146,12 +147,13 @@ export const c4 = "a"; export const c5 = 1; >c5 : Symbol(c5, Decl(main.ts, 28, 12)) -export const s2 = s0; +export const s2: typeof s0 = s0; >s2 : Symbol(s2, Decl(main.ts, 29, 12)) >s0 : Symbol(s0, Decl(main.ts, 0, 16)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) interface T8 { ->T8 : Symbol(T8, Decl(main.ts, 29, 21)) +>T8 : Symbol(T8, Decl(main.ts, 29, 32)) [c4]: number; >c4 : Symbol(c4, Decl(main.ts, 27, 12)) @@ -164,7 +166,7 @@ interface T8 { } declare class T9 implements T8 { >T9 : Symbol(T9, Decl(main.ts, 35, 1)) ->T8 : Symbol(T8, Decl(main.ts, 29, 21)) +>T8 : Symbol(T8, Decl(main.ts, 29, 32)) [c4]: number; >c4 : Symbol(c4, Decl(main.ts, 27, 12)) @@ -269,7 +271,7 @@ let t3_1: M.T3; let t4: N.T4; >t4 : Symbol(t4, Decl(main.ts, 75, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) ->T4 : Symbol(N.T4, Decl(main.ts, 6, 25)) +>T4 : Symbol(N.T4, Decl(main.ts, 6, 36)) let t5: N.T5; >t5 : Symbol(t5, Decl(main.ts, 76, 3)) @@ -288,7 +290,7 @@ let t7: N.T7; let t8: T8; >t8 : Symbol(t8, Decl(main.ts, 79, 3)) ->T8 : Symbol(T8, Decl(main.ts, 29, 21)) +>T8 : Symbol(T8, Decl(main.ts, 29, 32)) let t9: T9; >t9 : Symbol(t9, Decl(main.ts, 80, 3)) diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 058585be7da58..98d5617093f3b 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -9,7 +9,7 @@ export const c1 = 1; export const s0 = Symbol(); >s0 : symbol() ->Symbol() : typeof s0 +>Symbol() : symbol() >Symbol : SymbolConstructor export interface T0 { @@ -22,7 +22,7 @@ export interface T0 { >c1 : 1 [s0]: boolean; ->s0 : typeof s0 +>s0 : symbol() } export declare class T1 implements T2 { >T1 : T1 @@ -35,7 +35,7 @@ export declare class T1 implements T2 { >c1 : 1 [s0]: boolean; ->s0 : typeof s0 +>s0 : symbol() } export declare class T2 extends T1 { >T2 : T2 @@ -51,7 +51,7 @@ export declare type T3 = { >c1 : 1 [s0]: boolean; ->s0 : typeof s0 +>s0 : symbol() }; @@ -79,9 +79,10 @@ namespace N { >c3 : 1 >1 : 1 - export const s1 = s0; ->s1 : typeof s0 ->s0 : typeof s0 + export const s1: typeof s0 = s0; +>s1 : symbol() +>s0 : symbol() +>s0 : symbol() export interface T4 { >T4 : T4 @@ -97,9 +98,9 @@ namespace N { >c3 : 1 [N.s1]: boolean; ->N.s1 : typeof s0 +>N.s1 : symbol() >N : typeof N ->s1 : typeof s0 +>s1 : symbol() } export declare class T5 implements T4 { >T5 : T5 @@ -116,9 +117,9 @@ namespace N { >c3 : 1 [N.s1]: boolean; ->N.s1 : typeof s0 +>N.s1 : symbol() >N : typeof N ->s1 : typeof s0 +>s1 : symbol() } export declare class T6 extends T5 { >T6 : T6 @@ -138,9 +139,9 @@ namespace N { >c3 : 1 [N.s1]: boolean; ->N.s1 : typeof s0 +>N.s1 : symbol() >N : typeof N ->s1 : typeof s0 +>s1 : symbol() }; } @@ -153,9 +154,10 @@ export const c5 = 1; >c5 : 1 >1 : 1 -export const s2 = s0; ->s2 : typeof s0 ->s0 : typeof s0 +export const s2: typeof s0 = s0; +>s2 : symbol() +>s0 : symbol() +>s0 : symbol() interface T8 { >T8 : T8 @@ -167,7 +169,7 @@ interface T8 { >c5 : 1 [s2]: boolean; ->s2 : typeof s0 +>s2 : symbol() } declare class T9 implements T8 { >T9 : T9 @@ -180,7 +182,7 @@ declare class T9 implements T8 { >c5 : 1 [s2]: boolean; ->s2 : typeof s0 +>s2 : symbol() } declare class T10 extends T9 { >T10 : T10 @@ -196,7 +198,7 @@ declare type T11 = { >c5 : 1 [s2]: boolean; ->s2 : typeof s0 +>s2 : symbol() }; @@ -208,7 +210,7 @@ interface T12 { 1: string; [s2]: boolean; ->s2 : typeof s0 +>s2 : symbol() } declare class T13 implements T2 { >T13 : T13 @@ -219,7 +221,7 @@ declare class T13 implements T2 { 1: string; [s2]: boolean; ->s2 : typeof s0 +>s2 : symbol() } declare class T14 extends T13 { >T14 : T14 @@ -233,7 +235,7 @@ declare type T15 = { 1: string; [s2]: boolean; ->s2 : typeof s0 +>s2 : symbol() }; @@ -471,7 +473,7 @@ export const o1 = { >"a" : "a" [s2]: true ->s2 : typeof s0 +>s2 : symbol() >true : true }; @@ -493,7 +495,7 @@ export const o1_s2 = o1[s2]; >o1_s2 : boolean >o1[s2] : boolean >o1 : { [c4]: number; [c5]: string; [s2]: boolean; } ->s2 : typeof s0 +>s2 : symbol() export const o2: T0 = o1; >o2 : T0 diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index cd097badd775e..0d8f865b7cb1f 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2714: Duplicate declaration '[c0]'. -tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2714: Duplicate declaration '[c0]'. -tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2713: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. +tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2716: Duplicate declaration '[c0]'. +tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2716: Duplicate declaration '[c0]'. +tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2715: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '[c0]' are incompatible. Type 'string' is not assignable to type 'number'. @@ -17,10 +17,10 @@ tests/cases/compiler/dynamicNamesErrors.ts(28,6): error TS4033: Property '[c0]' interface T0 { [c0]: number; ~~~~ -!!! error TS2714: Duplicate declaration '[c0]'. +!!! error TS2716: Duplicate declaration '[c0]'. 1: number; ~ -!!! error TS2714: Duplicate declaration '[c0]'. +!!! error TS2716: Duplicate declaration '[c0]'. } interface T1 { @@ -35,7 +35,7 @@ tests/cases/compiler/dynamicNamesErrors.ts(28,6): error TS4033: Property '[c0]' [c0]: number; [c1]: string; ~~~~ -!!! error TS2713: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. +!!! error TS2715: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. } let t1: T1; diff --git a/tests/baselines/reference/gettersAndSettersErrors.errors.txt b/tests/baselines/reference/gettersAndSettersErrors.errors.txt index 87b317670d507..bb26eb5ead01c 100644 --- a/tests/baselines/reference/gettersAndSettersErrors.errors.txt +++ b/tests/baselines/reference/gettersAndSettersErrors.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/gettersAndSettersErrors.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2713: Subsequent property declarations must have the same type. Property 'Foo' must be of type 'string', but here has type 'number'. +tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2715: Subsequent property declarations must have the same type. Property 'Foo' must be of type 'string', but here has type 'number'. tests/cases/compiler/gettersAndSettersErrors.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -23,7 +23,7 @@ tests/cases/compiler/gettersAndSettersErrors.ts(12,16): error TS2379: Getter and ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'Foo' must be of type 'string', but here has type 'number'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'Foo' must be of type 'string', but here has type 'number'. public get Goo(v:string):string {return null;} // error - getters must not have a parameter ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index 809ae03635824..d465bd8a958ea 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/giant.ts(33,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(34,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(35,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(35,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(60,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(60,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(60,6): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(61,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(62,6): error TS1096: An index signature must have exactly one parameter. @@ -39,7 +39,7 @@ tests/cases/compiler/giant.ts(97,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(98,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(99,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(99,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(124,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(124,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(124,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(125,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(126,10): error TS1096: An index signature must have exactly one parameter. @@ -63,7 +63,7 @@ tests/cases/compiler/giant.ts(176,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(177,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(178,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(178,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(203,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(203,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(203,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(204,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(205,10): error TS1096: An index signature must have exactly one parameter. @@ -119,7 +119,7 @@ tests/cases/compiler/giant.ts(291,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(292,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(293,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(293,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(318,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(318,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(318,6): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(319,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(320,6): error TS1096: An index signature must have exactly one parameter. @@ -142,7 +142,7 @@ tests/cases/compiler/giant.ts(355,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(356,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(357,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(357,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(382,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(382,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(382,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(383,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(384,10): error TS1096: An index signature must have exactly one parameter. @@ -166,7 +166,7 @@ tests/cases/compiler/giant.ts(434,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(435,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(436,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(436,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(461,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(461,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(461,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(462,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(463,10): error TS1096: An index signature must have exactly one parameter. @@ -238,7 +238,7 @@ tests/cases/compiler/giant.ts(555,21): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(557,24): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(560,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(562,21): error TS1183: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(586,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(586,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(586,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(587,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(588,10): error TS1096: An index signature must have exactly one parameter. @@ -255,7 +255,7 @@ tests/cases/compiler/giant.ts(620,26): error TS1183: An implementation cannot be tests/cases/compiler/giant.ts(622,24): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(625,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(627,21): error TS1183: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(652,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(652,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/giant.ts(652,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(653,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(654,10): error TS1096: An index signature must have exactly one parameter. @@ -363,7 +363,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -473,7 +473,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -600,7 +600,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -827,7 +827,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -937,7 +937,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1064,7 +1064,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1333,7 +1333,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1433,7 +1433,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index 88e09d7746b92..7c5502967e173 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,6): error TS2304: Cannot find name 'x'. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(4,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,6): error TS2304: Cannot find name 'x'. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021: An index signature must have a type annotation. @@ -11,7 +11,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021 // Used to be indexer, now it is a computed property [x]: string; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'x'. [x: string]; @@ -23,7 +23,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021 // Used to be indexer, now it is a computed property [x]: string ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'x'. diff --git a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt index 4a49de69393ac..e24d2163ad981 100644 --- a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt +++ b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/indexSignatureWithInitializer.ts(3,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureWithInitializer.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/indexSignatureWithInitializer.ts(3,6): error TS2304: Cannot find name 'x'. -tests/cases/compiler/indexSignatureWithInitializer.ts(7,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureWithInitializer.ts(7,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot find name 'x'. @@ -9,7 +9,7 @@ tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot interface I { [x = '']: string; ~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'x'. } @@ -17,7 +17,7 @@ tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot class C { [x = 0]: string ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'x'. } \ No newline at end of file diff --git a/tests/baselines/reference/indexWithoutParamType2.errors.txt b/tests/baselines/reference/indexWithoutParamType2.errors.txt index 7e72b7804e29c..64c4e43db84fb 100644 --- a/tests/baselines/reference/indexWithoutParamType2.errors.txt +++ b/tests/baselines/reference/indexWithoutParamType2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/indexWithoutParamType2.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/indexWithoutParamType2.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/indexWithoutParamType2.ts(3,6): error TS2304: Cannot find name 'x'. @@ -7,7 +7,7 @@ tests/cases/compiler/indexWithoutParamType2.ts(3,6): error TS2304: Cannot find n // Used to be indexer, now it is a computed property [x]: string ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'x'. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceDeclaration1.errors.txt b/tests/baselines/reference/interfaceDeclaration1.errors.txt index f7720103bf02a..8255a62dd5162 100644 --- a/tests/baselines/reference/interfaceDeclaration1.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration1.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/interfaceDeclaration1.ts(2,5): error TS2300: Duplicate iden tests/cases/compiler/interfaceDeclaration1.ts(3,5): error TS2300: Duplicate identifier 'item'. tests/cases/compiler/interfaceDeclaration1.ts(7,5): error TS2300: Duplicate identifier 'item'. tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2300: Duplicate identifier 'item'. -tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2713: Subsequent property declarations must have the same type. Property 'item' must be of type 'any', but here has type 'number'. +tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2715: Subsequent property declarations must have the same type. Property 'item' must be of type 'any', but here has type 'number'. tests/cases/compiler/interfaceDeclaration1.ts(22,11): error TS2310: Type 'I5' recursively references itself as a base type. tests/cases/compiler/interfaceDeclaration1.ts(35,7): error TS2420: Class 'C1' incorrectly implements interface 'I3'. Property 'prototype' is missing in type 'C1'. @@ -29,7 +29,7 @@ tests/cases/compiler/interfaceDeclaration1.ts(52,11): error TS2320: Interface 'i ~~~~ !!! error TS2300: Duplicate identifier 'item'. ~~~~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'item' must be of type 'any', but here has type 'number'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'item' must be of type 'any', but here has type 'number'. } interface I3 { diff --git a/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt b/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt index b70a0bf8fd5bc..18328ef9285d2 100644 --- a/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt +++ b/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(6,5): error TS2713: Subsequent property declarations must have the same type. Property 'x' must be of type 'string', but here has type 'number'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(15,9): error TS2713: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(39,9): error TS2713: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(6,5): error TS2715: Subsequent property declarations must have the same type. Property 'x' must be of type 'string', but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(15,9): error TS2715: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(39,9): error TS2715: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. ==== tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts (3 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli interface A { x: number; ~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'x' must be of type 'string', but here has type 'number'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'x' must be of type 'string', but here has type 'number'. } module M { @@ -22,7 +22,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli interface A { x: number; // error ~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. } } @@ -48,6 +48,6 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli export interface A { x: number; // error ~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'x' must be of type 'T', but here has type 'number'. } } \ No newline at end of file diff --git a/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt b/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt index b1411c80d3b71..b3973a62220a3 100644 --- a/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt +++ b/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericString tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(12,5): error TS2300: Duplicate identifier '1'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(16,5): error TS2300: Duplicate identifier '1'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2300: Duplicate identifier '1'. -tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2713: Subsequent property declarations must have the same type. Property '1.0' must be of type 'number', but here has type 'string'. +tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2715: Subsequent property declarations must have the same type. Property '1.0' must be of type 'number', but here has type 'string'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(22,5): error TS2300: Duplicate identifier '0'. @@ -36,7 +36,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericString ~~~ !!! error TS2300: Duplicate identifier '1'. ~~~ -!!! error TS2713: Subsequent property declarations must have the same type. Property '1.0' must be of type 'number', but here has type 'string'. +!!! error TS2715: Subsequent property declarations must have the same type. Property '1.0' must be of type 'number', but here has type 'string'. } var b = { diff --git a/tests/baselines/reference/parserComputedPropertyName10.errors.txt b/tests/baselines/reference/parserComputedPropertyName10.errors.txt index a9b5396781aa5..18c612291a463 100644 --- a/tests/baselines/reference/parserComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e] = 1 ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index 2a7a606f4bfcb..c9ff2faf43eb4 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e](); ~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName13.errors.txt b/tests/baselines/reference/parserComputedPropertyName13.errors.txt index a7a77cf12440f..ba15de5feafdc 100644 --- a/tests/baselines/reference/parserComputedPropertyName13.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts (2 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt index 50a6d1bc689ac..082f9f2dce4f4 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (2 errors) ==== var v: { [e](): number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName15.errors.txt b/tests/baselines/reference/parserComputedPropertyName15.errors.txt index 9635178af1673..7d9c7e8e5de1d 100644 --- a/tests/baselines/reference/parserComputedPropertyName15.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,32): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts (2 errors) ==== var v: { [e: number]: string; [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt index 9e64ddd0d28db..715bb5dd437f7 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (2 errors) ==== var v: { [e]?(): number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName19.errors.txt b/tests/baselines/reference/parserComputedPropertyName19.errors.txt index 86bb591011e36..626dbe78c5aec 100644 --- a/tests/baselines/reference/parserComputedPropertyName19.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts (2 errors) ==== var v: { [e]? }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt index 035e494af332c..67bb57c519cd3 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP interface I { [e](): number ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName21.errors.txt b/tests/baselines/reference/parserComputedPropertyName21.errors.txt index 4ebc321cc8032..a67bf8e779937 100644 --- a/tests/baselines/reference/parserComputedPropertyName21.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP interface I { [e]: number ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName22.errors.txt b/tests/baselines/reference/parserComputedPropertyName22.errors.txt index fd9e37970187c..44add8085809e 100644 --- a/tests/baselines/reference/parserComputedPropertyName22.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName22.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP declare class C { [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName25.errors.txt b/tests/baselines/reference/parserComputedPropertyName25.errors.txt index 0d0a2a8d8332b..c88eb3aea1131 100644 --- a/tests/baselines/reference/parserComputedPropertyName25.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName25.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // No ASI [e] = 0 ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. [e2] = 1 diff --git a/tests/baselines/reference/parserComputedPropertyName28.errors.txt b/tests/baselines/reference/parserComputedPropertyName28.errors.txt index a84f3b7d16b96..3aa13e0dfdb16 100644 --- a/tests/baselines/reference/parserComputedPropertyName28.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName28.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,6): error TS2304: Cannot find name 'e'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,6): error TS2304: Cannot find name 'e2'. @@ -8,12 +8,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e]: number = 0; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName29.errors.txt b/tests/baselines/reference/parserComputedPropertyName29.errors.txt index 3d886eacc5063..bbb27f8f7bf17 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,11): error TS2304: Cannot find name 'id'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -10,14 +10,14 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e] = id++ ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. ~~ !!! error TS2304: Cannot find name 'id'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName31.errors.txt b/tests/baselines/reference/parserComputedPropertyName31.errors.txt index 4661b0797af98..aaa8869696554 100644 --- a/tests/baselines/reference/parserComputedPropertyName31.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName31.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,6): error TS2304: Cannot find name 'e'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -9,12 +9,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName32.errors.txt b/tests/baselines/reference/parserComputedPropertyName32.errors.txt index 4be8d70383e19..3bc47afd90db8 100644 --- a/tests/baselines/reference/parserComputedPropertyName32.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: A computed property name in an ambient context must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP declare class C { [e](): number ~~~ -!!! error TS1165: A computed property name in an ambient context must directly refer to a built-in symbol. +!!! error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName36.errors.txt b/tests/baselines/reference/parserComputedPropertyName36.errors.txt index 6bcb5b5278998..e746b5e4f54ba 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName36.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS2304: Cannot find name 'public'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [public ]: string; ~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ diff --git a/tests/baselines/reference/parserComputedPropertyName7.errors.txt b/tests/baselines/reference/parserComputedPropertyName7.errors.txt index 056fa3d82fdd4..2fc7fd0346355 100644 --- a/tests/baselines/reference/parserComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName8.errors.txt b/tests/baselines/reference/parserComputedPropertyName8.errors.txt index 32bb490635357..0a57a6decbd75 100644 --- a/tests/baselines/reference/parserComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,12): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { public [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName9.errors.txt b/tests/baselines/reference/parserComputedPropertyName9.errors.txt index 9db0cbde3bd29..8d283a5f1b8d1 100644 --- a/tests/baselines/reference/parserComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e]: Type ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. ~~~~ diff --git a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt index 2c8f1d2ab4f0e..997587b0c7907 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput declare class C { [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt index 31d3f9985abae..233e665d9bf78 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e] = 1 ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt index b4808607ab06d..a8ba9113ea69a 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e](); ~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt index 9125ce7b58f42..c92babd424d6a 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput interface I { [e]: number ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt index 277bdcd3c94a5..d776c7921ea97 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt index 6b674a1d2c05b..d8f152c6b5aa0 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts (2 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt index fb087a4d82fcc..f4a6da790c02a 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e]: Type ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'e'. ~~~~ diff --git a/tests/baselines/reference/parserIndexSignature11.errors.txt b/tests/baselines/reference/parserIndexSignature11.errors.txt index f1f2a4a00f465..43f593c731a74 100644 --- a/tests/baselines/reference/parserIndexSignature11.errors.txt +++ b/tests/baselines/reference/parserIndexSignature11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,10): error TS2304: Cannot find name 'p'. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(3,9): error TS1021: An index signature must have a type annotation. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(4,10): error TS1096: An index signature must have exactly one parameter. @@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1 interface I { [p]; // Used to be indexer, now it is a computed property ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; diff --git a/tests/baselines/reference/parserIndexSignature4.errors.txt b/tests/baselines/reference/parserIndexSignature4.errors.txt index bd73b4d2bf451..2a102bd4c6ac9 100644 --- a/tests/baselines/reference/parserIndexSignature4.errors.txt +++ b/tests/baselines/reference/parserIndexSignature4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,4): error TS2304: Cannot find name 'a'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4 interface I { [a = 0] // Used to be indexer, now it is a computed property ~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature5.errors.txt b/tests/baselines/reference/parserIndexSignature5.errors.txt index 54ccd05f4f99f..2870258489ca6 100644 --- a/tests/baselines/reference/parserIndexSignature5.errors.txt +++ b/tests/baselines/reference/parserIndexSignature5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,4): error TS2304: Cannot find name 'a'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5 interface I { [a] // Used to be indexer, now it is a computed property ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~ !!! error TS2304: Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index 6aa34c15ac90e..74a8c9d46acca 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAssignment.ts(4,13): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/compiler/propertyAssignment.ts(4,13): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. tests/cases/compiler/propertyAssignment.ts(4,14): error TS2304: Cannot find name 'index'. tests/cases/compiler/propertyAssignment.ts(12,1): error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. Type '{ x: number; }' provides no match for the signature 'new (): any'. @@ -12,7 +12,7 @@ tests/cases/compiler/propertyAssignment.ts(14,1): error TS2322: Type '{ x: numbe var foo2: { [index]; } // should be an error, used to be indexer, now it is a computed property ~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. ~~~~~ !!! error TS2304: Cannot find name 'index'. var bar2: { x : number; } diff --git a/tests/baselines/reference/reassignStaticProp.errors.txt b/tests/baselines/reference/reassignStaticProp.errors.txt index ec24293c907b9..432d2b6913c31 100644 --- a/tests/baselines/reference/reassignStaticProp.errors.txt +++ b/tests/baselines/reference/reassignStaticProp.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2300: Duplicate identifier 'bar'. -tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2713: Subsequent property declarations must have the same type. Property 'bar' must be of type 'number', but here has type 'string'. +tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2715: Subsequent property declarations must have the same type. Property 'bar' must be of type 'number', but here has type 'string'. ==== tests/cases/compiler/reassignStaticProp.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2713: Subsequent prope ~~~ !!! error TS2300: Duplicate identifier 'bar'. ~~~ -!!! error TS2713: Subsequent property declarations must have the same type. Property 'bar' must be of type 'number', but here has type 'string'. +!!! error TS2715: Subsequent property declarations must have the same type. Property 'bar' must be of type 'number', but here has type 'string'. } diff --git a/tests/baselines/reference/symbolProperty7.errors.txt b/tests/baselines/reference/symbolProperty7.errors.txt index 652f637d852d0..b2a182aa3bbe9 100644 --- a/tests/baselines/reference/symbolProperty7.errors.txt +++ b/tests/baselines/reference/symbolProperty7.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/Symbols/symbolProperty7.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/Symbols/symbolProperty7.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/es6/Symbols/symbolProperty7.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/Symbols/symbolProperty7.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. ==== tests/cases/conformance/es6/Symbols/symbolProperty7.ts (2 errors) ==== class C { [Symbol()] = 0; ~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [Symbol()]: number; ~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. [Symbol()]() { } get [Symbol()]() { return 0; diff --git a/tests/baselines/reference/uniqueSymbols.js b/tests/baselines/reference/uniqueSymbols.js new file mode 100644 index 0000000000000..88282afb60ede --- /dev/null +++ b/tests/baselines/reference/uniqueSymbols.js @@ -0,0 +1,275 @@ +//// [uniqueSymbols.ts] +// declarations with call initializer +const constCall = Symbol(); +let letCall = Symbol(); +var varCall = Symbol(); + +// ambient declaration with type +declare const constType: symbol(); + +// declaration with type and call initializer +const constTypeAndCall: symbol() = Symbol(); + +// declaration from initializer +const constInitToConstCall = constCall; +const constInitToLetCall = letCall; +const constInitToVarCall = varCall; +const constInitToConstDeclAmbient = constType; +let letInitToConstCall = constCall; +let letInitToLetCall = letCall; +let letInitToVarCall = varCall; +let letInitToConstDeclAmbient = constType; +var varInitToConstCall = constCall; +var varInitToLetCall = letCall; +var varInitToVarCall = varCall; +var varInitToConstDeclAmbient = constType; + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; + +// function return inference +function funcReturnConstCall() { return constCall; } +function funcReturnLetCall() { return letCall; } +function funcReturnVarCall() { return varCall; } + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +function* genFuncYieldLetCall() { yield letCall; } +function* genFuncYieldVarCall() { yield varCall; } + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +async function asyncFuncReturnLetCall() { return letCall; } +async function asyncFuncReturnVarCall() { return varCall; } + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +async function* asyncGenFuncYieldLetCall() { yield letCall; } +async function* asyncGenFuncYieldVarCall() { yield varCall; } + +// classes +class C { + static readonly readonlyStaticCall = Symbol(); + static readonly readonlyStaticType: symbol(); + static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); + static readwriteStaticCall = Symbol(); + + readonly readonlyCall = Symbol(); + readwriteCall = Symbol(); +} +declare const c: C; + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyCall = c.readonlyCall; +const constInitToCReadwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; + +// interfaces +interface I { + readonly readonlyType: symbol(); +} +declare const i: I; + +const constInitToIReadonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; + +// type literals +type L = { + readonly readonlyType: symbol(); + nested: { + readonly readonlyNestedType: symbol(); + } +}; +declare const l: L; + +const constInitToLReadonlyType = l.readonlyType; +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +const arrayOfConstCall = [constCall]; + +//// [uniqueSymbols.js] +// declarations with call initializer +const constCall = Symbol(); +let letCall = Symbol(); +var varCall = Symbol(); +// declaration with type and call initializer +const constTypeAndCall = Symbol(); +// declaration from initializer +const constInitToConstCall = constCall; +const constInitToLetCall = letCall; +const constInitToVarCall = varCall; +const constInitToConstDeclAmbient = constType; +let letInitToConstCall = constCall; +let letInitToLetCall = letCall; +let letInitToVarCall = varCall; +let letInitToConstDeclAmbient = constType; +var varInitToConstCall = constCall; +var varInitToLetCall = letCall; +var varInitToVarCall = varCall; +var varInitToConstDeclAmbient = constType; +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery = constCall; +const constInitToConstDeclAmbientWithTypeQuery = constType; +// function return inference +function funcReturnConstCall() { return constCall; } +function funcReturnLetCall() { return letCall; } +function funcReturnVarCall() { return varCall; } +// function return value with type query +function funcReturnConstCallWithTypeQuery() { return constCall; } +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +function* genFuncYieldLetCall() { yield letCall; } +function* genFuncYieldVarCall() { yield varCall; } +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery() { yield constCall; } +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +async function asyncFuncReturnLetCall() { return letCall; } +async function asyncFuncReturnVarCall() { return varCall; } +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +async function* asyncGenFuncYieldLetCall() { yield letCall; } +async function* asyncGenFuncYieldVarCall() { yield varCall; } +// classes +class C { + constructor() { + this.readonlyCall = Symbol(); + this.readwriteCall = Symbol(); + } +} +C.readonlyStaticCall = Symbol(); +C.readonlyStaticTypeAndCall = Symbol(); +C.readwriteStaticCall = Symbol(); +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; +const constInitToCReadonlyStaticCallWithTypeQuery = C.readonlyStaticCall; +const constInitToCReadonlyStaticTypeWithTypeQuery = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCallWithTypeQuery = C.readwriteStaticCall; +const constInitToCReadonlyCall = c.readonlyCall; +const constInitToCReadwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithTypeQuery = c.readonlyCall; +const constInitToCReadwriteCallWithTypeQuery = c.readwriteCall; +const constInitToCReadonlyCallWithIndexedAccess = c.readonlyCall; +const constInitToCReadwriteCallWithIndexedAccess = c.readwriteCall; +const constInitToIReadonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithTypeQuery = i.readonlyType; +const constInitToIReadonlyTypeWithIndexedAccess = i.readonlyType; +const constInitToLReadonlyType = l.readonlyType; +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithTypeQuery = l.readonlyType; +const constInitToLReadonlyNestedTypeWithTypeQuery = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithIndexedAccess = l.readonlyType; +const constInitToLReadonlyNestedTypeWithIndexedAccess = l.nested.readonlyNestedType; +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +const arrayOfConstCall = [constCall]; + + +//// [uniqueSymbols.d.ts] +declare const constCall: symbol(); +declare let letCall: symbol; +declare var varCall: symbol; +declare const constType: symbol(); +declare const constTypeAndCall: symbol(); +declare const constInitToConstCall: symbol; +declare const constInitToLetCall: symbol; +declare const constInitToVarCall: symbol; +declare const constInitToConstDeclAmbient: symbol; +declare let letInitToConstCall: symbol; +declare let letInitToLetCall: symbol; +declare let letInitToVarCall: symbol; +declare let letInitToConstDeclAmbient: symbol; +declare var varInitToConstCall: symbol; +declare var varInitToLetCall: symbol; +declare var varInitToVarCall: symbol; +declare var varInitToConstDeclAmbient: symbol; +declare const constInitToConstCallWithTypeQuery: typeof constCall; +declare const constInitToConstDeclAmbientWithTypeQuery: typeof constType; +declare function funcReturnConstCall(): symbol; +declare function funcReturnLetCall(): symbol; +declare function funcReturnVarCall(): symbol; +declare function funcReturnConstCallWithTypeQuery(): typeof constCall; +declare function genFuncYieldConstCall(): IterableIterator; +declare function genFuncYieldLetCall(): IterableIterator; +declare function genFuncYieldVarCall(): IterableIterator; +declare function genFuncYieldConstCallWithTypeQuery(): IterableIterator; +declare function asyncFuncReturnConstCall(): Promise; +declare function asyncFuncReturnLetCall(): Promise; +declare function asyncFuncReturnVarCall(): Promise; +declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator; +declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator; +declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator; +declare class C { + static readonly readonlyStaticCall: symbol(); + static readonly readonlyStaticType: symbol(); + static readonly readonlyStaticTypeAndCall: symbol(); + static readwriteStaticCall: symbol; + readonly readonlyCall: symbol; + readwriteCall: symbol; +} +declare const c: C; +declare const constInitToCReadonlyStaticCall: symbol; +declare const constInitToCReadonlyStaticType: symbol; +declare const constInitToCReadonlyStaticTypeAndCall: symbol; +declare const constInitToCReadwriteStaticCall: symbol; +declare const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall; +declare const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType; +declare const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall; +declare const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall; +declare const constInitToCReadonlyCall: symbol; +declare const constInitToCReadwriteCall: symbol; +declare const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall; +declare const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall; +declare const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"]; +declare const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"]; +interface I { + readonly readonlyType: symbol(); +} +declare const i: I; +declare const constInitToIReadonlyType: symbol; +declare const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType; +declare const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"]; +declare type L = { + readonly readonlyType: symbol(); + nested: { + readonly readonlyNestedType: symbol(); + }; +}; +declare const l: L; +declare const constInitToLReadonlyType: symbol; +declare const constInitToLReadonlyNestedType: symbol; +declare const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType; +declare const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType; +declare const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"]; +declare const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"]; +declare const promiseForConstCall: Promise; +declare const arrayOfConstCall: symbol[]; diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols new file mode 100644 index 0000000000000..9831e201ece47 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -0,0 +1,398 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts === +// declarations with call initializer +const constCall = Symbol(); +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +let letCall = Symbol(); +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +var varCall = Symbol(); +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +// ambient declaration with type +declare const constType: symbol(); +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +// declaration with type and call initializer +const constTypeAndCall: symbol() = Symbol(); +>constTypeAndCall : Symbol(constTypeAndCall, Decl(uniqueSymbols.ts, 9, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +// declaration from initializer +const constInitToConstCall = constCall; +>constInitToConstCall : Symbol(constInitToConstCall, Decl(uniqueSymbols.ts, 12, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +const constInitToLetCall = letCall; +>constInitToLetCall : Symbol(constInitToLetCall, Decl(uniqueSymbols.ts, 13, 5)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +const constInitToVarCall = varCall; +>constInitToVarCall : Symbol(constInitToVarCall, Decl(uniqueSymbols.ts, 14, 5)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +const constInitToConstDeclAmbient = constType; +>constInitToConstDeclAmbient : Symbol(constInitToConstDeclAmbient, Decl(uniqueSymbols.ts, 15, 5)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +let letInitToConstCall = constCall; +>letInitToConstCall : Symbol(letInitToConstCall, Decl(uniqueSymbols.ts, 16, 3)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +let letInitToLetCall = letCall; +>letInitToLetCall : Symbol(letInitToLetCall, Decl(uniqueSymbols.ts, 17, 3)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +let letInitToVarCall = varCall; +>letInitToVarCall : Symbol(letInitToVarCall, Decl(uniqueSymbols.ts, 18, 3)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +let letInitToConstDeclAmbient = constType; +>letInitToConstDeclAmbient : Symbol(letInitToConstDeclAmbient, Decl(uniqueSymbols.ts, 19, 3)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +var varInitToConstCall = constCall; +>varInitToConstCall : Symbol(varInitToConstCall, Decl(uniqueSymbols.ts, 20, 3)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +var varInitToLetCall = letCall; +>varInitToLetCall : Symbol(varInitToLetCall, Decl(uniqueSymbols.ts, 21, 3)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +var varInitToVarCall = varCall; +>varInitToVarCall : Symbol(varInitToVarCall, Decl(uniqueSymbols.ts, 22, 3)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +var varInitToConstDeclAmbient = constType; +>varInitToConstDeclAmbient : Symbol(varInitToConstDeclAmbient, Decl(uniqueSymbols.ts, 23, 3)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +>constInitToConstCallWithTypeQuery : Symbol(constInitToConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 26, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +>constInitToConstDeclAmbientWithTypeQuery : Symbol(constInitToConstDeclAmbientWithTypeQuery, Decl(uniqueSymbols.ts, 27, 5)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +// function return inference +function funcReturnConstCall() { return constCall; } +>funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbols.ts, 27, 77)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +function funcReturnLetCall() { return letCall; } +>funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbols.ts, 30, 52)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +function funcReturnVarCall() { return varCall; } +>funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbols.ts, 31, 48)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } +>funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 32, 48)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +>genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbols.ts, 35, 83)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +function* genFuncYieldLetCall() { yield letCall; } +>genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbols.ts, 38, 54)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +function* genFuncYieldVarCall() { yield varCall; } +>genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbols.ts, 39, 50)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } +>genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 40, 50)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +>asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbols.ts, 43, 103)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +async function asyncFuncReturnLetCall() { return letCall; } +>asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbols.ts, 46, 63)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +async function asyncFuncReturnVarCall() { return varCall; } +>asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbols.ts, 47, 59)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +>asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbols.ts, 48, 59)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +async function* asyncGenFuncYieldLetCall() { yield letCall; } +>asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbols.ts, 51, 65)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +async function* asyncGenFuncYieldVarCall() { yield varCall; } +>asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbols.ts, 52, 61)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// classes +class C { +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) + + static readonly readonlyStaticCall = Symbol(); +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + static readonly readonlyStaticType: symbol(); +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) + + static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + static readwriteStaticCall = Symbol(); +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + readonly readonlyCall = Symbol(); +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + readwriteCall = Symbol(); +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) +} +declare const c: C; +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbols.ts, 67, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) + +const constInitToCReadonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbols.ts, 68, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) + +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 69, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) + +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbols.ts, 70, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 72, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) + +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbols.ts, 73, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) + +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbols.ts, 74, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) + +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 75, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) + +const constInitToCReadonlyCall = c.readonlyCall; +>constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbols.ts, 77, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) + +const constInitToCReadwriteCall = c.readwriteCall; +>constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbols.ts, 78, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) + +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +>constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbols.ts, 79, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) + +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +>constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbols.ts, 80, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) + +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +>constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbols.ts, 81, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) + +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; +>constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbols.ts, 82, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) + +// interfaces +interface I { +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) + + readonly readonlyType: symbol(); +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +} +declare const i: I; +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) + +const constInitToIReadonlyType = i.readonlyType; +>constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbols.ts, 90, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) + +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +>constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 91, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) + +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; +>constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 92, 5)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) + +// type literals +type L = { +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) + + readonly readonlyType: symbol(); +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + + nested: { +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) + + readonly readonlyNestedType: symbol(); +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + } +}; +declare const l: L; +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) + +const constInitToLReadonlyType = l.readonlyType; +>constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbols.ts, 103, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbols.ts, 104, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +>constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 105, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbols.ts, 106, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +>constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 107, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 108, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +>promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbols.ts, 111, 5)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +const arrayOfConstCall = [constCall]; +>arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbols.ts, 112, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types new file mode 100644 index 0000000000000..956f6656362e9 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbols.types @@ -0,0 +1,416 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts === +// declarations with call initializer +const constCall = Symbol(); +>constCall : symbol() +>Symbol() : symbol() +>Symbol : SymbolConstructor + +let letCall = Symbol(); +>letCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + +var varCall = Symbol(); +>varCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + +// ambient declaration with type +declare const constType: symbol(); +>constType : symbol() + +// declaration with type and call initializer +const constTypeAndCall: symbol() = Symbol(); +>constTypeAndCall : symbol() +>Symbol() : symbol() +>Symbol : SymbolConstructor + +// declaration from initializer +const constInitToConstCall = constCall; +>constInitToConstCall : symbol +>constCall : symbol() + +const constInitToLetCall = letCall; +>constInitToLetCall : symbol +>letCall : symbol + +const constInitToVarCall = varCall; +>constInitToVarCall : symbol +>varCall : symbol + +const constInitToConstDeclAmbient = constType; +>constInitToConstDeclAmbient : symbol +>constType : symbol() + +let letInitToConstCall = constCall; +>letInitToConstCall : symbol +>constCall : symbol() + +let letInitToLetCall = letCall; +>letInitToLetCall : symbol +>letCall : symbol + +let letInitToVarCall = varCall; +>letInitToVarCall : symbol +>varCall : symbol + +let letInitToConstDeclAmbient = constType; +>letInitToConstDeclAmbient : symbol +>constType : symbol() + +var varInitToConstCall = constCall; +>varInitToConstCall : symbol +>constCall : symbol() + +var varInitToLetCall = letCall; +>varInitToLetCall : symbol +>letCall : symbol + +var varInitToVarCall = varCall; +>varInitToVarCall : symbol +>varCall : symbol + +var varInitToConstDeclAmbient = constType; +>varInitToConstDeclAmbient : symbol +>constType : symbol() + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +>constInitToConstCallWithTypeQuery : symbol +>constCall : symbol() +>constCall : symbol() + +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +>constInitToConstDeclAmbientWithTypeQuery : symbol +>constType : symbol() +>constType : symbol() + +// function return inference +function funcReturnConstCall() { return constCall; } +>funcReturnConstCall : () => symbol +>constCall : symbol() + +function funcReturnLetCall() { return letCall; } +>funcReturnLetCall : () => symbol +>letCall : symbol + +function funcReturnVarCall() { return varCall; } +>funcReturnVarCall : () => symbol +>varCall : symbol + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } +>funcReturnConstCallWithTypeQuery : () => symbol() +>constCall : symbol() +>constCall : symbol() + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +>genFuncYieldConstCall : () => IterableIterator +>yield constCall : any +>constCall : symbol() + +function* genFuncYieldLetCall() { yield letCall; } +>genFuncYieldLetCall : () => IterableIterator +>yield letCall : any +>letCall : symbol + +function* genFuncYieldVarCall() { yield varCall; } +>genFuncYieldVarCall : () => IterableIterator +>yield varCall : any +>varCall : symbol + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } +>genFuncYieldConstCallWithTypeQuery : () => IterableIterator +>IterableIterator : IterableIterator +>constCall : symbol() +>yield constCall : any +>constCall : symbol() + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +>asyncFuncReturnConstCall : () => Promise +>constCall : symbol() + +async function asyncFuncReturnLetCall() { return letCall; } +>asyncFuncReturnLetCall : () => Promise +>letCall : symbol + +async function asyncFuncReturnVarCall() { return varCall; } +>asyncFuncReturnVarCall : () => Promise +>varCall : symbol + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +>asyncGenFuncYieldConstCall : () => AsyncIterableIterator +>yield constCall : any +>constCall : symbol() + +async function* asyncGenFuncYieldLetCall() { yield letCall; } +>asyncGenFuncYieldLetCall : () => AsyncIterableIterator +>yield letCall : any +>letCall : symbol + +async function* asyncGenFuncYieldVarCall() { yield varCall; } +>asyncGenFuncYieldVarCall : () => AsyncIterableIterator +>yield varCall : any +>varCall : symbol + +// classes +class C { +>C : C + + static readonly readonlyStaticCall = Symbol(); +>readonlyStaticCall : symbol() +>Symbol() : symbol() +>Symbol : SymbolConstructor + + static readonly readonlyStaticType: symbol(); +>readonlyStaticType : symbol() + + static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); +>readonlyStaticTypeAndCall : symbol() +>Symbol() : symbol() +>Symbol : SymbolConstructor + + static readwriteStaticCall = Symbol(); +>readwriteStaticCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + + readonly readonlyCall = Symbol(); +>readonlyCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + + readwriteCall = Symbol(); +>readwriteCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor +} +declare const c: C; +>c : C +>C : C + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCall : symbol +>C.readonlyStaticCall : symbol() +>C : typeof C +>readonlyStaticCall : symbol() + +const constInitToCReadonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticType : symbol +>C.readonlyStaticType : symbol() +>C : typeof C +>readonlyStaticType : symbol() + +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCall : symbol +>C.readonlyStaticTypeAndCall : symbol() +>C : typeof C +>readonlyStaticTypeAndCall : symbol() + +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCall : symbol +>C.readwriteStaticCall : symbol +>C : typeof C +>readwriteStaticCall : symbol + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCallWithTypeQuery : symbol +>C.readonlyStaticCall : symbol() +>C : typeof C +>readonlyStaticCall : symbol() +>C.readonlyStaticCall : symbol() +>C : typeof C +>readonlyStaticCall : symbol() + +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticTypeWithTypeQuery : symbol +>C.readonlyStaticType : symbol() +>C : typeof C +>readonlyStaticType : symbol() +>C.readonlyStaticType : symbol() +>C : typeof C +>readonlyStaticType : symbol() + +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : symbol +>C.readonlyStaticTypeAndCall : symbol() +>C : typeof C +>readonlyStaticTypeAndCall : symbol() +>C.readonlyStaticTypeAndCall : symbol() +>C : typeof C +>readonlyStaticTypeAndCall : symbol() + +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCallWithTypeQuery : symbol +>C.readwriteStaticCall : symbol +>C : typeof C +>readwriteStaticCall : symbol +>C.readwriteStaticCall : symbol +>C : typeof C +>readwriteStaticCall : symbol + +const constInitToCReadonlyCall = c.readonlyCall; +>constInitToCReadonlyCall : symbol +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol + +const constInitToCReadwriteCall = c.readwriteCall; +>constInitToCReadwriteCall : symbol +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol + +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +>constInitToCReadonlyCallWithTypeQuery : symbol +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol + +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +>constInitToCReadwriteCallWithTypeQuery : symbol +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol + +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +>constInitToCReadonlyCallWithIndexedAccess : symbol +>C : C +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol + +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; +>constInitToCReadwriteCallWithIndexedAccess : symbol +>C : C +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol + +// interfaces +interface I { +>I : I + + readonly readonlyType: symbol(); +>readonlyType : symbol() +} +declare const i: I; +>i : I +>I : I + +const constInitToIReadonlyType = i.readonlyType; +>constInitToIReadonlyType : symbol +>i.readonlyType : symbol() +>i : I +>readonlyType : symbol() + +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +>constInitToIReadonlyTypeWithTypeQuery : symbol +>i.readonlyType : symbol() +>i : I +>readonlyType : symbol() +>i.readonlyType : symbol() +>i : I +>readonlyType : symbol() + +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; +>constInitToIReadonlyTypeWithIndexedAccess : symbol +>I : I +>i.readonlyType : symbol() +>i : I +>readonlyType : symbol() + +// type literals +type L = { +>L : L + + readonly readonlyType: symbol(); +>readonlyType : symbol() + + nested: { +>nested : { readonly readonlyNestedType: symbol(); } + + readonly readonlyNestedType: symbol(); +>readonlyNestedType : symbol() + } +}; +declare const l: L; +>l : L +>L : L + +const constInitToLReadonlyType = l.readonlyType; +>constInitToLReadonlyType : symbol +>l.readonlyType : symbol() +>l : L +>readonlyType : symbol() + +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedType : symbol +>l.nested.readonlyNestedType : symbol() +>l.nested : { readonly readonlyNestedType: symbol(); } +>l : L +>nested : { readonly readonlyNestedType: symbol(); } +>readonlyNestedType : symbol() + +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +>constInitToLReadonlyTypeWithTypeQuery : symbol +>l.readonlyType : symbol() +>l : L +>readonlyType : symbol() +>l.readonlyType : symbol() +>l : L +>readonlyType : symbol() + +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithTypeQuery : symbol +>l.nested.readonlyNestedType : symbol() +>l.nested : { readonly readonlyNestedType: symbol(); } +>l : L +>nested : { readonly readonlyNestedType: symbol(); } +>readonlyNestedType : symbol() +>l.nested.readonlyNestedType : symbol() +>l.nested : { readonly readonlyNestedType: symbol(); } +>l : L +>nested : { readonly readonlyNestedType: symbol(); } +>readonlyNestedType : symbol() + +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +>constInitToLReadonlyTypeWithIndexedAccess : symbol +>L : L +>l.readonlyType : symbol() +>l : L +>readonlyType : symbol() + +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithIndexedAccess : symbol +>L : L +>l.nested.readonlyNestedType : symbol() +>l.nested : { readonly readonlyNestedType: symbol(); } +>l : L +>nested : { readonly readonlyNestedType: symbol(); } +>readonlyNestedType : symbol() + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +>promiseForConstCall : Promise +>Promise.resolve(constCall) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>constCall : symbol() + +const arrayOfConstCall = [constCall]; +>arrayOfConstCall : symbol[] +>[constCall] : symbol[] +>constCall : symbol() + diff --git a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt new file mode 100644 index 0000000000000..95c9132fb7549 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt @@ -0,0 +1,265 @@ +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(2,19): error TS1337: Unique 'symbol()' types may not be used on a variable declaration with a binding name. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,13): error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(4,13): error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(7,38): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,45): error TS1331: Unique 'symbol()' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,39): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,40): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,53): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,59): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,50): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(17,44): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(19,14): error TS1335: 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(20,5): error TS1335: 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,25): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(22,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,26): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,27): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,40): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,46): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,37): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,26): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,28): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(31,12): error TS1335: 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(32,38): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(33,46): error TS1331: Unique 'symbol()' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,39): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,40): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,53): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,59): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,50): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,39): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,41): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(45,5): error TS1334: 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(46,25): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(47,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,26): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,27): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,40): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,46): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,37): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(57,5): error TS1334: 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(58,25): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(59,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,26): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,27): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,40): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,46): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,37): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(68,21): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,52): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,49): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(73,44): error TS1339: Unique 'symbol()' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1332: Unique 'symbol()' types are not allowed in a tuple type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(78,51): error TS1333: Unique 'symbol()' types are not allowed in a mapped type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,29): error TS1329: Unique 'symbol()' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,40): error TS1329: Unique 'symbol()' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,36): error TS1329: Unique 'symbol()' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,47): error TS1329: Unique 'symbol()' types are not allowed in a union type. + + +==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts (59 errors) ==== + // declarations + declare const {}: symbol(); + ~~~~~~~~ +!!! error TS1337: Unique 'symbol()' types may not be used on a variable declaration with a binding name. + declare let invalidLetType: symbol(); + ~~~~~~~~~~~~~~ +!!! error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. + declare var invalidVarType: symbol(); + ~~~~~~~~~~~~~~ +!!! error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. + + // function arguments and return types + declare function invalidArgType(arg: symbol()): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + declare function invalidRestArgType(...arg: symbol()[]): void; + ~~~~~~~~ +!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. + declare function invalidReturnType(): symbol(); + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + declare function invalidThisType(this: symbol()): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + declare function invalidTypePredicate(n: any): n is symbol(); + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + declare function invalidTypeParameterConstraint(): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + declare function invalidTypeParameterDefault(): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + + // classes + class InvalidClass { + constructor(invalidConstructorArgType: symbol()) {} + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + + readonly invalidReadonlyPropertyType: symbol(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1335: A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'. + invalidPropertyType: symbol(); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1335: A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'. + invalidArgType(arg: symbol()): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidRestArgType(...args: symbol()[]): void { return; } + ~~~~~~~~ +!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. + invalidReturnType(): symbol() { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidThisType(this: symbol()): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypePredicate(n: any): n is symbol() { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypeParameterConstraint(): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypeParameterDefault(): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + get invalidGetter(): symbol() { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + set invalidSetter(arg: symbol()) { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + + static invalidStaticPropertyType: symbol(); + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1335: A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'. + static invalidStaticArgType(arg: symbol()): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + static invalidStaticRestArgType(...args: symbol()[]): void { return; } + ~~~~~~~~ +!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. + static invalidStaticReturnType(): symbol() { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + static invalidStaticThisType(this: symbol()): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + static invalidStaticTypePredicate(n: any): n is symbol() { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + static invalidStaticTypeParameterConstraint(): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + static invalidStaticTypeParameterDefault(): void { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + static get invalidStaticGetter(): symbol() { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + static set invalidStaticSetter(arg: symbol()) { return; } + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + } + + // interfaces + interface InvalidInterface { + invalidPropertyType: symbol(); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1334: A property of an interface or type literal whose type is a unique 'symbol()' type must be 'readonly'. + invalidArgType(arg: symbol()): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidRestArgType(...args: symbol()[]): void; + ~~~~~~~~ +!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. + invalidReturnType(): symbol(); + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidThisType(this: symbol()); + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypePredicate(n: any): n is symbol() + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypeParameterConstraint(): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypeParameterDefault(): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + } + + // type literals + type InvalidTypeLiteral = { + invalidPropertyType: symbol(); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1334: A property of an interface or type literal whose type is a unique 'symbol()' type must be 'readonly'. + invalidArgType(arg: symbol()): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidRestArgType(...args: symbol()[]): void; + ~~~~~~~~ +!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. + invalidReturnType(): symbol(); + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidThisType(this: symbol()); + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypePredicate(n: any): n is symbol() + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypeParameterConstraint(): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + invalidTypeParameterDefault(): void; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + }; + + // type alias + type InvalidAlias = symbol(); + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + type InvalidAliasTypeParameterConstraint = never; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + type InvalidAliasTypeParameterDefault = never; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + + // type references + declare const invalidTypeArgument: Promise; + ~~~~~~~~ +!!! error TS1339: Unique 'symbol()' types are not allowed here. + declare const invalidArrayType: symbol()[]; + ~~~~~~~~ +!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. + declare const invalidTupleType: [symbol()]; + ~~~~~~~~ +!!! error TS1332: Unique 'symbol()' types are not allowed in a tuple type. + + // mapped types + declare const invalidMappedType: { [P in string]: symbol() }; + ~~~~~~~~ +!!! error TS1333: Unique 'symbol()' types are not allowed in a mapped type. + + // unions/intersection + declare const invalidUnion: symbol() | symbol(); + ~~~~~~~~ +!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. + ~~~~~~~~ +!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. + declare const invalidIntersection: symbol() | symbol(); + ~~~~~~~~ +!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. + ~~~~~~~~ +!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. + + + \ No newline at end of file diff --git a/tests/baselines/reference/uniqueSymbolsErrors.js b/tests/baselines/reference/uniqueSymbolsErrors.js new file mode 100644 index 0000000000000..806e28a717848 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.js @@ -0,0 +1,110 @@ +//// [uniqueSymbolsErrors.ts] +// declarations +declare const {}: symbol(); +declare let invalidLetType: symbol(); +declare var invalidVarType: symbol(); + +// function arguments and return types +declare function invalidArgType(arg: symbol()): void; +declare function invalidRestArgType(...arg: symbol()[]): void; +declare function invalidReturnType(): symbol(); +declare function invalidThisType(this: symbol()): void; +declare function invalidTypePredicate(n: any): n is symbol(); +declare function invalidTypeParameterConstraint(): void; +declare function invalidTypeParameterDefault(): void; + +// classes +class InvalidClass { + constructor(invalidConstructorArgType: symbol()) {} + + readonly invalidReadonlyPropertyType: symbol(); + invalidPropertyType: symbol(); + invalidArgType(arg: symbol()): void { return; } + invalidRestArgType(...args: symbol()[]): void { return; } + invalidReturnType(): symbol() { return; } + invalidThisType(this: symbol()): void { return; } + invalidTypePredicate(n: any): n is symbol() { return; } + invalidTypeParameterConstraint(): void { return; } + invalidTypeParameterDefault(): void { return; } + get invalidGetter(): symbol() { return; } + set invalidSetter(arg: symbol()) { return; } + + static invalidStaticPropertyType: symbol(); + static invalidStaticArgType(arg: symbol()): void { return; } + static invalidStaticRestArgType(...args: symbol()[]): void { return; } + static invalidStaticReturnType(): symbol() { return; } + static invalidStaticThisType(this: symbol()): void { return; } + static invalidStaticTypePredicate(n: any): n is symbol() { return; } + static invalidStaticTypeParameterConstraint(): void { return; } + static invalidStaticTypeParameterDefault(): void { return; } + static get invalidStaticGetter(): symbol() { return; } + static set invalidStaticSetter(arg: symbol()) { return; } +} + +// interfaces +interface InvalidInterface { + invalidPropertyType: symbol(); + invalidArgType(arg: symbol()): void; + invalidRestArgType(...args: symbol()[]): void; + invalidReturnType(): symbol(); + invalidThisType(this: symbol()); + invalidTypePredicate(n: any): n is symbol() + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +} + +// type literals +type InvalidTypeLiteral = { + invalidPropertyType: symbol(); + invalidArgType(arg: symbol()): void; + invalidRestArgType(...args: symbol()[]): void; + invalidReturnType(): symbol(); + invalidThisType(this: symbol()); + invalidTypePredicate(n: any): n is symbol() + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +}; + +// type alias +type InvalidAlias = symbol(); +type InvalidAliasTypeParameterConstraint = never; +type InvalidAliasTypeParameterDefault = never; + +// type references +declare const invalidTypeArgument: Promise; +declare const invalidArrayType: symbol()[]; +declare const invalidTupleType: [symbol()]; + +// mapped types +declare const invalidMappedType: { [P in string]: symbol() }; + +// unions/intersection +declare const invalidUnion: symbol() | symbol(); +declare const invalidIntersection: symbol() | symbol(); + + + + +//// [uniqueSymbolsErrors.js] +// classes +class InvalidClass { + constructor(invalidConstructorArgType) { } + invalidArgType(arg) { return; } + invalidRestArgType(...args) { return; } + invalidReturnType() { return; } + invalidThisType() { return; } + invalidTypePredicate(n) { return; } + invalidTypeParameterConstraint() { return; } + invalidTypeParameterDefault() { return; } + get invalidGetter() { return; } + set invalidSetter(arg) { return; } + static invalidStaticArgType(arg) { return; } + static invalidStaticRestArgType(...args) { return; } + static invalidStaticReturnType() { return; } + static invalidStaticThisType() { return; } + static invalidStaticTypePredicate(n) { return; } + static invalidStaticTypeParameterConstraint() { return; } + static invalidStaticTypeParameterDefault() { return; } + static get invalidStaticGetter() { return; } + static set invalidStaticSetter(arg) { return; } +} diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index 3bf663892a73b..e07febc7c7c27 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -31,7 +31,7 @@ import * as M from "./module"; namespace N { export const c2 = "a"; export const c3 = 1; - export const s1 = s0; + export const s1: typeof s0 = s0; export interface T4 { [N.c2]: number; @@ -54,7 +54,7 @@ namespace N { export const c4 = "a"; export const c5 = 1; -export const s2 = s0; +export const s2: typeof s0 = s0; interface T8 { [c4]: number; diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts new file mode 100644 index 0000000000000..e21e6eb195dc5 --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts @@ -0,0 +1,117 @@ +// @target: esnext +// @lib: esnext +// @declaration: true + +// declarations with call initializer +const constCall = Symbol(); +let letCall = Symbol(); +var varCall = Symbol(); + +// ambient declaration with type +declare const constType: symbol(); + +// declaration with type and call initializer +const constTypeAndCall: symbol() = Symbol(); + +// declaration from initializer +const constInitToConstCall = constCall; +const constInitToLetCall = letCall; +const constInitToVarCall = varCall; +const constInitToConstDeclAmbient = constType; +let letInitToConstCall = constCall; +let letInitToLetCall = letCall; +let letInitToVarCall = varCall; +let letInitToConstDeclAmbient = constType; +var varInitToConstCall = constCall; +var varInitToLetCall = letCall; +var varInitToVarCall = varCall; +var varInitToConstDeclAmbient = constType; + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; + +// function return inference +function funcReturnConstCall() { return constCall; } +function funcReturnLetCall() { return letCall; } +function funcReturnVarCall() { return varCall; } + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +function* genFuncYieldLetCall() { yield letCall; } +function* genFuncYieldVarCall() { yield varCall; } + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +async function asyncFuncReturnLetCall() { return letCall; } +async function asyncFuncReturnVarCall() { return varCall; } + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +async function* asyncGenFuncYieldLetCall() { yield letCall; } +async function* asyncGenFuncYieldVarCall() { yield varCall; } + +// classes +class C { + static readonly readonlyStaticCall = Symbol(); + static readonly readonlyStaticType: symbol(); + static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); + static readwriteStaticCall = Symbol(); + + readonly readonlyCall = Symbol(); + readwriteCall = Symbol(); +} +declare const c: C; + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyCall = c.readonlyCall; +const constInitToCReadwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; + +// interfaces +interface I { + readonly readonlyType: symbol(); +} +declare const i: I; + +const constInitToIReadonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; + +// type literals +type L = { + readonly readonlyType: symbol(); + nested: { + readonly readonlyNestedType: symbol(); + } +}; +declare const l: L; + +const constInitToLReadonlyType = l.readonlyType; +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +const arrayOfConstCall = [constCall]; \ No newline at end of file diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts new file mode 100644 index 0000000000000..c077d5852ad1c --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts @@ -0,0 +1,86 @@ +// @target: esnext + +// declarations +declare const {}: symbol(); +declare let invalidLetType: symbol(); +declare var invalidVarType: symbol(); + +// function arguments and return types +declare function invalidArgType(arg: symbol()): void; +declare function invalidRestArgType(...arg: symbol()[]): void; +declare function invalidReturnType(): symbol(); +declare function invalidThisType(this: symbol()): void; +declare function invalidTypePredicate(n: any): n is symbol(); +declare function invalidTypeParameterConstraint(): void; +declare function invalidTypeParameterDefault(): void; + +// classes +class InvalidClass { + constructor(invalidConstructorArgType: symbol()) {} + + readonly invalidReadonlyPropertyType: symbol(); + invalidPropertyType: symbol(); + invalidArgType(arg: symbol()): void { return; } + invalidRestArgType(...args: symbol()[]): void { return; } + invalidReturnType(): symbol() { return; } + invalidThisType(this: symbol()): void { return; } + invalidTypePredicate(n: any): n is symbol() { return; } + invalidTypeParameterConstraint(): void { return; } + invalidTypeParameterDefault(): void { return; } + get invalidGetter(): symbol() { return; } + set invalidSetter(arg: symbol()) { return; } + + static invalidStaticPropertyType: symbol(); + static invalidStaticArgType(arg: symbol()): void { return; } + static invalidStaticRestArgType(...args: symbol()[]): void { return; } + static invalidStaticReturnType(): symbol() { return; } + static invalidStaticThisType(this: symbol()): void { return; } + static invalidStaticTypePredicate(n: any): n is symbol() { return; } + static invalidStaticTypeParameterConstraint(): void { return; } + static invalidStaticTypeParameterDefault(): void { return; } + static get invalidStaticGetter(): symbol() { return; } + static set invalidStaticSetter(arg: symbol()) { return; } +} + +// interfaces +interface InvalidInterface { + invalidPropertyType: symbol(); + invalidArgType(arg: symbol()): void; + invalidRestArgType(...args: symbol()[]): void; + invalidReturnType(): symbol(); + invalidThisType(this: symbol()); + invalidTypePredicate(n: any): n is symbol() + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +} + +// type literals +type InvalidTypeLiteral = { + invalidPropertyType: symbol(); + invalidArgType(arg: symbol()): void; + invalidRestArgType(...args: symbol()[]): void; + invalidReturnType(): symbol(); + invalidThisType(this: symbol()); + invalidTypePredicate(n: any): n is symbol() + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +}; + +// type alias +type InvalidAlias = symbol(); +type InvalidAliasTypeParameterConstraint = never; +type InvalidAliasTypeParameterDefault = never; + +// type references +declare const invalidTypeArgument: Promise; +declare const invalidArrayType: symbol()[]; +declare const invalidTupleType: [symbol()]; + +// mapped types +declare const invalidMappedType: { [P in string]: symbol() }; + +// unions/intersection +declare const invalidUnion: symbol() | symbol(); +declare const invalidIntersection: symbol() | symbol(); + + From 7eedf2e487c7cd7f42d4725582c50743c8a91051 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sun, 1 Oct 2017 13:04:00 -0700 Subject: [PATCH 17/43] Update baselines --- tests/baselines/reference/uniqueSymbols.types | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index 956f6656362e9..c9ccf9baaacbf 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -76,12 +76,12 @@ var varInitToConstDeclAmbient = constType; // declaration from initializer with type query const constInitToConstCallWithTypeQuery: typeof constCall = constCall; ->constInitToConstCallWithTypeQuery : symbol +>constInitToConstCallWithTypeQuery : symbol() >constCall : symbol() >constCall : symbol() const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; ->constInitToConstDeclAmbientWithTypeQuery : symbol +>constInitToConstDeclAmbientWithTypeQuery : symbol() >constType : symbol() >constType : symbol() @@ -218,7 +218,7 @@ const constInitToCReadwriteStaticCall = C.readwriteStaticCall; >readwriteStaticCall : symbol const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; ->constInitToCReadonlyStaticCallWithTypeQuery : symbol +>constInitToCReadonlyStaticCallWithTypeQuery : symbol() >C.readonlyStaticCall : symbol() >C : typeof C >readonlyStaticCall : symbol() @@ -227,7 +227,7 @@ const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = >readonlyStaticCall : symbol() const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; ->constInitToCReadonlyStaticTypeWithTypeQuery : symbol +>constInitToCReadonlyStaticTypeWithTypeQuery : symbol() >C.readonlyStaticType : symbol() >C : typeof C >readonlyStaticType : symbol() @@ -236,7 +236,7 @@ const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = >readonlyStaticType : symbol() const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; ->constInitToCReadonlyStaticTypeAndCallWithTypeQuery : symbol +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : symbol() >C.readonlyStaticTypeAndCall : symbol() >C : typeof C >readonlyStaticTypeAndCall : symbol() @@ -315,7 +315,7 @@ const constInitToIReadonlyType = i.readonlyType; >readonlyType : symbol() const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; ->constInitToIReadonlyTypeWithTypeQuery : symbol +>constInitToIReadonlyTypeWithTypeQuery : symbol() >i.readonlyType : symbol() >i : I >readonlyType : symbol() @@ -324,7 +324,7 @@ const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyT >readonlyType : symbol() const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; ->constInitToIReadonlyTypeWithIndexedAccess : symbol +>constInitToIReadonlyTypeWithIndexedAccess : symbol() >I : I >i.readonlyType : symbol() >i : I @@ -363,7 +363,7 @@ const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; >readonlyNestedType : symbol() const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; ->constInitToLReadonlyTypeWithTypeQuery : symbol +>constInitToLReadonlyTypeWithTypeQuery : symbol() >l.readonlyType : symbol() >l : L >readonlyType : symbol() @@ -372,7 +372,7 @@ const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyT >readonlyType : symbol() const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithTypeQuery : symbol +>constInitToLReadonlyNestedTypeWithTypeQuery : symbol() >l.nested.readonlyNestedType : symbol() >l.nested : { readonly readonlyNestedType: symbol(); } >l : L @@ -385,14 +385,14 @@ const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNeste >readonlyNestedType : symbol() const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; ->constInitToLReadonlyTypeWithIndexedAccess : symbol +>constInitToLReadonlyTypeWithIndexedAccess : symbol() >L : L >l.readonlyType : symbol() >l : L >readonlyType : symbol() const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithIndexedAccess : symbol +>constInitToLReadonlyNestedTypeWithIndexedAccess : symbol() >L : L >l.nested.readonlyNestedType : symbol() >l.nested : { readonly readonlyNestedType: symbol(); } From 1b45a05f7e3d1371babf5414d802550a7bf52cee Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 2 Oct 2017 11:51:05 -0700 Subject: [PATCH 18/43] Update baselines --- .../computedPropertyNames12_ES5.symbols | 4 +- .../computedPropertyNames12_ES6.symbols | 4 +- .../computedPropertyNames36_ES5.symbols | 4 +- .../computedPropertyNames36_ES6.symbols | 4 +- .../computedPropertyNames40_ES5.symbols | 4 +- .../computedPropertyNames40_ES6.symbols | 4 +- .../computedPropertyNames42_ES5.symbols | 2 +- .../computedPropertyNames42_ES6.symbols | 2 +- .../computedPropertyNames43_ES5.symbols | 4 +- .../computedPropertyNames43_ES6.symbols | 4 +- .../computedPropertyNames44_ES5.symbols | 4 +- .../computedPropertyNames44_ES6.symbols | 4 +- .../computedPropertyNames45_ES5.symbols | 4 +- .../computedPropertyNames45_ES6.symbols | 4 +- .../reference/decoratorOnClassMethod6.symbols | 2 +- .../duplicateIdentifierComputedName.symbols | 4 +- .../reference/dynamicNamesErrors.symbols | 62 +++++ .../reference/dynamicNamesErrors.types | 66 +++++ .../literalsInComputedProperties1.symbols | 24 +- .../reference/uniqueSymbolsErrors.symbols | 235 ++++++++++++++++++ .../reference/uniqueSymbolsErrors.types | 235 ++++++++++++++++++ 21 files changed, 639 insertions(+), 41 deletions(-) create mode 100644 tests/baselines/reference/dynamicNamesErrors.symbols create mode 100644 tests/baselines/reference/dynamicNamesErrors.types create mode 100644 tests/baselines/reference/uniqueSymbolsErrors.symbols create mode 100644 tests/baselines/reference/uniqueSymbolsErrors.types diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.symbols b/tests/baselines/reference/computedPropertyNames12_ES5.symbols index a6519a5dedf55..619a54c76c9ee 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames12_ES5.symbols @@ -31,10 +31,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames12_ES5.ts, 0, 3)) static [""]: number; ->"" : Symbol(C[[""]], Decl(computedPropertyNames12_ES5.ts, 8, 19)) +>"" : Symbol(C[""], Decl(computedPropertyNames12_ES5.ts, 8, 19)) [0]: number; ->0 : Symbol(C[[0]], Decl(computedPropertyNames12_ES5.ts, 9, 24)) +>0 : Symbol(C[0], Decl(computedPropertyNames12_ES5.ts, 9, 24)) [a]: number; >a : Symbol(a, Decl(computedPropertyNames12_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.symbols b/tests/baselines/reference/computedPropertyNames12_ES6.symbols index 3ba128eb1c26e..9cb6fb3fa4bf7 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames12_ES6.symbols @@ -31,10 +31,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames12_ES6.ts, 0, 3)) static [""]: number; ->"" : Symbol(C[[""]], Decl(computedPropertyNames12_ES6.ts, 8, 19)) +>"" : Symbol(C[""], Decl(computedPropertyNames12_ES6.ts, 8, 19)) [0]: number; ->0 : Symbol(C[[0]], Decl(computedPropertyNames12_ES6.ts, 9, 24)) +>0 : Symbol(C[0], Decl(computedPropertyNames12_ES6.ts, 9, 24)) [a]: number; >a : Symbol(a, Decl(computedPropertyNames12_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames36_ES5.symbols b/tests/baselines/reference/computedPropertyNames36_ES5.symbols index b0ee9a5a6c335..f0c9adbf22f1b 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames36_ES5.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames36_ES5.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames36_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames36_ES5.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames36_ES5.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames36_ES5.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames36_ES5.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames36_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames36_ES6.symbols b/tests/baselines/reference/computedPropertyNames36_ES6.symbols index 5a7fa1cdb8dc1..ad406fa526612 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames36_ES6.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames36_ES6.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames36_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames36_ES6.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames36_ES6.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames36_ES6.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames36_ES6.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames36_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames40_ES5.symbols b/tests/baselines/reference/computedPropertyNames40_ES5.symbols index 67535664576f1..d59a516b5e280 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames40_ES5.symbols @@ -17,10 +17,10 @@ class C { // Computed properties [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) >Foo : Symbol(Foo, Decl(computedPropertyNames40_ES5.ts, 0, 0)) [""]() { return new Foo2 } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames40_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames40_ES6.symbols b/tests/baselines/reference/computedPropertyNames40_ES6.symbols index 71cb41642fc66..f5881fa6a6b59 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames40_ES6.symbols @@ -17,10 +17,10 @@ class C { // Computed properties [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) >Foo : Symbol(Foo, Decl(computedPropertyNames40_ES6.ts, 0, 0)) [""]() { return new Foo2 } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames40_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames42_ES5.symbols b/tests/baselines/reference/computedPropertyNames42_ES5.symbols index c4fc11571f0de..7c3fa50362a1a 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames42_ES5.symbols @@ -17,6 +17,6 @@ class C { // Computed properties [""]: Foo; ->"" : Symbol(C[[""]], Decl(computedPropertyNames42_ES5.ts, 4, 22)) +>"" : Symbol(C[""], Decl(computedPropertyNames42_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames42_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames42_ES6.symbols b/tests/baselines/reference/computedPropertyNames42_ES6.symbols index fef7d3c50089d..2055a90e07406 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames42_ES6.symbols @@ -17,6 +17,6 @@ class C { // Computed properties [""]: Foo; ->"" : Symbol(C[[""]], Decl(computedPropertyNames42_ES6.ts, 4, 22)) +>"" : Symbol(C[""], Decl(computedPropertyNames42_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames42_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.symbols b/tests/baselines/reference/computedPropertyNames43_ES5.symbols index 3765c9af51d63..3fe757202806d 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames43_ES5.symbols @@ -22,11 +22,11 @@ class D extends C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(D[["get1"]], Decl(computedPropertyNames43_ES5.ts, 7, 19)) +>"get1" : Symbol(D["get1"], Decl(computedPropertyNames43_ES5.ts, 7, 19)) >Foo : Symbol(Foo, Decl(computedPropertyNames43_ES5.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames43_ES5.ts, 9, 37)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames43_ES5.ts, 9, 37)) >p : Symbol(p, Decl(computedPropertyNames43_ES5.ts, 10, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames43_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames43_ES6.symbols b/tests/baselines/reference/computedPropertyNames43_ES6.symbols index f37c0943bfd6b..4c2c808277104 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames43_ES6.symbols @@ -22,11 +22,11 @@ class D extends C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(D[["get1"]], Decl(computedPropertyNames43_ES6.ts, 7, 19)) +>"get1" : Symbol(D["get1"], Decl(computedPropertyNames43_ES6.ts, 7, 19)) >Foo : Symbol(Foo, Decl(computedPropertyNames43_ES6.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames43_ES6.ts, 9, 37)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames43_ES6.ts, 9, 37)) >p : Symbol(p, Decl(computedPropertyNames43_ES6.ts, 10, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames43_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.symbols b/tests/baselines/reference/computedPropertyNames44_ES5.symbols index ed097da110a70..ca3841411a099 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames44_ES5.symbols @@ -16,7 +16,7 @@ class C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames44_ES5.ts, 0, 15)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames44_ES5.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames44_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES5.ts, 0, 0)) } @@ -25,7 +25,7 @@ class D extends C { >C : Symbol(C, Decl(computedPropertyNames44_ES5.ts, 1, 19)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames44_ES5.ts, 8, 19)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames44_ES5.ts, 8, 19)) >p : Symbol(p, Decl(computedPropertyNames44_ES5.ts, 9, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames44_ES6.symbols b/tests/baselines/reference/computedPropertyNames44_ES6.symbols index 7ac6914fe5a6c..13abd6f8f24a9 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames44_ES6.symbols @@ -16,7 +16,7 @@ class C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames44_ES6.ts, 0, 15)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames44_ES6.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames44_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES6.ts, 0, 0)) } @@ -25,7 +25,7 @@ class D extends C { >C : Symbol(C, Decl(computedPropertyNames44_ES6.ts, 1, 19)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames44_ES6.ts, 8, 19)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames44_ES6.ts, 8, 19)) >p : Symbol(p, Decl(computedPropertyNames44_ES6.ts, 9, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.symbols b/tests/baselines/reference/computedPropertyNames45_ES5.symbols index 3028174bb4f3e..04887f8e9ffec 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames45_ES5.symbols @@ -12,7 +12,7 @@ class C { >C : Symbol(C, Decl(computedPropertyNames45_ES5.ts, 1, 19)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames45_ES5.ts, 3, 9)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames45_ES5.ts, 3, 9)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES5.ts, 0, 0)) } @@ -26,7 +26,7 @@ class D extends C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames45_ES5.ts, 0, 15)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames45_ES5.ts, 9, 22)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames45_ES5.ts, 9, 22)) >p : Symbol(p, Decl(computedPropertyNames45_ES5.ts, 10, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames45_ES6.symbols b/tests/baselines/reference/computedPropertyNames45_ES6.symbols index 110fe23aeef38..5e01cb0201e80 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames45_ES6.symbols @@ -12,7 +12,7 @@ class C { >C : Symbol(C, Decl(computedPropertyNames45_ES6.ts, 1, 19)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames45_ES6.ts, 3, 9)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames45_ES6.ts, 3, 9)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES6.ts, 0, 0)) } @@ -26,7 +26,7 @@ class D extends C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames45_ES6.ts, 0, 15)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames45_ES6.ts, 9, 22)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames45_ES6.ts, 9, 22)) >p : Symbol(p, Decl(computedPropertyNames45_ES6.ts, 10, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod6.symbols b/tests/baselines/reference/decoratorOnClassMethod6.symbols index 6391192ece3de..bc9046aa666a6 100644 --- a/tests/baselines/reference/decoratorOnClassMethod6.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod6.symbols @@ -15,5 +15,5 @@ class C { @dec ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod6.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod6.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod6.ts, 2, 9)) } diff --git a/tests/baselines/reference/duplicateIdentifierComputedName.symbols b/tests/baselines/reference/duplicateIdentifierComputedName.symbols index 0f5753e0eb6bd..efe01b6a34940 100644 --- a/tests/baselines/reference/duplicateIdentifierComputedName.symbols +++ b/tests/baselines/reference/duplicateIdentifierComputedName.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(duplicateIdentifierComputedName.ts, 0, 0)) ["a"]: string; ->"a" : Symbol(C[["a"]], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) +>"a" : Symbol(C["a"], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) ["a"]: string; ->"a" : Symbol(C[["a"]], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) +>"a" : Symbol(C["a"], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) } diff --git a/tests/baselines/reference/dynamicNamesErrors.symbols b/tests/baselines/reference/dynamicNamesErrors.symbols new file mode 100644 index 0000000000000..cc8c3a2e6cfc8 --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.symbols @@ -0,0 +1,62 @@ +=== tests/cases/compiler/dynamicNamesErrors.ts === +const c0 = "1"; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) + +const c1 = 1; +>c1 : Symbol(c1, Decl(dynamicNamesErrors.ts, 1, 5)) + +interface T0 { +>T0 : Symbol(T0, Decl(dynamicNamesErrors.ts, 1, 13)) + + [c0]: number; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) + + 1: number; +} + +interface T1 { +>T1 : Symbol(T1, Decl(dynamicNamesErrors.ts, 6, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) +} + +interface T2 { +>T2 : Symbol(T2, Decl(dynamicNamesErrors.ts, 10, 1)) + + [c0]: string; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) +} + +interface T3 { +>T3 : Symbol(T3, Decl(dynamicNamesErrors.ts, 14, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) + + [c1]: string; +>c1 : Symbol(c1, Decl(dynamicNamesErrors.ts, 1, 5)) +} + +let t1: T1; +>t1 : Symbol(t1, Decl(dynamicNamesErrors.ts, 21, 3)) +>T1 : Symbol(T1, Decl(dynamicNamesErrors.ts, 6, 1)) + +let t2: T2; +>t2 : Symbol(t2, Decl(dynamicNamesErrors.ts, 22, 3)) +>T2 : Symbol(T2, Decl(dynamicNamesErrors.ts, 10, 1)) + +t1 = t2; +>t1 : Symbol(t1, Decl(dynamicNamesErrors.ts, 21, 3)) +>t2 : Symbol(t2, Decl(dynamicNamesErrors.ts, 22, 3)) + +t2 = t1; +>t2 : Symbol(t2, Decl(dynamicNamesErrors.ts, 22, 3)) +>t1 : Symbol(t1, Decl(dynamicNamesErrors.ts, 21, 3)) + +export interface T4 { +>T4 : Symbol(T4, Decl(dynamicNamesErrors.ts, 24, 8)) + + [c0]: number; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) +} diff --git a/tests/baselines/reference/dynamicNamesErrors.types b/tests/baselines/reference/dynamicNamesErrors.types new file mode 100644 index 0000000000000..afee89cf39791 --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.types @@ -0,0 +1,66 @@ +=== tests/cases/compiler/dynamicNamesErrors.ts === +const c0 = "1"; +>c0 : "1" +>"1" : "1" + +const c1 = 1; +>c1 : 1 +>1 : 1 + +interface T0 { +>T0 : T0 + + [c0]: number; +>c0 : "1" + + 1: number; +} + +interface T1 { +>T1 : T1 + + [c0]: number; +>c0 : "1" +} + +interface T2 { +>T2 : T2 + + [c0]: string; +>c0 : "1" +} + +interface T3 { +>T3 : T3 + + [c0]: number; +>c0 : "1" + + [c1]: string; +>c1 : 1 +} + +let t1: T1; +>t1 : T1 +>T1 : T1 + +let t2: T2; +>t2 : T2 +>T2 : T2 + +t1 = t2; +>t1 = t2 : T2 +>t1 : T1 +>t2 : T2 + +t2 = t1; +>t2 = t1 : T1 +>t2 : T2 +>t1 : T1 + +export interface T4 { +>T4 : T4 + + [c0]: number; +>c0 : "1" +} diff --git a/tests/baselines/reference/literalsInComputedProperties1.symbols b/tests/baselines/reference/literalsInComputedProperties1.symbols index e0f22d39e8d32..501b969706ab7 100644 --- a/tests/baselines/reference/literalsInComputedProperties1.symbols +++ b/tests/baselines/reference/literalsInComputedProperties1.symbols @@ -39,11 +39,11 @@ interface A { 1:number; [2]:number; ->2 : Symbol(A[[2]], Decl(literalsInComputedProperties1.ts, 12, 13)) +>2 : Symbol(A[2], Decl(literalsInComputedProperties1.ts, 12, 13)) "3":number; ["4"]:number; ->"4" : Symbol(A[["4"]], Decl(literalsInComputedProperties1.ts, 14, 15)) +>"4" : Symbol(A["4"], Decl(literalsInComputedProperties1.ts, 14, 15)) } let y:A; @@ -59,7 +59,7 @@ y[1].toExponential(); y[2].toExponential(); >y[2].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(literalsInComputedProperties1.ts, 18, 3)) ->2 : Symbol(A[[2]], Decl(literalsInComputedProperties1.ts, 12, 13)) +>2 : Symbol(A[2], Decl(literalsInComputedProperties1.ts, 12, 13)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) y[3].toExponential(); @@ -71,7 +71,7 @@ y[3].toExponential(); y[4].toExponential(); >y[4].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(literalsInComputedProperties1.ts, 18, 3)) ->4 : Symbol(A[["4"]], Decl(literalsInComputedProperties1.ts, 14, 15)) +>4 : Symbol(A["4"], Decl(literalsInComputedProperties1.ts, 14, 15)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) class C { @@ -79,11 +79,11 @@ class C { 1:number; [2]:number; ->2 : Symbol(C[[2]], Decl(literalsInComputedProperties1.ts, 25, 13)) +>2 : Symbol(C[2], Decl(literalsInComputedProperties1.ts, 25, 13)) "3":number; ["4"]:number; ->"4" : Symbol(C[["4"]], Decl(literalsInComputedProperties1.ts, 27, 15)) +>"4" : Symbol(C["4"], Decl(literalsInComputedProperties1.ts, 27, 15)) } let z:C; @@ -99,7 +99,7 @@ z[1].toExponential(); z[2].toExponential(); >z[2].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >z : Symbol(z, Decl(literalsInComputedProperties1.ts, 31, 3)) ->2 : Symbol(C[[2]], Decl(literalsInComputedProperties1.ts, 25, 13)) +>2 : Symbol(C[2], Decl(literalsInComputedProperties1.ts, 25, 13)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) z[3].toExponential(); @@ -111,7 +111,7 @@ z[3].toExponential(); z[4].toExponential(); >z[4].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >z : Symbol(z, Decl(literalsInComputedProperties1.ts, 31, 3)) ->4 : Symbol(C[["4"]], Decl(literalsInComputedProperties1.ts, 27, 15)) +>4 : Symbol(C["4"], Decl(literalsInComputedProperties1.ts, 27, 15)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) enum X { @@ -119,15 +119,15 @@ enum X { 1 = 1, [2] = 2, ->2 : Symbol(X[[2]], Decl(literalsInComputedProperties1.ts, 38, 10)) +>2 : Symbol(X[2], Decl(literalsInComputedProperties1.ts, 38, 10)) "3" = 3, ["4"] = 4, ->"4" : Symbol(X[["4"]], Decl(literalsInComputedProperties1.ts, 40, 12)) +>"4" : Symbol(X["4"], Decl(literalsInComputedProperties1.ts, 40, 12)) "foo" = 5, ["bar"] = 6 ->"bar" : Symbol(X[["bar"]], Decl(literalsInComputedProperties1.ts, 42, 14)) +>"bar" : Symbol(X["bar"], Decl(literalsInComputedProperties1.ts, 42, 14)) } let a = X["foo"]; @@ -138,6 +138,6 @@ let a = X["foo"]; let a0 = X["bar"]; >a0 : Symbol(a0, Decl(literalsInComputedProperties1.ts, 47, 3)) >X : Symbol(X, Decl(literalsInComputedProperties1.ts, 35, 21)) ->"bar" : Symbol(X[["bar"]], Decl(literalsInComputedProperties1.ts, 42, 14)) +>"bar" : Symbol(X["bar"], Decl(literalsInComputedProperties1.ts, 42, 14)) // TODO: make sure that enum still disallow template literals as member names diff --git a/tests/baselines/reference/uniqueSymbolsErrors.symbols b/tests/baselines/reference/uniqueSymbolsErrors.symbols new file mode 100644 index 0000000000000..75c06e720d5b6 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.symbols @@ -0,0 +1,235 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === +// declarations +declare const {}: symbol(); +declare let invalidLetType: symbol(); +>invalidLetType : Symbol(invalidLetType, Decl(uniqueSymbolsErrors.ts, 2, 11)) + +declare var invalidVarType: symbol(); +>invalidVarType : Symbol(invalidVarType, Decl(uniqueSymbolsErrors.ts, 3, 11)) + +// function arguments and return types +declare function invalidArgType(arg: symbol()): void; +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 3, 37)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 6, 32)) + +declare function invalidRestArgType(...arg: symbol()[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 6, 53)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 7, 36)) + +declare function invalidReturnType(): symbol(); +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 7, 62)) + +declare function invalidThisType(this: symbol()): void; +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 8, 47)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 9, 33)) + +declare function invalidTypePredicate(n: any): n is symbol(); +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 9, 55)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 10, 38)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 10, 38)) + +declare function invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 10, 61)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 11, 48)) + +declare function invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 11, 76)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 12, 45)) + +// classes +class InvalidClass { +>InvalidClass : Symbol(InvalidClass, Decl(uniqueSymbolsErrors.ts, 12, 67)) + + constructor(invalidConstructorArgType: symbol()) {} +>invalidConstructorArgType : Symbol(invalidConstructorArgType, Decl(uniqueSymbolsErrors.ts, 16, 16)) + + readonly invalidReadonlyPropertyType: symbol(); +>invalidReadonlyPropertyType : Symbol(InvalidClass.invalidReadonlyPropertyType, Decl(uniqueSymbolsErrors.ts, 16, 55)) + + invalidPropertyType: symbol(); +>invalidPropertyType : Symbol(InvalidClass.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 18, 51)) + + invalidArgType(arg: symbol()): void { return; } +>invalidArgType : Symbol(InvalidClass.invalidArgType, Decl(uniqueSymbolsErrors.ts, 19, 34)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 20, 19)) + + invalidRestArgType(...args: symbol()[]): void { return; } +>invalidRestArgType : Symbol(InvalidClass.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 20, 51)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 21, 23)) + + invalidReturnType(): symbol() { return; } +>invalidReturnType : Symbol(InvalidClass.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 21, 61)) + + invalidThisType(this: symbol()): void { return; } +>invalidThisType : Symbol(InvalidClass.invalidThisType, Decl(uniqueSymbolsErrors.ts, 22, 45)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 23, 20)) + + invalidTypePredicate(n: any): n is symbol() { return; } +>invalidTypePredicate : Symbol(InvalidClass.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 23, 53)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 24, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 24, 25)) + + invalidTypeParameterConstraint(): void { return; } +>invalidTypeParameterConstraint : Symbol(InvalidClass.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 24, 59)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 25, 35)) + + invalidTypeParameterDefault(): void { return; } +>invalidTypeParameterDefault : Symbol(InvalidClass.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 25, 74)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 26, 32)) + + get invalidGetter(): symbol() { return; } +>invalidGetter : Symbol(InvalidClass.invalidGetter, Decl(uniqueSymbolsErrors.ts, 26, 65)) + + set invalidSetter(arg: symbol()) { return; } +>invalidSetter : Symbol(InvalidClass.invalidSetter, Decl(uniqueSymbolsErrors.ts, 27, 45)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 28, 22)) + + static invalidStaticPropertyType: symbol(); +>invalidStaticPropertyType : Symbol(InvalidClass.invalidStaticPropertyType, Decl(uniqueSymbolsErrors.ts, 28, 48)) + + static invalidStaticArgType(arg: symbol()): void { return; } +>invalidStaticArgType : Symbol(InvalidClass.invalidStaticArgType, Decl(uniqueSymbolsErrors.ts, 30, 47)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 31, 32)) + + static invalidStaticRestArgType(...args: symbol()[]): void { return; } +>invalidStaticRestArgType : Symbol(InvalidClass.invalidStaticRestArgType, Decl(uniqueSymbolsErrors.ts, 31, 64)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 32, 36)) + + static invalidStaticReturnType(): symbol() { return; } +>invalidStaticReturnType : Symbol(InvalidClass.invalidStaticReturnType, Decl(uniqueSymbolsErrors.ts, 32, 74)) + + static invalidStaticThisType(this: symbol()): void { return; } +>invalidStaticThisType : Symbol(InvalidClass.invalidStaticThisType, Decl(uniqueSymbolsErrors.ts, 33, 58)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 34, 33)) + + static invalidStaticTypePredicate(n: any): n is symbol() { return; } +>invalidStaticTypePredicate : Symbol(InvalidClass.invalidStaticTypePredicate, Decl(uniqueSymbolsErrors.ts, 34, 66)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 35, 38)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 35, 38)) + + static invalidStaticTypeParameterConstraint(): void { return; } +>invalidStaticTypeParameterConstraint : Symbol(InvalidClass.invalidStaticTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 35, 72)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 36, 48)) + + static invalidStaticTypeParameterDefault(): void { return; } +>invalidStaticTypeParameterDefault : Symbol(InvalidClass.invalidStaticTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 36, 87)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 37, 45)) + + static get invalidStaticGetter(): symbol() { return; } +>invalidStaticGetter : Symbol(InvalidClass.invalidStaticGetter, Decl(uniqueSymbolsErrors.ts, 37, 78)) + + static set invalidStaticSetter(arg: symbol()) { return; } +>invalidStaticSetter : Symbol(InvalidClass.invalidStaticSetter, Decl(uniqueSymbolsErrors.ts, 38, 58)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 39, 35)) +} + +// interfaces +interface InvalidInterface { +>InvalidInterface : Symbol(InvalidInterface, Decl(uniqueSymbolsErrors.ts, 40, 1)) + + invalidPropertyType: symbol(); +>invalidPropertyType : Symbol(InvalidInterface.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 43, 28)) + + invalidArgType(arg: symbol()): void; +>invalidArgType : Symbol(InvalidInterface.invalidArgType, Decl(uniqueSymbolsErrors.ts, 44, 34)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 45, 19)) + + invalidRestArgType(...args: symbol()[]): void; +>invalidRestArgType : Symbol(InvalidInterface.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 45, 40)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 46, 23)) + + invalidReturnType(): symbol(); +>invalidReturnType : Symbol(InvalidInterface.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 46, 50)) + + invalidThisType(this: symbol()); +>invalidThisType : Symbol(InvalidInterface.invalidThisType, Decl(uniqueSymbolsErrors.ts, 47, 34)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 48, 20)) + + invalidTypePredicate(n: any): n is symbol() +>invalidTypePredicate : Symbol(InvalidInterface.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 48, 36)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 49, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 49, 25)) + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(InvalidInterface.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 49, 47)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 50, 35)) + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(InvalidInterface.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 50, 63)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 51, 32)) +} + +// type literals +type InvalidTypeLiteral = { +>InvalidTypeLiteral : Symbol(InvalidTypeLiteral, Decl(uniqueSymbolsErrors.ts, 52, 1)) + + invalidPropertyType: symbol(); +>invalidPropertyType : Symbol(invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 55, 27)) + + invalidArgType(arg: symbol()): void; +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 56, 34)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 57, 19)) + + invalidRestArgType(...args: symbol()[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 57, 40)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 58, 23)) + + invalidReturnType(): symbol(); +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 58, 50)) + + invalidThisType(this: symbol()); +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 59, 34)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 60, 20)) + + invalidTypePredicate(n: any): n is symbol() +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 60, 36)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 61, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 61, 25)) + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 61, 47)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 62, 35)) + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 62, 63)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 63, 32)) + +}; + +// type alias +type InvalidAlias = symbol(); +>InvalidAlias : Symbol(InvalidAlias, Decl(uniqueSymbolsErrors.ts, 64, 2)) + +type InvalidAliasTypeParameterConstraint = never; +>InvalidAliasTypeParameterConstraint : Symbol(InvalidAliasTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 67, 29)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 68, 41)) + +type InvalidAliasTypeParameterDefault = never; +>InvalidAliasTypeParameterDefault : Symbol(InvalidAliasTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 68, 69)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 69, 38)) + +// type references +declare const invalidTypeArgument: Promise; +>invalidTypeArgument : Symbol(invalidTypeArgument, Decl(uniqueSymbolsErrors.ts, 72, 13)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +declare const invalidArrayType: symbol()[]; +>invalidArrayType : Symbol(invalidArrayType, Decl(uniqueSymbolsErrors.ts, 73, 13)) + +declare const invalidTupleType: [symbol()]; +>invalidTupleType : Symbol(invalidTupleType, Decl(uniqueSymbolsErrors.ts, 74, 13)) + +// mapped types +declare const invalidMappedType: { [P in string]: symbol() }; +>invalidMappedType : Symbol(invalidMappedType, Decl(uniqueSymbolsErrors.ts, 77, 13)) +>P : Symbol(P, Decl(uniqueSymbolsErrors.ts, 77, 36)) + +// unions/intersection +declare const invalidUnion: symbol() | symbol(); +>invalidUnion : Symbol(invalidUnion, Decl(uniqueSymbolsErrors.ts, 80, 13)) + +declare const invalidIntersection: symbol() | symbol(); +>invalidIntersection : Symbol(invalidIntersection, Decl(uniqueSymbolsErrors.ts, 81, 13)) + + + diff --git a/tests/baselines/reference/uniqueSymbolsErrors.types b/tests/baselines/reference/uniqueSymbolsErrors.types new file mode 100644 index 0000000000000..455dd13c58df0 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.types @@ -0,0 +1,235 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === +// declarations +declare const {}: symbol(); +declare let invalidLetType: symbol(); +>invalidLetType : symbol + +declare var invalidVarType: symbol(); +>invalidVarType : symbol + +// function arguments and return types +declare function invalidArgType(arg: symbol()): void; +>invalidArgType : (arg: symbol) => void +>arg : symbol + +declare function invalidRestArgType(...arg: symbol()[]): void; +>invalidRestArgType : (...arg: symbol[]) => void +>arg : symbol[] + +declare function invalidReturnType(): symbol(); +>invalidReturnType : () => symbol + +declare function invalidThisType(this: symbol()): void; +>invalidThisType : (this: symbol) => void +>this : symbol + +declare function invalidTypePredicate(n: any): n is symbol(); +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + +declare function invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : () => void +>T : T + +declare function invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : () => void +>T : T + +// classes +class InvalidClass { +>InvalidClass : InvalidClass + + constructor(invalidConstructorArgType: symbol()) {} +>invalidConstructorArgType : symbol + + readonly invalidReadonlyPropertyType: symbol(); +>invalidReadonlyPropertyType : symbol + + invalidPropertyType: symbol(); +>invalidPropertyType : symbol + + invalidArgType(arg: symbol()): void { return; } +>invalidArgType : (arg: symbol) => void +>arg : symbol + + invalidRestArgType(...args: symbol()[]): void { return; } +>invalidRestArgType : (...args: symbol[]) => void +>args : symbol[] + + invalidReturnType(): symbol() { return; } +>invalidReturnType : () => symbol + + invalidThisType(this: symbol()): void { return; } +>invalidThisType : (this: symbol) => void +>this : symbol + + invalidTypePredicate(n: any): n is symbol() { return; } +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + invalidTypeParameterConstraint(): void { return; } +>invalidTypeParameterConstraint : () => void +>T : T + + invalidTypeParameterDefault(): void { return; } +>invalidTypeParameterDefault : () => void +>T : T + + get invalidGetter(): symbol() { return; } +>invalidGetter : symbol + + set invalidSetter(arg: symbol()) { return; } +>invalidSetter : symbol +>arg : symbol + + static invalidStaticPropertyType: symbol(); +>invalidStaticPropertyType : symbol + + static invalidStaticArgType(arg: symbol()): void { return; } +>invalidStaticArgType : (arg: symbol) => void +>arg : symbol + + static invalidStaticRestArgType(...args: symbol()[]): void { return; } +>invalidStaticRestArgType : (...args: symbol[]) => void +>args : symbol[] + + static invalidStaticReturnType(): symbol() { return; } +>invalidStaticReturnType : () => symbol + + static invalidStaticThisType(this: symbol()): void { return; } +>invalidStaticThisType : (this: symbol) => void +>this : symbol + + static invalidStaticTypePredicate(n: any): n is symbol() { return; } +>invalidStaticTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + static invalidStaticTypeParameterConstraint(): void { return; } +>invalidStaticTypeParameterConstraint : () => void +>T : T + + static invalidStaticTypeParameterDefault(): void { return; } +>invalidStaticTypeParameterDefault : () => void +>T : T + + static get invalidStaticGetter(): symbol() { return; } +>invalidStaticGetter : symbol + + static set invalidStaticSetter(arg: symbol()) { return; } +>invalidStaticSetter : symbol +>arg : symbol +} + +// interfaces +interface InvalidInterface { +>InvalidInterface : InvalidInterface + + invalidPropertyType: symbol(); +>invalidPropertyType : symbol + + invalidArgType(arg: symbol()): void; +>invalidArgType : (arg: symbol) => void +>arg : symbol + + invalidRestArgType(...args: symbol()[]): void; +>invalidRestArgType : (...args: symbol[]) => void +>args : symbol[] + + invalidReturnType(): symbol(); +>invalidReturnType : () => symbol + + invalidThisType(this: symbol()); +>invalidThisType : (this: symbol) => any +>this : symbol + + invalidTypePredicate(n: any): n is symbol() +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : () => void +>T : T + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : () => void +>T : T +} + +// type literals +type InvalidTypeLiteral = { +>InvalidTypeLiteral : InvalidTypeLiteral + + invalidPropertyType: symbol(); +>invalidPropertyType : symbol + + invalidArgType(arg: symbol()): void; +>invalidArgType : (arg: symbol) => void +>arg : symbol + + invalidRestArgType(...args: symbol()[]): void; +>invalidRestArgType : (...args: symbol[]) => void +>args : symbol[] + + invalidReturnType(): symbol(); +>invalidReturnType : () => symbol + + invalidThisType(this: symbol()); +>invalidThisType : (this: symbol) => any +>this : symbol + + invalidTypePredicate(n: any): n is symbol() +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : () => void +>T : T + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : () => void +>T : T + +}; + +// type alias +type InvalidAlias = symbol(); +>InvalidAlias : symbol + +type InvalidAliasTypeParameterConstraint = never; +>InvalidAliasTypeParameterConstraint : never +>T : T + +type InvalidAliasTypeParameterDefault = never; +>InvalidAliasTypeParameterDefault : never +>T : T + +// type references +declare const invalidTypeArgument: Promise; +>invalidTypeArgument : Promise +>Promise : Promise + +declare const invalidArrayType: symbol()[]; +>invalidArrayType : symbol[] + +declare const invalidTupleType: [symbol()]; +>invalidTupleType : [symbol] + +// mapped types +declare const invalidMappedType: { [P in string]: symbol() }; +>invalidMappedType : { [x: string]: symbol; } +>P : P + +// unions/intersection +declare const invalidUnion: symbol() | symbol(); +>invalidUnion : symbol + +declare const invalidIntersection: symbol() | symbol(); +>invalidIntersection : symbol + + + From 4395f256486d8460ab2301e4e6de968fb952809b Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 3 Oct 2017 13:06:17 -0700 Subject: [PATCH 19/43] PR Feedback and API baselines --- src/compiler/checker.ts | 3 +- .../reference/api/tsserverlibrary.d.ts | 304 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 304 +++++++++--------- 3 files changed, 317 insertions(+), 294 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 206ad674870a6..6f5cc8e0e5bd8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8206,8 +8206,7 @@ namespace ts { switch (symbol.valueDeclaration.kind) { case SyntaxKind.VariableDeclaration: return getNameOfDeclaration(symbol.valueDeclaration).kind === SyntaxKind.Identifier - && symbol.valueDeclaration.parent.kind === SyntaxKind.VariableDeclarationList - && symbol.valueDeclaration.parent.parent.kind === SyntaxKind.VariableStatement + && isVariableDeclarationInVariableStatement(symbol.valueDeclaration) && !!(symbol.valueDeclaration.parent.flags & NodeFlags.Const); case SyntaxKind.PropertySignature: return hasModifier(symbol.valueDeclaration, ModifierFlags.Readonly); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 7adc7539ca608..de9ff05f9c1b6 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -234,125 +234,126 @@ declare namespace ts { IndexedAccessType = 171, MappedType = 172, LiteralType = 173, - ObjectBindingPattern = 174, - ArrayBindingPattern = 175, - BindingElement = 176, - ArrayLiteralExpression = 177, - ObjectLiteralExpression = 178, - PropertyAccessExpression = 179, - ElementAccessExpression = 180, - CallExpression = 181, - NewExpression = 182, - TaggedTemplateExpression = 183, - TypeAssertionExpression = 184, - ParenthesizedExpression = 185, - FunctionExpression = 186, - ArrowFunction = 187, - DeleteExpression = 188, - TypeOfExpression = 189, - VoidExpression = 190, - AwaitExpression = 191, - PrefixUnaryExpression = 192, - PostfixUnaryExpression = 193, - BinaryExpression = 194, - ConditionalExpression = 195, - TemplateExpression = 196, - YieldExpression = 197, - SpreadElement = 198, - ClassExpression = 199, - OmittedExpression = 200, - ExpressionWithTypeArguments = 201, - AsExpression = 202, - NonNullExpression = 203, - MetaProperty = 204, - TemplateSpan = 205, - SemicolonClassElement = 206, - Block = 207, - VariableStatement = 208, - EmptyStatement = 209, - ExpressionStatement = 210, - IfStatement = 211, - DoStatement = 212, - WhileStatement = 213, - ForStatement = 214, - ForInStatement = 215, - ForOfStatement = 216, - ContinueStatement = 217, - BreakStatement = 218, - ReturnStatement = 219, - WithStatement = 220, - SwitchStatement = 221, - LabeledStatement = 222, - ThrowStatement = 223, - TryStatement = 224, - DebuggerStatement = 225, - VariableDeclaration = 226, - VariableDeclarationList = 227, - FunctionDeclaration = 228, - ClassDeclaration = 229, - InterfaceDeclaration = 230, - TypeAliasDeclaration = 231, - EnumDeclaration = 232, - ModuleDeclaration = 233, - ModuleBlock = 234, - CaseBlock = 235, - NamespaceExportDeclaration = 236, - ImportEqualsDeclaration = 237, - ImportDeclaration = 238, - ImportClause = 239, - NamespaceImport = 240, - NamedImports = 241, - ImportSpecifier = 242, - ExportAssignment = 243, - ExportDeclaration = 244, - NamedExports = 245, - ExportSpecifier = 246, - MissingDeclaration = 247, - ExternalModuleReference = 248, - JsxElement = 249, - JsxSelfClosingElement = 250, - JsxOpeningElement = 251, - JsxClosingElement = 252, - JsxAttribute = 253, - JsxAttributes = 254, - JsxSpreadAttribute = 255, - JsxExpression = 256, - CaseClause = 257, - DefaultClause = 258, - HeritageClause = 259, - CatchClause = 260, - PropertyAssignment = 261, - ShorthandPropertyAssignment = 262, - SpreadAssignment = 263, - EnumMember = 264, - SourceFile = 265, - Bundle = 266, - JSDocTypeExpression = 267, - JSDocAllType = 268, - JSDocUnknownType = 269, - JSDocNullableType = 270, - JSDocNonNullableType = 271, - JSDocOptionalType = 272, - JSDocFunctionType = 273, - JSDocVariadicType = 274, - JSDocComment = 275, - JSDocTag = 276, - JSDocAugmentsTag = 277, - JSDocClassTag = 278, - JSDocParameterTag = 279, - JSDocReturnTag = 280, - JSDocTypeTag = 281, - JSDocTemplateTag = 282, - JSDocTypedefTag = 283, - JSDocPropertyTag = 284, - JSDocTypeLiteral = 285, - SyntaxList = 286, - NotEmittedStatement = 287, - PartiallyEmittedExpression = 288, - CommaListExpression = 289, - MergeDeclarationMarker = 290, - EndOfDeclarationMarker = 291, - Count = 292, + ESSymbolType = 174, + ObjectBindingPattern = 175, + ArrayBindingPattern = 176, + BindingElement = 177, + ArrayLiteralExpression = 178, + ObjectLiteralExpression = 179, + PropertyAccessExpression = 180, + ElementAccessExpression = 181, + CallExpression = 182, + NewExpression = 183, + TaggedTemplateExpression = 184, + TypeAssertionExpression = 185, + ParenthesizedExpression = 186, + FunctionExpression = 187, + ArrowFunction = 188, + DeleteExpression = 189, + TypeOfExpression = 190, + VoidExpression = 191, + AwaitExpression = 192, + PrefixUnaryExpression = 193, + PostfixUnaryExpression = 194, + BinaryExpression = 195, + ConditionalExpression = 196, + TemplateExpression = 197, + YieldExpression = 198, + SpreadElement = 199, + ClassExpression = 200, + OmittedExpression = 201, + ExpressionWithTypeArguments = 202, + AsExpression = 203, + NonNullExpression = 204, + MetaProperty = 205, + TemplateSpan = 206, + SemicolonClassElement = 207, + Block = 208, + VariableStatement = 209, + EmptyStatement = 210, + ExpressionStatement = 211, + IfStatement = 212, + DoStatement = 213, + WhileStatement = 214, + ForStatement = 215, + ForInStatement = 216, + ForOfStatement = 217, + ContinueStatement = 218, + BreakStatement = 219, + ReturnStatement = 220, + WithStatement = 221, + SwitchStatement = 222, + LabeledStatement = 223, + ThrowStatement = 224, + TryStatement = 225, + DebuggerStatement = 226, + VariableDeclaration = 227, + VariableDeclarationList = 228, + FunctionDeclaration = 229, + ClassDeclaration = 230, + InterfaceDeclaration = 231, + TypeAliasDeclaration = 232, + EnumDeclaration = 233, + ModuleDeclaration = 234, + ModuleBlock = 235, + CaseBlock = 236, + NamespaceExportDeclaration = 237, + ImportEqualsDeclaration = 238, + ImportDeclaration = 239, + ImportClause = 240, + NamespaceImport = 241, + NamedImports = 242, + ImportSpecifier = 243, + ExportAssignment = 244, + ExportDeclaration = 245, + NamedExports = 246, + ExportSpecifier = 247, + MissingDeclaration = 248, + ExternalModuleReference = 249, + JsxElement = 250, + JsxSelfClosingElement = 251, + JsxOpeningElement = 252, + JsxClosingElement = 253, + JsxAttribute = 254, + JsxAttributes = 255, + JsxSpreadAttribute = 256, + JsxExpression = 257, + CaseClause = 258, + DefaultClause = 259, + HeritageClause = 260, + CatchClause = 261, + PropertyAssignment = 262, + ShorthandPropertyAssignment = 263, + SpreadAssignment = 264, + EnumMember = 265, + SourceFile = 266, + Bundle = 267, + JSDocTypeExpression = 268, + JSDocAllType = 269, + JSDocUnknownType = 270, + JSDocNullableType = 271, + JSDocNonNullableType = 272, + JSDocOptionalType = 273, + JSDocFunctionType = 274, + JSDocVariadicType = 275, + JSDocComment = 276, + JSDocTag = 277, + JSDocAugmentsTag = 278, + JSDocClassTag = 279, + JSDocParameterTag = 280, + JSDocReturnTag = 281, + JSDocTypeTag = 282, + JSDocTemplateTag = 283, + JSDocTypedefTag = 284, + JSDocPropertyTag = 285, + JSDocTypeLiteral = 286, + SyntaxList = 287, + NotEmittedStatement = 288, + PartiallyEmittedExpression = 289, + CommaListExpression = 290, + MergeDeclarationMarker = 291, + EndOfDeclarationMarker = 292, + Count = 293, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -364,7 +365,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 158, - LastTypeNode = 173, + LastTypeNode = 174, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -378,10 +379,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 143, - FirstJSDocNode = 267, - LastJSDocNode = 285, - FirstJSDocTagNode = 276, - LastJSDocTagNode = 285, + FirstJSDocNode = 268, + LastJSDocNode = 286, + FirstJSDocTagNode = 277, + LastJSDocTagNode = 286, } enum NodeFlags { None = 0, @@ -755,6 +756,9 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } + interface ESSymbolTypeNode extends TypeNode { + kind: SyntaxKind.ESSymbolType; + } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } @@ -1772,6 +1776,7 @@ declare namespace ts { IgnoreErrors = 60416, InObjectTypeLiteral = 1048576, InTypeAlias = 8388608, + IsDeclarationOfUniqueESSymbolType = 16777216, } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1871,6 +1876,7 @@ declare namespace ts { ExportStar = 8388608, Optional = 16777216, Transient = 33554432, + Late = 67108864, Enum = 384, Variable = 3, Value = 107455, @@ -1973,32 +1979,34 @@ declare namespace ts { BooleanLiteral = 128, EnumLiteral = 256, ESSymbol = 512, - Void = 1024, - Undefined = 2048, - Null = 4096, - Never = 8192, - TypeParameter = 16384, - Object = 32768, - Union = 65536, - Intersection = 131072, - Index = 262144, - IndexedAccess = 524288, - NonPrimitive = 16777216, - MarkerType = 67108864, - Literal = 224, - Unit = 6368, + UniqueESSymbol = 1024, + Void = 2048, + Undefined = 4096, + Null = 8192, + Never = 16384, + TypeParameter = 32768, + Object = 65536, + Union = 131072, + Intersection = 262144, + Index = 524288, + IndexedAccess = 1048576, + NonPrimitive = 33554432, + MarkerType = 134217728, + Literal = 1248, + Unit = 13536, StringOrNumberLiteral = 96, - PossiblyFalsy = 7406, - StringLike = 262178, + PossiblyFalsy = 14574, + StringLike = 524322, NumberLike = 84, BooleanLike = 136, EnumLike = 272, - UnionOrIntersection = 196608, - StructuredType = 229376, - StructuredOrTypeVariable = 1032192, - TypeVariable = 540672, - Narrowable = 17810175, - NotUnionOrUnit = 16810497, + ESSymbolLike = 1536, + UnionOrIntersection = 393216, + StructuredType = 458752, + StructuredOrTypeVariable = 2064384, + TypeVariable = 1081344, + Narrowable = 35620607, + NotUnionOrUnit = 33620481, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2013,6 +2021,9 @@ declare namespace ts { freshType?: LiteralType; regularType?: LiteralType; } + interface UniqueESSymbolType extends Type { + symbol: Symbol; + } interface StringLiteralType extends LiteralType { value: string; } @@ -3325,6 +3336,7 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; + function createESSymbolTypeNode(): ESSymbolTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d41db2eb413ee..2be759e509ebf 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -234,125 +234,126 @@ declare namespace ts { IndexedAccessType = 171, MappedType = 172, LiteralType = 173, - ObjectBindingPattern = 174, - ArrayBindingPattern = 175, - BindingElement = 176, - ArrayLiteralExpression = 177, - ObjectLiteralExpression = 178, - PropertyAccessExpression = 179, - ElementAccessExpression = 180, - CallExpression = 181, - NewExpression = 182, - TaggedTemplateExpression = 183, - TypeAssertionExpression = 184, - ParenthesizedExpression = 185, - FunctionExpression = 186, - ArrowFunction = 187, - DeleteExpression = 188, - TypeOfExpression = 189, - VoidExpression = 190, - AwaitExpression = 191, - PrefixUnaryExpression = 192, - PostfixUnaryExpression = 193, - BinaryExpression = 194, - ConditionalExpression = 195, - TemplateExpression = 196, - YieldExpression = 197, - SpreadElement = 198, - ClassExpression = 199, - OmittedExpression = 200, - ExpressionWithTypeArguments = 201, - AsExpression = 202, - NonNullExpression = 203, - MetaProperty = 204, - TemplateSpan = 205, - SemicolonClassElement = 206, - Block = 207, - VariableStatement = 208, - EmptyStatement = 209, - ExpressionStatement = 210, - IfStatement = 211, - DoStatement = 212, - WhileStatement = 213, - ForStatement = 214, - ForInStatement = 215, - ForOfStatement = 216, - ContinueStatement = 217, - BreakStatement = 218, - ReturnStatement = 219, - WithStatement = 220, - SwitchStatement = 221, - LabeledStatement = 222, - ThrowStatement = 223, - TryStatement = 224, - DebuggerStatement = 225, - VariableDeclaration = 226, - VariableDeclarationList = 227, - FunctionDeclaration = 228, - ClassDeclaration = 229, - InterfaceDeclaration = 230, - TypeAliasDeclaration = 231, - EnumDeclaration = 232, - ModuleDeclaration = 233, - ModuleBlock = 234, - CaseBlock = 235, - NamespaceExportDeclaration = 236, - ImportEqualsDeclaration = 237, - ImportDeclaration = 238, - ImportClause = 239, - NamespaceImport = 240, - NamedImports = 241, - ImportSpecifier = 242, - ExportAssignment = 243, - ExportDeclaration = 244, - NamedExports = 245, - ExportSpecifier = 246, - MissingDeclaration = 247, - ExternalModuleReference = 248, - JsxElement = 249, - JsxSelfClosingElement = 250, - JsxOpeningElement = 251, - JsxClosingElement = 252, - JsxAttribute = 253, - JsxAttributes = 254, - JsxSpreadAttribute = 255, - JsxExpression = 256, - CaseClause = 257, - DefaultClause = 258, - HeritageClause = 259, - CatchClause = 260, - PropertyAssignment = 261, - ShorthandPropertyAssignment = 262, - SpreadAssignment = 263, - EnumMember = 264, - SourceFile = 265, - Bundle = 266, - JSDocTypeExpression = 267, - JSDocAllType = 268, - JSDocUnknownType = 269, - JSDocNullableType = 270, - JSDocNonNullableType = 271, - JSDocOptionalType = 272, - JSDocFunctionType = 273, - JSDocVariadicType = 274, - JSDocComment = 275, - JSDocTag = 276, - JSDocAugmentsTag = 277, - JSDocClassTag = 278, - JSDocParameterTag = 279, - JSDocReturnTag = 280, - JSDocTypeTag = 281, - JSDocTemplateTag = 282, - JSDocTypedefTag = 283, - JSDocPropertyTag = 284, - JSDocTypeLiteral = 285, - SyntaxList = 286, - NotEmittedStatement = 287, - PartiallyEmittedExpression = 288, - CommaListExpression = 289, - MergeDeclarationMarker = 290, - EndOfDeclarationMarker = 291, - Count = 292, + ESSymbolType = 174, + ObjectBindingPattern = 175, + ArrayBindingPattern = 176, + BindingElement = 177, + ArrayLiteralExpression = 178, + ObjectLiteralExpression = 179, + PropertyAccessExpression = 180, + ElementAccessExpression = 181, + CallExpression = 182, + NewExpression = 183, + TaggedTemplateExpression = 184, + TypeAssertionExpression = 185, + ParenthesizedExpression = 186, + FunctionExpression = 187, + ArrowFunction = 188, + DeleteExpression = 189, + TypeOfExpression = 190, + VoidExpression = 191, + AwaitExpression = 192, + PrefixUnaryExpression = 193, + PostfixUnaryExpression = 194, + BinaryExpression = 195, + ConditionalExpression = 196, + TemplateExpression = 197, + YieldExpression = 198, + SpreadElement = 199, + ClassExpression = 200, + OmittedExpression = 201, + ExpressionWithTypeArguments = 202, + AsExpression = 203, + NonNullExpression = 204, + MetaProperty = 205, + TemplateSpan = 206, + SemicolonClassElement = 207, + Block = 208, + VariableStatement = 209, + EmptyStatement = 210, + ExpressionStatement = 211, + IfStatement = 212, + DoStatement = 213, + WhileStatement = 214, + ForStatement = 215, + ForInStatement = 216, + ForOfStatement = 217, + ContinueStatement = 218, + BreakStatement = 219, + ReturnStatement = 220, + WithStatement = 221, + SwitchStatement = 222, + LabeledStatement = 223, + ThrowStatement = 224, + TryStatement = 225, + DebuggerStatement = 226, + VariableDeclaration = 227, + VariableDeclarationList = 228, + FunctionDeclaration = 229, + ClassDeclaration = 230, + InterfaceDeclaration = 231, + TypeAliasDeclaration = 232, + EnumDeclaration = 233, + ModuleDeclaration = 234, + ModuleBlock = 235, + CaseBlock = 236, + NamespaceExportDeclaration = 237, + ImportEqualsDeclaration = 238, + ImportDeclaration = 239, + ImportClause = 240, + NamespaceImport = 241, + NamedImports = 242, + ImportSpecifier = 243, + ExportAssignment = 244, + ExportDeclaration = 245, + NamedExports = 246, + ExportSpecifier = 247, + MissingDeclaration = 248, + ExternalModuleReference = 249, + JsxElement = 250, + JsxSelfClosingElement = 251, + JsxOpeningElement = 252, + JsxClosingElement = 253, + JsxAttribute = 254, + JsxAttributes = 255, + JsxSpreadAttribute = 256, + JsxExpression = 257, + CaseClause = 258, + DefaultClause = 259, + HeritageClause = 260, + CatchClause = 261, + PropertyAssignment = 262, + ShorthandPropertyAssignment = 263, + SpreadAssignment = 264, + EnumMember = 265, + SourceFile = 266, + Bundle = 267, + JSDocTypeExpression = 268, + JSDocAllType = 269, + JSDocUnknownType = 270, + JSDocNullableType = 271, + JSDocNonNullableType = 272, + JSDocOptionalType = 273, + JSDocFunctionType = 274, + JSDocVariadicType = 275, + JSDocComment = 276, + JSDocTag = 277, + JSDocAugmentsTag = 278, + JSDocClassTag = 279, + JSDocParameterTag = 280, + JSDocReturnTag = 281, + JSDocTypeTag = 282, + JSDocTemplateTag = 283, + JSDocTypedefTag = 284, + JSDocPropertyTag = 285, + JSDocTypeLiteral = 286, + SyntaxList = 287, + NotEmittedStatement = 288, + PartiallyEmittedExpression = 289, + CommaListExpression = 290, + MergeDeclarationMarker = 291, + EndOfDeclarationMarker = 292, + Count = 293, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -364,7 +365,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 158, - LastTypeNode = 173, + LastTypeNode = 174, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -378,10 +379,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 143, - FirstJSDocNode = 267, - LastJSDocNode = 285, - FirstJSDocTagNode = 276, - LastJSDocTagNode = 285, + FirstJSDocNode = 268, + LastJSDocNode = 286, + FirstJSDocTagNode = 277, + LastJSDocTagNode = 286, } enum NodeFlags { None = 0, @@ -755,6 +756,9 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } + interface ESSymbolTypeNode extends TypeNode { + kind: SyntaxKind.ESSymbolType; + } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } @@ -1772,6 +1776,7 @@ declare namespace ts { IgnoreErrors = 60416, InObjectTypeLiteral = 1048576, InTypeAlias = 8388608, + IsDeclarationOfUniqueESSymbolType = 16777216, } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1871,6 +1876,7 @@ declare namespace ts { ExportStar = 8388608, Optional = 16777216, Transient = 33554432, + Late = 67108864, Enum = 384, Variable = 3, Value = 107455, @@ -1973,32 +1979,34 @@ declare namespace ts { BooleanLiteral = 128, EnumLiteral = 256, ESSymbol = 512, - Void = 1024, - Undefined = 2048, - Null = 4096, - Never = 8192, - TypeParameter = 16384, - Object = 32768, - Union = 65536, - Intersection = 131072, - Index = 262144, - IndexedAccess = 524288, - NonPrimitive = 16777216, - MarkerType = 67108864, - Literal = 224, - Unit = 6368, + UniqueESSymbol = 1024, + Void = 2048, + Undefined = 4096, + Null = 8192, + Never = 16384, + TypeParameter = 32768, + Object = 65536, + Union = 131072, + Intersection = 262144, + Index = 524288, + IndexedAccess = 1048576, + NonPrimitive = 33554432, + MarkerType = 134217728, + Literal = 1248, + Unit = 13536, StringOrNumberLiteral = 96, - PossiblyFalsy = 7406, - StringLike = 262178, + PossiblyFalsy = 14574, + StringLike = 524322, NumberLike = 84, BooleanLike = 136, EnumLike = 272, - UnionOrIntersection = 196608, - StructuredType = 229376, - StructuredOrTypeVariable = 1032192, - TypeVariable = 540672, - Narrowable = 17810175, - NotUnionOrUnit = 16810497, + ESSymbolLike = 1536, + UnionOrIntersection = 393216, + StructuredType = 458752, + StructuredOrTypeVariable = 2064384, + TypeVariable = 1081344, + Narrowable = 35620607, + NotUnionOrUnit = 33620481, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2013,6 +2021,9 @@ declare namespace ts { freshType?: LiteralType; regularType?: LiteralType; } + interface UniqueESSymbolType extends Type { + symbol: Symbol; + } interface StringLiteralType extends LiteralType { value: string; } @@ -3272,6 +3283,7 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; + function createESSymbolTypeNode(): ESSymbolTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; From ee23f93275ff9238fadecdafba020e40ad2b3228 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 4 Oct 2017 15:26:57 -0700 Subject: [PATCH 20/43] Switch to 'unique symbol' --- src/compiler/checker.ts | 154 +++--- src/compiler/declarationEmitter.ts | 2 - src/compiler/diagnosticMessages.json | 32 +- src/compiler/emitter.ts | 2 - src/compiler/factory.ts | 14 +- src/compiler/parser.ts | 27 +- src/compiler/scanner.ts | 1 + src/compiler/types.ts | 13 +- .../reference/api/tsserverlibrary.d.ts | 333 ++++++------- tests/baselines/reference/api/typescript.d.ts | 333 ++++++------- ...pturedParametersInInitializers2.errors.txt | 4 +- .../reference/complicatedPrivacy.errors.txt | 4 +- .../computedPropertyNames12_ES5.errors.txt | 36 +- .../computedPropertyNames12_ES6.errors.txt | 36 +- .../computedPropertyNames35_ES5.errors.txt | 4 +- .../computedPropertyNames35_ES6.errors.txt | 4 +- ...opertyNamesDeclarationEmit3_ES5.errors.txt | 4 +- ...opertyNamesDeclarationEmit3_ES6.errors.txt | 4 +- ...opertyNamesDeclarationEmit4_ES5.errors.txt | 4 +- ...opertyNamesDeclarationEmit4_ES6.errors.txt | 4 +- ...tedPropertyNamesOnOverloads_ES5.errors.txt | 8 +- ...tedPropertyNamesOnOverloads_ES6.errors.txt | 8 +- tests/baselines/reference/dynamicNames.js | 2 +- tests/baselines/reference/dynamicNames.types | 52 +- tests/baselines/reference/giant.errors.txt | 32 +- ...SignatureMustHaveTypeAnnotation.errors.txt | 8 +- .../indexSignatureWithInitializer.errors.txt | 8 +- .../indexWithoutParamType2.errors.txt | 4 +- .../parserComputedPropertyName10.errors.txt | 4 +- .../parserComputedPropertyName11.errors.txt | 4 +- .../parserComputedPropertyName13.errors.txt | 4 +- .../parserComputedPropertyName14.errors.txt | 4 +- .../parserComputedPropertyName15.errors.txt | 4 +- .../parserComputedPropertyName18.errors.txt | 4 +- .../parserComputedPropertyName19.errors.txt | 4 +- .../parserComputedPropertyName20.errors.txt | 4 +- .../parserComputedPropertyName21.errors.txt | 4 +- .../parserComputedPropertyName22.errors.txt | 4 +- .../parserComputedPropertyName25.errors.txt | 4 +- .../parserComputedPropertyName28.errors.txt | 8 +- .../parserComputedPropertyName29.errors.txt | 8 +- .../parserComputedPropertyName31.errors.txt | 8 +- .../parserComputedPropertyName32.errors.txt | 4 +- .../parserComputedPropertyName36.errors.txt | 4 +- .../parserComputedPropertyName7.errors.txt | 4 +- .../parserComputedPropertyName8.errors.txt | 4 +- .../parserComputedPropertyName9.errors.txt | 4 +- .../parserES5ComputedPropertyName1.errors.txt | 4 +- ...parserES5ComputedPropertyName10.errors.txt | 4 +- ...parserES5ComputedPropertyName11.errors.txt | 4 +- .../parserES5ComputedPropertyName5.errors.txt | 4 +- .../parserES5ComputedPropertyName7.errors.txt | 4 +- .../parserES5ComputedPropertyName8.errors.txt | 4 +- .../parserES5ComputedPropertyName9.errors.txt | 4 +- .../parserIndexSignature11.errors.txt | 4 +- .../parserIndexSignature4.errors.txt | 4 +- .../parserIndexSignature5.errors.txt | 4 +- .../reference/propertyAssignment.errors.txt | 4 +- .../reference/symbolProperty7.errors.txt | 8 +- tests/baselines/reference/uniqueSymbols.js | 32 +- .../baselines/reference/uniqueSymbols.symbols | 60 +-- tests/baselines/reference/uniqueSymbols.types | 208 ++++---- .../reference/uniqueSymbolsErrors.errors.txt | 454 +++++++++--------- .../reference/uniqueSymbolsErrors.js | 114 ++--- .../reference/uniqueSymbolsErrors.symbols | 204 ++++---- .../reference/uniqueSymbolsErrors.types | 114 ++--- .../types/uniqueSymbol/uniqueSymbols.ts | 14 +- .../types/uniqueSymbol/uniqueSymbolsErrors.ts | 114 ++--- .../fourslash/completionInJSDocFunctionNew.ts | 2 +- .../completionInJSDocFunctionThis.ts | 2 +- 70 files changed, 1291 insertions(+), 1304 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e9ed2d889a91c..2653b822a5f2a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2497,7 +2497,7 @@ namespace ts { return (type).intrinsicName === "true" ? createTrue() : createFalse(); } if (type.flags & TypeFlags.UniqueESSymbol) { - return createESSymbolTypeNode(); + return createTypeOperatorNode(SyntaxKind.UniqueKeyword, createKeywordTypeNode(SyntaxKind.SymbolKeyword)); } if (type.flags & TypeFlags.Void) { return createKeywordTypeNode(SyntaxKind.VoidKeyword); @@ -3313,9 +3313,9 @@ namespace ts { writeAnonymousType(type, nextFlags); } else if (type.flags & TypeFlags.UniqueESSymbol) { + writeKeyword(writer, SyntaxKind.UniqueKeyword); + writeSpace(writer); writeKeyword(writer, SyntaxKind.SymbolKeyword); - writePunctuation(writer, SyntaxKind.OpenParenToken); - writePunctuation(writer, SyntaxKind.CloseParenToken); } else if (type.flags & TypeFlags.StringOrNumberLiteral) { writer.writeStringLiteral(literalTypeToString(type)); @@ -4533,7 +4533,7 @@ namespace ts { reportErrorsFromWidening(declaration, type); } - // always widen a unique 'symbol()' type if the type was created for a different declaration. + // always widen a 'unique symbol' type if the type was created for a different declaration. if (type.flags & TypeFlags.UniqueESSymbol && !declaration.type && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } @@ -5949,7 +5949,9 @@ namespace ts { const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' const templateReadonly = !!type.declaration.readonlyToken; const templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === SyntaxKind.TypeOperator) { + const constraintDeclaration = type.declaration.typeParameter.constraint; + if (constraintDeclaration.kind === SyntaxKind.TypeOperator && + (constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) { // We have a { [P in keyof T]: X } for (const propertySymbol of getPropertiesOfType(modifiersType)) { addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); @@ -6024,7 +6026,8 @@ namespace ts { function getModifiersTypeFromMappedType(type: MappedType) { if (!type.modifiersType) { const constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === SyntaxKind.TypeOperator) { + if (constraintDeclaration.kind === SyntaxKind.TypeOperator && + (constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -7822,7 +7825,21 @@ namespace ts { function getTypeFromTypeOperatorNode(node: TypeOperatorNode) { const links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); + switch (node.operator) { + case SyntaxKind.KeyOfKeyword: + 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; + } + break; + } } return links.resolvedType; } @@ -8226,21 +8243,6 @@ namespace ts { return esSymbolType; } - function getTypeFromESSymbolTypeNode(node: ESSymbolTypeNode): Type { - const links = getNodeLinks(node); - if (!links.resolvedType) { - const parent = skipParentheses(node).parent; - const symbol = getSymbolOfNode(parent); - if (symbol) { - links.resolvedType = getUniqueESSymbolTypeForSymbol(symbol); - } - else { - links.resolvedType = esSymbolType; - } - } - return links.resolvedType; - } - function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { const links = getNodeLinks(node); if (!links.resolvedType) { @@ -8300,8 +8302,6 @@ namespace ts { return getTypeFromThisTypeNode(node as ThisExpression | ThisTypeNode); case SyntaxKind.LiteralType: return getTypeFromLiteralTypeNode(node); - case SyntaxKind.ESSymbolType: - return getTypeFromESSymbolTypeNode(node); case SyntaxKind.TypeReference: return getTypeFromTypeReference(node); case SyntaxKind.TypePredicate: @@ -17313,7 +17313,7 @@ namespace ts { type = checkAwaitedType(type, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - // widen 'symbol()' types when we infer the return type. + // widen 'unique symbol' types when we infer the return type. type = getWidenedTypeOfUniqueESSymbolType(type); } else { @@ -17349,7 +17349,7 @@ namespace ts { // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); - // widen 'symbol()' types when we infer the return type. + // widen 'unique symbol' types when we infer the return type. type = getWidenedTypeOfUniqueESSymbolType(type); if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function @@ -19428,8 +19428,9 @@ namespace ts { checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } - function checkSymbolType(node: ESSymbolTypeNode) { - checkGrammarESSymbolTypeNode(node); + function checkTypeOperator(node: TypeOperatorNode) { + checkGrammarTypeOperatorNode(node); + checkSourceElement(node.type); } function isPrivateWithinAmbient(node: Node): boolean { @@ -23000,8 +23001,9 @@ namespace ts { case SyntaxKind.IntersectionType: return checkUnionOrIntersectionType(node); case SyntaxKind.ParenthesizedType: - case SyntaxKind.TypeOperator: return checkSourceElement((node).type); + case SyntaxKind.TypeOperator: + return checkTypeOperator(node); case SyntaxKind.JSDocAugmentsTag: return checkJSDocAugmentsTag(node as JSDocAugmentsTag); case SyntaxKind.JSDocTypedefTag: @@ -23026,8 +23028,6 @@ namespace ts { return checkIndexedAccessType(node); case SyntaxKind.MappedType: return checkMappedType(node); - case SyntaxKind.ESSymbolType: - return checkSymbolType(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); case SyntaxKind.Block: @@ -25341,54 +25341,60 @@ namespace ts { } } - function checkGrammarESSymbolTypeNode(node: ESSymbolTypeNode) { - let parent = node.parent; - while (parent.kind === SyntaxKind.ParenthesizedType) { - parent = parent.parent; - } + function checkGrammarTypeOperatorNode(node: TypeOperatorNode) { + if (node.operator === SyntaxKind.UniqueKeyword) { + if (node.type.kind !== SyntaxKind.SymbolKeyword) { + return grammarErrorOnNode(node.type, Diagnostics._0_expected, tokenToString(SyntaxKind.SymbolKeyword)); + } - switch (parent.kind) { - case SyntaxKind.VariableDeclaration: - const decl = parent as VariableDeclaration; - if (decl.name.kind !== SyntaxKind.Identifier) { - return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); - } - if (!isVariableDeclarationInVariableStatement(decl)) { - return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); - } - if (!(decl.parent.flags & NodeFlags.Const)) { - return grammarErrorOnNode((parent).name, Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); - } - break; + let parent = node.parent; + while (parent.kind === SyntaxKind.ParenthesizedType) { + parent = parent.parent; + } - case SyntaxKind.PropertyDeclaration: - if (!hasModifier(parent, ModifierFlags.Static) || - !hasModifier(parent, ModifierFlags.Readonly)) { - return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); - } - break; + switch (parent.kind) { + case SyntaxKind.VariableDeclaration: + const decl = parent as VariableDeclaration; + if (decl.name.kind !== SyntaxKind.Identifier) { + return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); + } + if (!isVariableDeclarationInVariableStatement(decl)) { + return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); + } + if (!(decl.parent.flags & NodeFlags.Const)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); + } + break; - case SyntaxKind.PropertySignature: - if (!hasModifier(parent, ModifierFlags.Readonly)) { - return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); - } - break; + case SyntaxKind.PropertyDeclaration: + if (!hasModifier(parent, ModifierFlags.Static) || + !hasModifier(parent, ModifierFlags.Readonly)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); + } + break; - // report specific errors for cases where a `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); + case SyntaxKind.PropertySignature: + if (!hasModifier(parent, ModifierFlags.Readonly)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); + } + break; - // report a general error for any other invalid use site. - default: - return grammarErrorOnNode(node, Diagnostics.Unique_symbol_types_are_not_allowed_here); + // 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/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 3fb1a5d976e13..7928d7ad46a60 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -425,8 +425,6 @@ namespace ts { case SyntaxKind.ThisType: case SyntaxKind.LiteralType: return writeTextOfNode(currentText, type); - case SyntaxKind.ESSymbolType: - return write("symbol()"); case SyntaxKind.ExpressionWithTypeArguments: return emitExpressionWithTypeArguments(type); case SyntaxKind.TypeReference: diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e8a37fcbdea9d..995424e5f997d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -491,23 +491,23 @@ "category": "Error", "code": 1164 }, - "A computed property name in an ambient context must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { + "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1165 }, - "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { + "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1166 }, - "A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { + "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1168 }, - "A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { + "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1169 }, - "A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type.": { + "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1170 }, @@ -907,47 +907,47 @@ "category": "Error", "code": 1328 }, - "Unique 'symbol()' types are not allowed in a union type.": { + "'unique symbol' types are not allowed in a union type.": { "category": "Error", "code": 1329 }, - "Unique 'symbol()' types are not allowed in an intersection type.": { + "'unique symbol' types are not allowed in an intersection type.": { "category": "Error", "code": 1330 }, - "Unique 'symbol()' types are not allowed in an array type.": { + "'unique symbol' types are not allowed in an array type.": { "category": "Error", "code": 1331 }, - "Unique 'symbol()' types are not allowed in a tuple type.": { + "'unique symbol' types are not allowed in a tuple type.": { "category": "Error", "code": 1332 }, - "Unique 'symbol()' types are not allowed in a mapped type.": { + "'unique symbol' types are not allowed in a mapped type.": { "category": "Error", "code": 1333 }, - "A property of an interface or type literal whose type is a unique 'symbol()' type must be 'readonly'.": { + "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'.": { "category": "Error", "code": 1334 }, - "A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'.": { + "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.": { "category": "Error", "code": 1335 }, - "A variable whose type is a unique 'symbol()' type must be 'const'.": { + "A variable whose type is a 'unique symbol' type must be 'const'.": { "category": "Error", "code": 1336 }, - "Unique 'symbol()' types may not be used on a variable declaration with a binding name.": { + "'unique symbol' types may not be used on a variable declaration with a binding name.": { "category": "Error", "code": 1337 }, - "Unique 'symbol()' types are only allowed on variables in a variable statement.": { + "'unique symbol' types are only allowed on variables in a variable statement.": { "category": "Error", "code": 1338 }, - "Unique 'symbol()' types are not allowed here.": { + "'unique symbol' types are not allowed here.": { "category": "Error", "code": 1339 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ba39d99ca10a6..8083b3841c802 100755 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -574,8 +574,6 @@ namespace ts { return emitMappedType(node); case SyntaxKind.LiteralType: return emitLiteralType(node); - case SyntaxKind.ESSymbolType: - return write("symbol()"); // Binding patterns case SyntaxKind.ObjectBindingPattern: diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 926608146c023..7362d56574953 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -730,15 +730,17 @@ namespace ts { return createSynthesizedNode(SyntaxKind.ThisType); } - export function createTypeOperatorNode(type: TypeNode) { + export function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + export function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode; + export function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | TypeNode, type?: TypeNode) { const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode; - node.operator = SyntaxKind.KeyOfKeyword; - node.type = parenthesizeElementTypeMember(type); + node.operator = typeof operatorOrType === "number" ? operatorOrType : SyntaxKind.KeyOfKeyword; + node.type = parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } export function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode) { - return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + return node.type !== type ? updateNode(createTypeOperatorNode(node.operator, type), node) : node; } export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) { @@ -785,10 +787,6 @@ namespace ts { : node; } - export function createESSymbolTypeNode() { - return createSynthesizedNode(SyntaxKind.ESSymbolType); - } - // Binding Patterns export function createObjectBindingPattern(elements: ReadonlyArray) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5aabc4163e092..337dba57de82a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2609,19 +2609,6 @@ namespace ts { return token() === SyntaxKind.DotToken ? undefined : node; } - function parseSymbolType(): TypeNode | undefined { - const fullStart = scanner.getStartPos(); - parseExpected(SyntaxKind.SymbolKeyword); - if (token() === SyntaxKind.DotToken) return undefined; - if (parseOptional(SyntaxKind.OpenParenToken)) { - parseExpected(SyntaxKind.CloseParenToken); - return finishNode(createNode(SyntaxKind.ESSymbolType, fullStart)); - } - else { - return finishNode(createNode(SyntaxKind.SymbolKeyword, fullStart)); - } - } - function parseLiteralTypeNode(negative?: boolean): LiteralTypeNode { const node = createNode(SyntaxKind.LiteralType) as LiteralTypeNode; let unaryMinusExpression: PrefixUnaryExpression; @@ -2655,10 +2642,9 @@ namespace ts { case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.ObjectKeyword: - // If these are followed by a dot, then parse these out as a dotted type reference instead. - return tryParse(parseKeywordAndNoDot) || parseTypeReference(); case SyntaxKind.SymbolKeyword: - return tryParse(parseSymbolType) || parseTypeReference(); + // If these are followed by a dot, then parse these out as a dotted type reference instead. + return tryParse(parseKeywordAndNoDot) || parseTypeReference(); case SyntaxKind.AsteriskToken: return parseJSDocAllType(); case SyntaxKind.QuestionToken: @@ -2709,6 +2695,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.UniqueKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NullKeyword: @@ -2794,7 +2781,7 @@ namespace ts { return finishNode(postfix); } - function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword) { + function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword) { const node = createNode(SyntaxKind.TypeOperator); parseExpected(operator); node.operator = operator; @@ -2803,9 +2790,11 @@ namespace ts { } function parseTypeOperatorOrHigher(): TypeNode { - switch (token()) { + const operator = token(); + switch (operator) { case SyntaxKind.KeyOfKeyword: - return parseTypeOperator(SyntaxKind.KeyOfKeyword); + case SyntaxKind.UniqueKeyword: + return parseTypeOperator(operator); } return parsePostfixTypeOrHigher(); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index b19a14663285d..d7748721ede6f 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -122,6 +122,7 @@ namespace ts { "type": SyntaxKind.TypeKeyword, "typeof": SyntaxKind.TypeOfKeyword, "undefined": SyntaxKind.UndefinedKeyword, + "unique": SyntaxKind.UniqueKeyword, "var": SyntaxKind.VarKeyword, "void": SyntaxKind.VoidKeyword, "while": SyntaxKind.WhileKeyword, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6fa30f547a587..a8e8e79e49397 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -199,6 +199,7 @@ namespace ts { SymbolKeyword, TypeKeyword, UndefinedKeyword, + UniqueKeyword, FromKeyword, GlobalKeyword, OfKeyword, // LastKeyword and LastToken @@ -240,7 +241,6 @@ namespace ts { IndexedAccessType, MappedType, LiteralType, - ESSymbolType, // Binding patterns ObjectBindingPattern, ArrayBindingPattern, @@ -399,7 +399,7 @@ namespace ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypePredicate, - LastTypeNode = ESSymbolType, + LastTypeNode = LiteralType, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = Unknown, @@ -1030,7 +1030,7 @@ namespace ts { export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword; type: TypeNode; } @@ -1053,11 +1053,6 @@ namespace ts { literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - // Represents a unique `symbol()` type - export interface ESSymbolTypeNode extends TypeNode { - kind: SyntaxKind.ESSymbolType; - } - export interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; /* @internal */ textSourceNode?: Identifier | StringLiteral | NumericLiteral; // Allows a StringLiteral to get its text from another node (used by transforms). @@ -3209,7 +3204,7 @@ namespace ts { BooleanLiteral = 1 << 7, EnumLiteral = 1 << 8, // Always combined with StringLiteral, NumberLiteral, or Union ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6 - UniqueESSymbol = 1 << 10, // symbol() + UniqueESSymbol = 1 << 10, // unique symbol Void = 1 << 11, Undefined = 1 << 12, Null = 1 << 13, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 78c067787399f..63f60edb2dc22 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -200,160 +200,161 @@ declare namespace ts { SymbolKeyword = 137, TypeKeyword = 138, UndefinedKeyword = 139, - FromKeyword = 140, - GlobalKeyword = 141, - OfKeyword = 142, - QualifiedName = 143, - ComputedPropertyName = 144, - TypeParameter = 145, - Parameter = 146, - Decorator = 147, - PropertySignature = 148, - PropertyDeclaration = 149, - MethodSignature = 150, - MethodDeclaration = 151, - Constructor = 152, - GetAccessor = 153, - SetAccessor = 154, - CallSignature = 155, - ConstructSignature = 156, - IndexSignature = 157, - TypePredicate = 158, - TypeReference = 159, - FunctionType = 160, - ConstructorType = 161, - TypeQuery = 162, - TypeLiteral = 163, - ArrayType = 164, - TupleType = 165, - UnionType = 166, - IntersectionType = 167, - ParenthesizedType = 168, - ThisType = 169, - TypeOperator = 170, - IndexedAccessType = 171, - MappedType = 172, - LiteralType = 173, - ESSymbolType = 174, - ObjectBindingPattern = 175, - ArrayBindingPattern = 176, - BindingElement = 177, - ArrayLiteralExpression = 178, - ObjectLiteralExpression = 179, - PropertyAccessExpression = 180, - ElementAccessExpression = 181, - CallExpression = 182, - NewExpression = 183, - TaggedTemplateExpression = 184, - TypeAssertionExpression = 185, - ParenthesizedExpression = 186, - FunctionExpression = 187, - ArrowFunction = 188, - DeleteExpression = 189, - TypeOfExpression = 190, - VoidExpression = 191, - AwaitExpression = 192, - PrefixUnaryExpression = 193, - PostfixUnaryExpression = 194, - BinaryExpression = 195, - ConditionalExpression = 196, - TemplateExpression = 197, - YieldExpression = 198, - SpreadElement = 199, - ClassExpression = 200, - OmittedExpression = 201, - ExpressionWithTypeArguments = 202, - AsExpression = 203, - NonNullExpression = 204, - MetaProperty = 205, - TemplateSpan = 206, - SemicolonClassElement = 207, - Block = 208, - VariableStatement = 209, - EmptyStatement = 210, - ExpressionStatement = 211, - IfStatement = 212, - DoStatement = 213, - WhileStatement = 214, - ForStatement = 215, - ForInStatement = 216, - ForOfStatement = 217, - ContinueStatement = 218, - BreakStatement = 219, - ReturnStatement = 220, - WithStatement = 221, - SwitchStatement = 222, - LabeledStatement = 223, - ThrowStatement = 224, - TryStatement = 225, - DebuggerStatement = 226, - VariableDeclaration = 227, - VariableDeclarationList = 228, - FunctionDeclaration = 229, - ClassDeclaration = 230, - InterfaceDeclaration = 231, - TypeAliasDeclaration = 232, - EnumDeclaration = 233, - ModuleDeclaration = 234, - ModuleBlock = 235, - CaseBlock = 236, - NamespaceExportDeclaration = 237, - ImportEqualsDeclaration = 238, - ImportDeclaration = 239, - ImportClause = 240, - NamespaceImport = 241, - NamedImports = 242, - ImportSpecifier = 243, - ExportAssignment = 244, - ExportDeclaration = 245, - NamedExports = 246, - ExportSpecifier = 247, - MissingDeclaration = 248, - ExternalModuleReference = 249, - JsxElement = 250, - JsxSelfClosingElement = 251, - JsxOpeningElement = 252, - JsxClosingElement = 253, - JsxAttribute = 254, - JsxAttributes = 255, - JsxSpreadAttribute = 256, - JsxExpression = 257, - CaseClause = 258, - DefaultClause = 259, - HeritageClause = 260, - CatchClause = 261, - PropertyAssignment = 262, - ShorthandPropertyAssignment = 263, - SpreadAssignment = 264, - EnumMember = 265, - SourceFile = 266, - Bundle = 267, - JSDocTypeExpression = 268, - JSDocAllType = 269, - JSDocUnknownType = 270, - JSDocNullableType = 271, - JSDocNonNullableType = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocComment = 276, - JSDocTag = 277, - JSDocAugmentsTag = 278, - JSDocClassTag = 279, - JSDocParameterTag = 280, - JSDocReturnTag = 281, - JSDocTypeTag = 282, - JSDocTemplateTag = 283, - JSDocTypedefTag = 284, - JSDocPropertyTag = 285, - JSDocTypeLiteral = 286, - SyntaxList = 287, - NotEmittedStatement = 288, - PartiallyEmittedExpression = 289, - CommaListExpression = 290, - MergeDeclarationMarker = 291, - EndOfDeclarationMarker = 292, - Count = 293, + UniqueKeyword = 140, + FromKeyword = 141, + GlobalKeyword = 142, + OfKeyword = 143, + QualifiedName = 144, + ComputedPropertyName = 145, + TypeParameter = 146, + Parameter = 147, + Decorator = 148, + PropertySignature = 149, + PropertyDeclaration = 150, + MethodSignature = 151, + MethodDeclaration = 152, + Constructor = 153, + GetAccessor = 154, + SetAccessor = 155, + CallSignature = 156, + ConstructSignature = 157, + IndexSignature = 158, + TypePredicate = 159, + TypeReference = 160, + FunctionType = 161, + ConstructorType = 162, + TypeQuery = 163, + TypeLiteral = 164, + ArrayType = 165, + TupleType = 166, + UnionType = 167, + IntersectionType = 168, + ParenthesizedType = 169, + ThisType = 170, + TypeOperator = 171, + IndexedAccessType = 172, + MappedType = 173, + LiteralType = 174, + UniqueESSymbolType = 175, + ObjectBindingPattern = 176, + ArrayBindingPattern = 177, + BindingElement = 178, + ArrayLiteralExpression = 179, + ObjectLiteralExpression = 180, + PropertyAccessExpression = 181, + ElementAccessExpression = 182, + CallExpression = 183, + NewExpression = 184, + TaggedTemplateExpression = 185, + TypeAssertionExpression = 186, + ParenthesizedExpression = 187, + FunctionExpression = 188, + ArrowFunction = 189, + DeleteExpression = 190, + TypeOfExpression = 191, + VoidExpression = 192, + AwaitExpression = 193, + PrefixUnaryExpression = 194, + PostfixUnaryExpression = 195, + BinaryExpression = 196, + ConditionalExpression = 197, + TemplateExpression = 198, + YieldExpression = 199, + SpreadElement = 200, + ClassExpression = 201, + OmittedExpression = 202, + ExpressionWithTypeArguments = 203, + AsExpression = 204, + NonNullExpression = 205, + MetaProperty = 206, + TemplateSpan = 207, + SemicolonClassElement = 208, + Block = 209, + VariableStatement = 210, + EmptyStatement = 211, + ExpressionStatement = 212, + IfStatement = 213, + DoStatement = 214, + WhileStatement = 215, + ForStatement = 216, + ForInStatement = 217, + ForOfStatement = 218, + ContinueStatement = 219, + BreakStatement = 220, + ReturnStatement = 221, + WithStatement = 222, + SwitchStatement = 223, + LabeledStatement = 224, + ThrowStatement = 225, + TryStatement = 226, + DebuggerStatement = 227, + VariableDeclaration = 228, + VariableDeclarationList = 229, + FunctionDeclaration = 230, + ClassDeclaration = 231, + InterfaceDeclaration = 232, + TypeAliasDeclaration = 233, + EnumDeclaration = 234, + ModuleDeclaration = 235, + ModuleBlock = 236, + CaseBlock = 237, + NamespaceExportDeclaration = 238, + ImportEqualsDeclaration = 239, + ImportDeclaration = 240, + ImportClause = 241, + NamespaceImport = 242, + NamedImports = 243, + ImportSpecifier = 244, + ExportAssignment = 245, + ExportDeclaration = 246, + NamedExports = 247, + ExportSpecifier = 248, + MissingDeclaration = 249, + ExternalModuleReference = 250, + JsxElement = 251, + JsxSelfClosingElement = 252, + JsxOpeningElement = 253, + JsxClosingElement = 254, + JsxAttribute = 255, + JsxAttributes = 256, + JsxSpreadAttribute = 257, + JsxExpression = 258, + CaseClause = 259, + DefaultClause = 260, + HeritageClause = 261, + CatchClause = 262, + PropertyAssignment = 263, + ShorthandPropertyAssignment = 264, + SpreadAssignment = 265, + EnumMember = 266, + SourceFile = 267, + Bundle = 268, + JSDocTypeExpression = 269, + JSDocAllType = 270, + JSDocUnknownType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocComment = 277, + JSDocTag = 278, + JSDocAugmentsTag = 279, + JSDocClassTag = 280, + JSDocParameterTag = 281, + JSDocReturnTag = 282, + JSDocTypeTag = 283, + JSDocTemplateTag = 284, + JSDocTypedefTag = 285, + JSDocPropertyTag = 286, + JSDocTypeLiteral = 287, + SyntaxList = 288, + NotEmittedStatement = 289, + PartiallyEmittedExpression = 290, + CommaListExpression = 291, + MergeDeclarationMarker = 292, + EndOfDeclarationMarker = 293, + Count = 294, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -361,15 +362,15 @@ declare namespace ts { FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, - LastKeyword = 142, + LastKeyword = 143, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, - FirstTypeNode = 158, - LastTypeNode = 174, + FirstTypeNode = 159, + LastTypeNode = 175, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, - LastToken = 142, + LastToken = 143, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -378,11 +379,11 @@ declare namespace ts { LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, - FirstNode = 143, - FirstJSDocNode = 268, - LastJSDocNode = 286, - FirstJSDocTagNode = 277, - LastJSDocTagNode = 286, + FirstNode = 144, + FirstJSDocNode = 269, + LastJSDocNode = 287, + FirstJSDocTagNode = 278, + LastJSDocTagNode = 287, } enum NodeFlags { None = 0, @@ -756,8 +757,8 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface ESSymbolTypeNode extends TypeNode { - kind: SyntaxKind.ESSymbolType; + interface UniqueESSymbolTypeNode extends TypeNode { + kind: SyntaxKind.UniqueESSymbolType; } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; @@ -3336,7 +3337,7 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createESSymbolTypeNode(): ESSymbolTypeNode; + function createUniqueESSymbolTypeNode(): UniqueESSymbolTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2be759e509ebf..6f88bf241eea2 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -200,160 +200,161 @@ declare namespace ts { SymbolKeyword = 137, TypeKeyword = 138, UndefinedKeyword = 139, - FromKeyword = 140, - GlobalKeyword = 141, - OfKeyword = 142, - QualifiedName = 143, - ComputedPropertyName = 144, - TypeParameter = 145, - Parameter = 146, - Decorator = 147, - PropertySignature = 148, - PropertyDeclaration = 149, - MethodSignature = 150, - MethodDeclaration = 151, - Constructor = 152, - GetAccessor = 153, - SetAccessor = 154, - CallSignature = 155, - ConstructSignature = 156, - IndexSignature = 157, - TypePredicate = 158, - TypeReference = 159, - FunctionType = 160, - ConstructorType = 161, - TypeQuery = 162, - TypeLiteral = 163, - ArrayType = 164, - TupleType = 165, - UnionType = 166, - IntersectionType = 167, - ParenthesizedType = 168, - ThisType = 169, - TypeOperator = 170, - IndexedAccessType = 171, - MappedType = 172, - LiteralType = 173, - ESSymbolType = 174, - ObjectBindingPattern = 175, - ArrayBindingPattern = 176, - BindingElement = 177, - ArrayLiteralExpression = 178, - ObjectLiteralExpression = 179, - PropertyAccessExpression = 180, - ElementAccessExpression = 181, - CallExpression = 182, - NewExpression = 183, - TaggedTemplateExpression = 184, - TypeAssertionExpression = 185, - ParenthesizedExpression = 186, - FunctionExpression = 187, - ArrowFunction = 188, - DeleteExpression = 189, - TypeOfExpression = 190, - VoidExpression = 191, - AwaitExpression = 192, - PrefixUnaryExpression = 193, - PostfixUnaryExpression = 194, - BinaryExpression = 195, - ConditionalExpression = 196, - TemplateExpression = 197, - YieldExpression = 198, - SpreadElement = 199, - ClassExpression = 200, - OmittedExpression = 201, - ExpressionWithTypeArguments = 202, - AsExpression = 203, - NonNullExpression = 204, - MetaProperty = 205, - TemplateSpan = 206, - SemicolonClassElement = 207, - Block = 208, - VariableStatement = 209, - EmptyStatement = 210, - ExpressionStatement = 211, - IfStatement = 212, - DoStatement = 213, - WhileStatement = 214, - ForStatement = 215, - ForInStatement = 216, - ForOfStatement = 217, - ContinueStatement = 218, - BreakStatement = 219, - ReturnStatement = 220, - WithStatement = 221, - SwitchStatement = 222, - LabeledStatement = 223, - ThrowStatement = 224, - TryStatement = 225, - DebuggerStatement = 226, - VariableDeclaration = 227, - VariableDeclarationList = 228, - FunctionDeclaration = 229, - ClassDeclaration = 230, - InterfaceDeclaration = 231, - TypeAliasDeclaration = 232, - EnumDeclaration = 233, - ModuleDeclaration = 234, - ModuleBlock = 235, - CaseBlock = 236, - NamespaceExportDeclaration = 237, - ImportEqualsDeclaration = 238, - ImportDeclaration = 239, - ImportClause = 240, - NamespaceImport = 241, - NamedImports = 242, - ImportSpecifier = 243, - ExportAssignment = 244, - ExportDeclaration = 245, - NamedExports = 246, - ExportSpecifier = 247, - MissingDeclaration = 248, - ExternalModuleReference = 249, - JsxElement = 250, - JsxSelfClosingElement = 251, - JsxOpeningElement = 252, - JsxClosingElement = 253, - JsxAttribute = 254, - JsxAttributes = 255, - JsxSpreadAttribute = 256, - JsxExpression = 257, - CaseClause = 258, - DefaultClause = 259, - HeritageClause = 260, - CatchClause = 261, - PropertyAssignment = 262, - ShorthandPropertyAssignment = 263, - SpreadAssignment = 264, - EnumMember = 265, - SourceFile = 266, - Bundle = 267, - JSDocTypeExpression = 268, - JSDocAllType = 269, - JSDocUnknownType = 270, - JSDocNullableType = 271, - JSDocNonNullableType = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocComment = 276, - JSDocTag = 277, - JSDocAugmentsTag = 278, - JSDocClassTag = 279, - JSDocParameterTag = 280, - JSDocReturnTag = 281, - JSDocTypeTag = 282, - JSDocTemplateTag = 283, - JSDocTypedefTag = 284, - JSDocPropertyTag = 285, - JSDocTypeLiteral = 286, - SyntaxList = 287, - NotEmittedStatement = 288, - PartiallyEmittedExpression = 289, - CommaListExpression = 290, - MergeDeclarationMarker = 291, - EndOfDeclarationMarker = 292, - Count = 293, + UniqueKeyword = 140, + FromKeyword = 141, + GlobalKeyword = 142, + OfKeyword = 143, + QualifiedName = 144, + ComputedPropertyName = 145, + TypeParameter = 146, + Parameter = 147, + Decorator = 148, + PropertySignature = 149, + PropertyDeclaration = 150, + MethodSignature = 151, + MethodDeclaration = 152, + Constructor = 153, + GetAccessor = 154, + SetAccessor = 155, + CallSignature = 156, + ConstructSignature = 157, + IndexSignature = 158, + TypePredicate = 159, + TypeReference = 160, + FunctionType = 161, + ConstructorType = 162, + TypeQuery = 163, + TypeLiteral = 164, + ArrayType = 165, + TupleType = 166, + UnionType = 167, + IntersectionType = 168, + ParenthesizedType = 169, + ThisType = 170, + TypeOperator = 171, + IndexedAccessType = 172, + MappedType = 173, + LiteralType = 174, + UniqueESSymbolType = 175, + ObjectBindingPattern = 176, + ArrayBindingPattern = 177, + BindingElement = 178, + ArrayLiteralExpression = 179, + ObjectLiteralExpression = 180, + PropertyAccessExpression = 181, + ElementAccessExpression = 182, + CallExpression = 183, + NewExpression = 184, + TaggedTemplateExpression = 185, + TypeAssertionExpression = 186, + ParenthesizedExpression = 187, + FunctionExpression = 188, + ArrowFunction = 189, + DeleteExpression = 190, + TypeOfExpression = 191, + VoidExpression = 192, + AwaitExpression = 193, + PrefixUnaryExpression = 194, + PostfixUnaryExpression = 195, + BinaryExpression = 196, + ConditionalExpression = 197, + TemplateExpression = 198, + YieldExpression = 199, + SpreadElement = 200, + ClassExpression = 201, + OmittedExpression = 202, + ExpressionWithTypeArguments = 203, + AsExpression = 204, + NonNullExpression = 205, + MetaProperty = 206, + TemplateSpan = 207, + SemicolonClassElement = 208, + Block = 209, + VariableStatement = 210, + EmptyStatement = 211, + ExpressionStatement = 212, + IfStatement = 213, + DoStatement = 214, + WhileStatement = 215, + ForStatement = 216, + ForInStatement = 217, + ForOfStatement = 218, + ContinueStatement = 219, + BreakStatement = 220, + ReturnStatement = 221, + WithStatement = 222, + SwitchStatement = 223, + LabeledStatement = 224, + ThrowStatement = 225, + TryStatement = 226, + DebuggerStatement = 227, + VariableDeclaration = 228, + VariableDeclarationList = 229, + FunctionDeclaration = 230, + ClassDeclaration = 231, + InterfaceDeclaration = 232, + TypeAliasDeclaration = 233, + EnumDeclaration = 234, + ModuleDeclaration = 235, + ModuleBlock = 236, + CaseBlock = 237, + NamespaceExportDeclaration = 238, + ImportEqualsDeclaration = 239, + ImportDeclaration = 240, + ImportClause = 241, + NamespaceImport = 242, + NamedImports = 243, + ImportSpecifier = 244, + ExportAssignment = 245, + ExportDeclaration = 246, + NamedExports = 247, + ExportSpecifier = 248, + MissingDeclaration = 249, + ExternalModuleReference = 250, + JsxElement = 251, + JsxSelfClosingElement = 252, + JsxOpeningElement = 253, + JsxClosingElement = 254, + JsxAttribute = 255, + JsxAttributes = 256, + JsxSpreadAttribute = 257, + JsxExpression = 258, + CaseClause = 259, + DefaultClause = 260, + HeritageClause = 261, + CatchClause = 262, + PropertyAssignment = 263, + ShorthandPropertyAssignment = 264, + SpreadAssignment = 265, + EnumMember = 266, + SourceFile = 267, + Bundle = 268, + JSDocTypeExpression = 269, + JSDocAllType = 270, + JSDocUnknownType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocComment = 277, + JSDocTag = 278, + JSDocAugmentsTag = 279, + JSDocClassTag = 280, + JSDocParameterTag = 281, + JSDocReturnTag = 282, + JSDocTypeTag = 283, + JSDocTemplateTag = 284, + JSDocTypedefTag = 285, + JSDocPropertyTag = 286, + JSDocTypeLiteral = 287, + SyntaxList = 288, + NotEmittedStatement = 289, + PartiallyEmittedExpression = 290, + CommaListExpression = 291, + MergeDeclarationMarker = 292, + EndOfDeclarationMarker = 293, + Count = 294, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -361,15 +362,15 @@ declare namespace ts { FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, - LastKeyword = 142, + LastKeyword = 143, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, - FirstTypeNode = 158, - LastTypeNode = 174, + FirstTypeNode = 159, + LastTypeNode = 175, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, - LastToken = 142, + LastToken = 143, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -378,11 +379,11 @@ declare namespace ts { LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, - FirstNode = 143, - FirstJSDocNode = 268, - LastJSDocNode = 286, - FirstJSDocTagNode = 277, - LastJSDocTagNode = 286, + FirstNode = 144, + FirstJSDocNode = 269, + LastJSDocNode = 287, + FirstJSDocTagNode = 278, + LastJSDocTagNode = 287, } enum NodeFlags { None = 0, @@ -756,8 +757,8 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface ESSymbolTypeNode extends TypeNode { - kind: SyntaxKind.ESSymbolType; + interface UniqueESSymbolTypeNode extends TypeNode { + kind: SyntaxKind.UniqueESSymbolType; } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; @@ -3283,7 +3284,7 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createESSymbolTypeNode(): ESSymbolTypeNode; + function createUniqueESSymbolTypeNode(): UniqueESSymbolTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; diff --git a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt index 0cf6c7f07c1e7..70435b77cee84 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt +++ b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(1,36): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. -tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/compiler/capturedParametersInInitializers2.ts (2 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A } function foo2(y = class {[x] = x}, x = 1) { ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/complicatedPrivacy.errors.txt b/tests/baselines/reference/complicatedPrivacy.errors.txt index 2848a11b2a47a..750beb1994d3d 100644 --- a/tests/baselines/reference/complicatedPrivacy.errors.txt +++ b/tests/baselines/reference/complicatedPrivacy.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/complicatedPrivacy.ts(11,24): error TS1054: A 'get' accessor cannot have parameters. -tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/complicatedPrivacy.ts(35,6): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo5' has no exported member 'i6'. @@ -43,7 +43,7 @@ tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo { [number]: C1; // Used to be indexer, now it is a computed property ~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~~~~~ !!! error TS2693: 'number' only refers to a type, but is being used as a value here. }) { diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt index bee9a01bcd4e7..309b734dfeaf7 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts (9 errors) ==== @@ -16,31 +16,31 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15 class C { [s]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [n] = n; ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [s + s]: string; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [s + n] = 2; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [+s]: typeof s; ~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [""]: number; [0]: number; [a]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [true]: number; ~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [`hello bye`] = 0; ~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [`hello ${a} bye`] = 0 ~~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt index a81279994c2dc..13920995eaa9a 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts (9 errors) ==== @@ -16,31 +16,31 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15 class C { [s]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [n] = n; ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [s + s]: string; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [s + n] = 2; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [+s]: typeof s; ~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [""]: number; [0]: number; [a]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [true]: number; ~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [`hello bye`] = 0; ~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [`hello ${a} bye`] = 0 ~~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt index 730594d0df99b..47ad09c51e3de 100644 --- a/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,10): error TS2467: A computed property name cannot reference a type parameter from its containing type. @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4, bar(): string; [foo()](): void; ~~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2467: A computed property name cannot reference a type parameter from its containing type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt index 11e9b35eeb6fb..8a0be33325c9c 100644 --- a/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,10): error TS2467: A computed property name cannot reference a type parameter from its containing type. @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4, bar(): string; [foo()](): void; ~~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2467: A computed property name cannot reference a type parameter from its containing type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt index 888f29c4dde6c..8ac89ebdb1976 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts (1 errors) ==== interface I { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt index 70b2a3e2e16df..79b0971d0b7b4 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts (1 errors) ==== interface I { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt index b9fad3157a973..be1543e81eb41 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts (1 errors) ==== var v: { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt index 94b904274ec1c..51daaef725f1b 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts (1 errors) ==== var v: { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt index cf6c9801074a3..cdd5577f01100 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts (2 errors) ==== @@ -8,9 +8,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ class C { [methodName](v: string); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](v?: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt index 656a1d2b17e61..3f31d4088106c 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts (2 errors) ==== @@ -8,9 +8,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ class C { [methodName](v: string); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](v?: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index 979ed0c1beb41..869f7282639ec 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -189,7 +189,7 @@ exports.o2 = exports.o1; //// [module.d.ts] export declare const c0 = "a"; export declare const c1 = 1; -export declare const s0: symbol(); +export declare const s0: unique symbol; export interface T0 { [c0]: number; [c1]: string; diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 98d5617093f3b..07d4673697863 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -8,8 +8,8 @@ export const c1 = 1; >1 : 1 export const s0 = Symbol(); ->s0 : symbol() ->Symbol() : symbol() +>s0 : unique symbol +>Symbol() : unique symbol >Symbol : SymbolConstructor export interface T0 { @@ -22,7 +22,7 @@ export interface T0 { >c1 : 1 [s0]: boolean; ->s0 : symbol() +>s0 : unique symbol } export declare class T1 implements T2 { >T1 : T1 @@ -35,7 +35,7 @@ export declare class T1 implements T2 { >c1 : 1 [s0]: boolean; ->s0 : symbol() +>s0 : unique symbol } export declare class T2 extends T1 { >T2 : T2 @@ -51,7 +51,7 @@ export declare type T3 = { >c1 : 1 [s0]: boolean; ->s0 : symbol() +>s0 : unique symbol }; @@ -59,7 +59,7 @@ export declare type T3 = { import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; >c0 : "a" >c1 : 1 ->s0 : symbol() +>s0 : unique symbol >T0 : any >T1 : typeof T1 >T2 : typeof T2 @@ -80,9 +80,9 @@ namespace N { >1 : 1 export const s1: typeof s0 = s0; ->s1 : symbol() ->s0 : symbol() ->s0 : symbol() +>s1 : unique symbol +>s0 : unique symbol +>s0 : unique symbol export interface T4 { >T4 : T4 @@ -98,9 +98,9 @@ namespace N { >c3 : 1 [N.s1]: boolean; ->N.s1 : symbol() +>N.s1 : unique symbol >N : typeof N ->s1 : symbol() +>s1 : unique symbol } export declare class T5 implements T4 { >T5 : T5 @@ -117,9 +117,9 @@ namespace N { >c3 : 1 [N.s1]: boolean; ->N.s1 : symbol() +>N.s1 : unique symbol >N : typeof N ->s1 : symbol() +>s1 : unique symbol } export declare class T6 extends T5 { >T6 : T6 @@ -139,9 +139,9 @@ namespace N { >c3 : 1 [N.s1]: boolean; ->N.s1 : symbol() +>N.s1 : unique symbol >N : typeof N ->s1 : symbol() +>s1 : unique symbol }; } @@ -155,9 +155,9 @@ export const c5 = 1; >1 : 1 export const s2: typeof s0 = s0; ->s2 : symbol() ->s0 : symbol() ->s0 : symbol() +>s2 : unique symbol +>s0 : unique symbol +>s0 : unique symbol interface T8 { >T8 : T8 @@ -169,7 +169,7 @@ interface T8 { >c5 : 1 [s2]: boolean; ->s2 : symbol() +>s2 : unique symbol } declare class T9 implements T8 { >T9 : T9 @@ -182,7 +182,7 @@ declare class T9 implements T8 { >c5 : 1 [s2]: boolean; ->s2 : symbol() +>s2 : unique symbol } declare class T10 extends T9 { >T10 : T10 @@ -198,7 +198,7 @@ declare type T11 = { >c5 : 1 [s2]: boolean; ->s2 : symbol() +>s2 : unique symbol }; @@ -210,7 +210,7 @@ interface T12 { 1: string; [s2]: boolean; ->s2 : symbol() +>s2 : unique symbol } declare class T13 implements T2 { >T13 : T13 @@ -221,7 +221,7 @@ declare class T13 implements T2 { 1: string; [s2]: boolean; ->s2 : symbol() +>s2 : unique symbol } declare class T14 extends T13 { >T14 : T14 @@ -235,7 +235,7 @@ declare type T15 = { 1: string; [s2]: boolean; ->s2 : symbol() +>s2 : unique symbol }; @@ -473,7 +473,7 @@ export const o1 = { >"a" : "a" [s2]: true ->s2 : symbol() +>s2 : unique symbol >true : true }; @@ -495,7 +495,7 @@ export const o1_s2 = o1[s2]; >o1_s2 : boolean >o1[s2] : boolean >o1 : { [c4]: number; [c5]: string; [s2]: boolean; } ->s2 : symbol() +>s2 : unique symbol export const o2: T0 = o1; >o2 : T0 diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index d465bd8a958ea..eb899ff132e6d 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/giant.ts(33,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(34,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(35,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(35,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(60,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(60,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(60,6): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(61,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(62,6): error TS1096: An index signature must have exactly one parameter. @@ -39,7 +39,7 @@ tests/cases/compiler/giant.ts(97,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(98,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(99,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(99,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(124,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(124,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(124,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(125,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(126,10): error TS1096: An index signature must have exactly one parameter. @@ -63,7 +63,7 @@ tests/cases/compiler/giant.ts(176,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(177,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(178,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(178,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(203,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(203,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(203,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(204,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(205,10): error TS1096: An index signature must have exactly one parameter. @@ -119,7 +119,7 @@ tests/cases/compiler/giant.ts(291,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(292,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(293,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(293,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(318,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(318,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(318,6): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(319,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(320,6): error TS1096: An index signature must have exactly one parameter. @@ -142,7 +142,7 @@ tests/cases/compiler/giant.ts(355,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(356,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(357,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(357,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(382,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(382,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(382,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(383,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(384,10): error TS1096: An index signature must have exactly one parameter. @@ -166,7 +166,7 @@ tests/cases/compiler/giant.ts(434,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(435,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(436,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(436,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(461,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(461,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(461,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(462,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(463,10): error TS1096: An index signature must have exactly one parameter. @@ -238,7 +238,7 @@ tests/cases/compiler/giant.ts(555,21): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(557,24): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(560,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(562,21): error TS1183: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(586,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(586,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(586,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(587,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(588,10): error TS1096: An index signature must have exactly one parameter. @@ -255,7 +255,7 @@ tests/cases/compiler/giant.ts(620,26): error TS1183: An implementation cannot be tests/cases/compiler/giant.ts(622,24): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(625,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(627,21): error TS1183: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(652,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/giant.ts(652,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(652,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(653,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(654,10): error TS1096: An index signature must have exactly one parameter. @@ -363,7 +363,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -473,7 +473,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -600,7 +600,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -827,7 +827,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -937,7 +937,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1064,7 +1064,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1333,7 +1333,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1433,7 +1433,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index 7c5502967e173..bc18e0fb08486 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,6): error TS2304: Cannot find name 'x'. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(4,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,6): error TS2304: Cannot find name 'x'. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021: An index signature must have a type annotation. @@ -11,7 +11,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021 // Used to be indexer, now it is a computed property [x]: string; ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. [x: string]; @@ -23,7 +23,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021 // Used to be indexer, now it is a computed property [x]: string ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. diff --git a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt index e24d2163ad981..a2e78df0ed83f 100644 --- a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt +++ b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/indexSignatureWithInitializer.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/indexSignatureWithInitializer.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureWithInitializer.ts(3,6): error TS2304: Cannot find name 'x'. -tests/cases/compiler/indexSignatureWithInitializer.ts(7,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/indexSignatureWithInitializer.ts(7,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot find name 'x'. @@ -9,7 +9,7 @@ tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot interface I { [x = '']: string; ~~~~~~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. } @@ -17,7 +17,7 @@ tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot class C { [x = 0]: string ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. } \ No newline at end of file diff --git a/tests/baselines/reference/indexWithoutParamType2.errors.txt b/tests/baselines/reference/indexWithoutParamType2.errors.txt index 64c4e43db84fb..5463980d66d68 100644 --- a/tests/baselines/reference/indexWithoutParamType2.errors.txt +++ b/tests/baselines/reference/indexWithoutParamType2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/indexWithoutParamType2.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/indexWithoutParamType2.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexWithoutParamType2.ts(3,6): error TS2304: Cannot find name 'x'. @@ -7,7 +7,7 @@ tests/cases/compiler/indexWithoutParamType2.ts(3,6): error TS2304: Cannot find n // Used to be indexer, now it is a computed property [x]: string ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName10.errors.txt b/tests/baselines/reference/parserComputedPropertyName10.errors.txt index 18c612291a463..c8ca89f400214 100644 --- a/tests/baselines/reference/parserComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e] = 1 ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index c9ff2faf43eb4..abbb667723b7e 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e](); ~~~ -!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName13.errors.txt b/tests/baselines/reference/parserComputedPropertyName13.errors.txt index ba15de5feafdc..65fa109c34878 100644 --- a/tests/baselines/reference/parserComputedPropertyName13.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts (2 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt index 082f9f2dce4f4..668e1542c6250 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (2 errors) ==== var v: { [e](): number }; ~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName15.errors.txt b/tests/baselines/reference/parserComputedPropertyName15.errors.txt index 7d9c7e8e5de1d..2311fcafc348c 100644 --- a/tests/baselines/reference/parserComputedPropertyName15.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,32): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts (2 errors) ==== var v: { [e: number]: string; [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt index 715bb5dd437f7..8730dd6077468 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (2 errors) ==== var v: { [e]?(): number }; ~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName19.errors.txt b/tests/baselines/reference/parserComputedPropertyName19.errors.txt index 626dbe78c5aec..d7b2e25377d20 100644 --- a/tests/baselines/reference/parserComputedPropertyName19.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts (2 errors) ==== var v: { [e]? }; ~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt index 67bb57c519cd3..972457d8fbb88 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP interface I { [e](): number ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName21.errors.txt b/tests/baselines/reference/parserComputedPropertyName21.errors.txt index a67bf8e779937..52c26498999fa 100644 --- a/tests/baselines/reference/parserComputedPropertyName21.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP interface I { [e]: number ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName22.errors.txt b/tests/baselines/reference/parserComputedPropertyName22.errors.txt index 44add8085809e..866468aa53d93 100644 --- a/tests/baselines/reference/parserComputedPropertyName22.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName22.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP declare class C { [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName25.errors.txt b/tests/baselines/reference/parserComputedPropertyName25.errors.txt index c88eb3aea1131..d6bbb52ff7ce9 100644 --- a/tests/baselines/reference/parserComputedPropertyName25.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName25.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // No ASI [e] = 0 ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. [e2] = 1 diff --git a/tests/baselines/reference/parserComputedPropertyName28.errors.txt b/tests/baselines/reference/parserComputedPropertyName28.errors.txt index 3aa13e0dfdb16..df9202df567db 100644 --- a/tests/baselines/reference/parserComputedPropertyName28.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName28.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,6): error TS2304: Cannot find name 'e'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,6): error TS2304: Cannot find name 'e2'. @@ -8,12 +8,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e]: number = 0; ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName29.errors.txt b/tests/baselines/reference/parserComputedPropertyName29.errors.txt index bbb27f8f7bf17..53800078b5eb7 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,11): error TS2304: Cannot find name 'id'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -10,14 +10,14 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e] = id++ ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. ~~ !!! error TS2304: Cannot find name 'id'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName31.errors.txt b/tests/baselines/reference/parserComputedPropertyName31.errors.txt index aaa8869696554..57591fd4d946f 100644 --- a/tests/baselines/reference/parserComputedPropertyName31.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName31.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,6): error TS2304: Cannot find name 'e'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -9,12 +9,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName32.errors.txt b/tests/baselines/reference/parserComputedPropertyName32.errors.txt index 3bc47afd90db8..5d762d5ecc8e8 100644 --- a/tests/baselines/reference/parserComputedPropertyName32.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP declare class C { [e](): number ~~~ -!!! error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName36.errors.txt b/tests/baselines/reference/parserComputedPropertyName36.errors.txt index e746b5e4f54ba..9fbd7f565ad8f 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName36.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS2304: Cannot find name 'public'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [public ]: string; ~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ diff --git a/tests/baselines/reference/parserComputedPropertyName7.errors.txt b/tests/baselines/reference/parserComputedPropertyName7.errors.txt index 2fc7fd0346355..4fd7f320f266e 100644 --- a/tests/baselines/reference/parserComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName8.errors.txt b/tests/baselines/reference/parserComputedPropertyName8.errors.txt index 0a57a6decbd75..a846f858ea78d 100644 --- a/tests/baselines/reference/parserComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,12): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { public [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName9.errors.txt b/tests/baselines/reference/parserComputedPropertyName9.errors.txt index 8d283a5f1b8d1..8d0390053f121 100644 --- a/tests/baselines/reference/parserComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e]: Type ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. ~~~~ diff --git a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt index 997587b0c7907..7b1f9cb183248 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput declare class C { [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt index 233e665d9bf78..6fcb462d9e332 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e] = 1 ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt index a8ba9113ea69a..2bd17b3f4ca10 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e](); ~~~ -!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt index c92babd424d6a..3c7cdfd38a34e 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput interface I { [e]: number ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt index d776c7921ea97..487e84cccbf40 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt index d8f152c6b5aa0..6057d4f7cd339 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts (2 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt index f4a6da790c02a..cb08a497e1cd4 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e]: Type ~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. ~~~~ diff --git a/tests/baselines/reference/parserIndexSignature11.errors.txt b/tests/baselines/reference/parserIndexSignature11.errors.txt index 43f593c731a74..1f52552235743 100644 --- a/tests/baselines/reference/parserIndexSignature11.errors.txt +++ b/tests/baselines/reference/parserIndexSignature11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,10): error TS2304: Cannot find name 'p'. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(3,9): error TS1021: An index signature must have a type annotation. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(4,10): error TS1096: An index signature must have exactly one parameter. @@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1 interface I { [p]; // Used to be indexer, now it is a computed property ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; diff --git a/tests/baselines/reference/parserIndexSignature4.errors.txt b/tests/baselines/reference/parserIndexSignature4.errors.txt index 2a102bd4c6ac9..8bc0d9c40eac6 100644 --- a/tests/baselines/reference/parserIndexSignature4.errors.txt +++ b/tests/baselines/reference/parserIndexSignature4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,4): error TS2304: Cannot find name 'a'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4 interface I { [a = 0] // Used to be indexer, now it is a computed property ~~~~~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature5.errors.txt b/tests/baselines/reference/parserIndexSignature5.errors.txt index 2870258489ca6..c868ecc48e312 100644 --- a/tests/baselines/reference/parserIndexSignature5.errors.txt +++ b/tests/baselines/reference/parserIndexSignature5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,4): error TS2304: Cannot find name 'a'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5 interface I { [a] // Used to be indexer, now it is a computed property ~~~ -!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index 74a8c9d46acca..cb1b31ddb4d4c 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAssignment.ts(4,13): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/compiler/propertyAssignment.ts(4,13): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/propertyAssignment.ts(4,14): error TS2304: Cannot find name 'index'. tests/cases/compiler/propertyAssignment.ts(12,1): error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. Type '{ x: number; }' provides no match for the signature 'new (): any'. @@ -12,7 +12,7 @@ tests/cases/compiler/propertyAssignment.ts(14,1): error TS2322: Type '{ x: numbe var foo2: { [index]; } // should be an error, used to be indexer, now it is a computed property ~~~~~~~ -!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~~~~ !!! error TS2304: Cannot find name 'index'. var bar2: { x : number; } diff --git a/tests/baselines/reference/symbolProperty7.errors.txt b/tests/baselines/reference/symbolProperty7.errors.txt index b2a182aa3bbe9..bf6065a89d9ed 100644 --- a/tests/baselines/reference/symbolProperty7.errors.txt +++ b/tests/baselines/reference/symbolProperty7.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/Symbols/symbolProperty7.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. -tests/cases/conformance/es6/Symbols/symbolProperty7.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +tests/cases/conformance/es6/Symbols/symbolProperty7.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/Symbols/symbolProperty7.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/Symbols/symbolProperty7.ts (2 errors) ==== class C { [Symbol()] = 0; ~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [Symbol()]: number; ~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a unique 'symbol()' type. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [Symbol()]() { } get [Symbol()]() { return 0; diff --git a/tests/baselines/reference/uniqueSymbols.js b/tests/baselines/reference/uniqueSymbols.js index 88282afb60ede..7da555e6b1f0e 100644 --- a/tests/baselines/reference/uniqueSymbols.js +++ b/tests/baselines/reference/uniqueSymbols.js @@ -5,10 +5,10 @@ let letCall = Symbol(); var varCall = Symbol(); // ambient declaration with type -declare const constType: symbol(); +declare const constType: unique symbol; // declaration with type and call initializer -const constTypeAndCall: symbol() = Symbol(); +const constTypeAndCall: unique symbol = Symbol(); // declaration from initializer const constInitToConstCall = constCall; @@ -57,8 +57,8 @@ async function* asyncGenFuncYieldVarCall() { yield varCall; } // classes class C { static readonly readonlyStaticCall = Symbol(); - static readonly readonlyStaticType: symbol(); - static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); + static readonly readonlyStaticType: unique symbol; + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); static readwriteStaticCall = Symbol(); readonly readonlyCall = Symbol(); @@ -85,7 +85,7 @@ const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwri // interfaces interface I { - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; } declare const i: I; @@ -95,9 +95,9 @@ const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyT // type literals type L = { - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; nested: { - readonly readonlyNestedType: symbol(); + readonly readonlyNestedType: unique symbol; } }; declare const l: L; @@ -195,11 +195,11 @@ const arrayOfConstCall = [constCall]; //// [uniqueSymbols.d.ts] -declare const constCall: symbol(); +declare const constCall: unique symbol; declare let letCall: symbol; declare var varCall: symbol; -declare const constType: symbol(); -declare const constTypeAndCall: symbol(); +declare const constType: unique symbol; +declare const constTypeAndCall: unique symbol; declare const constInitToConstCall: symbol; declare const constInitToLetCall: symbol; declare const constInitToVarCall: symbol; @@ -229,9 +229,9 @@ declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator; declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator; declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator; declare class C { - static readonly readonlyStaticCall: symbol(); - static readonly readonlyStaticType: symbol(); - static readonly readonlyStaticTypeAndCall: symbol(); + static readonly readonlyStaticCall: unique symbol; + static readonly readonlyStaticType: unique symbol; + static readonly readonlyStaticTypeAndCall: unique symbol; static readwriteStaticCall: symbol; readonly readonlyCall: symbol; readwriteCall: symbol; @@ -252,16 +252,16 @@ declare const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall; declare const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"]; declare const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"]; interface I { - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; } declare const i: I; declare const constInitToIReadonlyType: symbol; declare const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType; declare const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"]; declare type L = { - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; nested: { - readonly readonlyNestedType: symbol(); + readonly readonlyNestedType: unique symbol; }; }; declare const l: L; diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols index 9831e201ece47..970938094ca98 100644 --- a/tests/baselines/reference/uniqueSymbols.symbols +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -13,11 +13,11 @@ var varCall = Symbol(); >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) // ambient declaration with type -declare const constType: symbol(); +declare const constType: unique symbol; >constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) // declaration with type and call initializer -const constTypeAndCall: symbol() = Symbol(); +const constTypeAndCall: unique symbol = Symbol(); >constTypeAndCall : Symbol(constTypeAndCall, Decl(uniqueSymbols.ts, 9, 5)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) @@ -154,15 +154,15 @@ class C { >readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) - static readonly readonlyStaticType: symbol(); + static readonly readonlyStaticType: unique symbol; >readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) - static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) static readwriteStaticCall = Symbol(); ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) readonly readonlyCall = Symbol(); @@ -191,15 +191,15 @@ const constInitToCReadonlyStaticType = C.readonlyStaticType; const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; >constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 69, 5)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) >C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) const constInitToCReadwriteStaticCall = C.readwriteStaticCall; >constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbols.ts, 70, 5)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) >C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; >constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 72, 5)) @@ -221,21 +221,21 @@ const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; >constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbols.ts, 74, 5)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) >C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) >C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 49)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; >constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 75, 5)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) >C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) >C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 67)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) const constInitToCReadonlyCall = c.readonlyCall; >constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbols.ts, 77, 5)) @@ -285,7 +285,7 @@ const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwri interface I { >I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; >readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) } declare const i: I; @@ -318,13 +318,13 @@ const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyT type L = { >L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; >readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) nested: { ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) - readonly readonlyNestedType: symbol(); + readonly readonlyNestedType: unique symbol; >readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) } }; @@ -341,9 +341,9 @@ const constInitToLReadonlyType = l.readonlyType; const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; >constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbols.ts, 104, 5)) >l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; @@ -358,14 +358,14 @@ const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyT const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; >constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbols.ts, 106, 5)) >l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) >l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; @@ -379,9 +379,9 @@ const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNest >constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 108, 5)) >L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) >l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 36)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) >readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) // type argument inference diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index c9ccf9baaacbf..495cf583294e2 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -1,8 +1,8 @@ === tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts === // declarations with call initializer const constCall = Symbol(); ->constCall : symbol() ->Symbol() : symbol() +>constCall : unique symbol +>Symbol() : unique symbol >Symbol : SymbolConstructor let letCall = Symbol(); @@ -16,19 +16,19 @@ var varCall = Symbol(); >Symbol : SymbolConstructor // ambient declaration with type -declare const constType: symbol(); ->constType : symbol() +declare const constType: unique symbol; +>constType : unique symbol // declaration with type and call initializer -const constTypeAndCall: symbol() = Symbol(); ->constTypeAndCall : symbol() ->Symbol() : symbol() +const constTypeAndCall: unique symbol = Symbol(); +>constTypeAndCall : unique symbol +>Symbol() : unique symbol >Symbol : SymbolConstructor // declaration from initializer const constInitToConstCall = constCall; >constInitToConstCall : symbol ->constCall : symbol() +>constCall : unique symbol const constInitToLetCall = letCall; >constInitToLetCall : symbol @@ -40,11 +40,11 @@ const constInitToVarCall = varCall; const constInitToConstDeclAmbient = constType; >constInitToConstDeclAmbient : symbol ->constType : symbol() +>constType : unique symbol let letInitToConstCall = constCall; >letInitToConstCall : symbol ->constCall : symbol() +>constCall : unique symbol let letInitToLetCall = letCall; >letInitToLetCall : symbol @@ -56,11 +56,11 @@ let letInitToVarCall = varCall; let letInitToConstDeclAmbient = constType; >letInitToConstDeclAmbient : symbol ->constType : symbol() +>constType : unique symbol var varInitToConstCall = constCall; >varInitToConstCall : symbol ->constCall : symbol() +>constCall : unique symbol var varInitToLetCall = letCall; >varInitToLetCall : symbol @@ -72,23 +72,23 @@ var varInitToVarCall = varCall; var varInitToConstDeclAmbient = constType; >varInitToConstDeclAmbient : symbol ->constType : symbol() +>constType : unique symbol // declaration from initializer with type query const constInitToConstCallWithTypeQuery: typeof constCall = constCall; ->constInitToConstCallWithTypeQuery : symbol() ->constCall : symbol() ->constCall : symbol() +>constInitToConstCallWithTypeQuery : unique symbol +>constCall : unique symbol +>constCall : unique symbol const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; ->constInitToConstDeclAmbientWithTypeQuery : symbol() ->constType : symbol() ->constType : symbol() +>constInitToConstDeclAmbientWithTypeQuery : unique symbol +>constType : unique symbol +>constType : unique symbol // function return inference function funcReturnConstCall() { return constCall; } >funcReturnConstCall : () => symbol ->constCall : symbol() +>constCall : unique symbol function funcReturnLetCall() { return letCall; } >funcReturnLetCall : () => symbol @@ -100,15 +100,15 @@ function funcReturnVarCall() { return varCall; } // function return value with type query function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } ->funcReturnConstCallWithTypeQuery : () => symbol() ->constCall : symbol() ->constCall : symbol() +>funcReturnConstCallWithTypeQuery : () => unique symbol +>constCall : unique symbol +>constCall : unique symbol // generator function yield inference function* genFuncYieldConstCall() { yield constCall; } >genFuncYieldConstCall : () => IterableIterator >yield constCall : any ->constCall : symbol() +>constCall : unique symbol function* genFuncYieldLetCall() { yield letCall; } >genFuncYieldLetCall : () => IterableIterator @@ -122,16 +122,16 @@ function* genFuncYieldVarCall() { yield varCall; } // generator function yield with return type query function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } ->genFuncYieldConstCallWithTypeQuery : () => IterableIterator +>genFuncYieldConstCallWithTypeQuery : () => IterableIterator >IterableIterator : IterableIterator ->constCall : symbol() +>constCall : unique symbol >yield constCall : any ->constCall : symbol() +>constCall : unique symbol // async function return inference async function asyncFuncReturnConstCall() { return constCall; } >asyncFuncReturnConstCall : () => Promise ->constCall : symbol() +>constCall : unique symbol async function asyncFuncReturnLetCall() { return letCall; } >asyncFuncReturnLetCall : () => Promise @@ -145,7 +145,7 @@ async function asyncFuncReturnVarCall() { return varCall; } async function* asyncGenFuncYieldConstCall() { yield constCall; } >asyncGenFuncYieldConstCall : () => AsyncIterableIterator >yield constCall : any ->constCall : symbol() +>constCall : unique symbol async function* asyncGenFuncYieldLetCall() { yield letCall; } >asyncGenFuncYieldLetCall : () => AsyncIterableIterator @@ -162,16 +162,16 @@ class C { >C : C static readonly readonlyStaticCall = Symbol(); ->readonlyStaticCall : symbol() ->Symbol() : symbol() +>readonlyStaticCall : unique symbol +>Symbol() : unique symbol >Symbol : SymbolConstructor - static readonly readonlyStaticType: symbol(); ->readonlyStaticType : symbol() + static readonly readonlyStaticType: unique symbol; +>readonlyStaticType : unique symbol - static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); ->readonlyStaticTypeAndCall : symbol() ->Symbol() : symbol() + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); +>readonlyStaticTypeAndCall : unique symbol +>Symbol() : unique symbol >Symbol : SymbolConstructor static readwriteStaticCall = Symbol(); @@ -195,21 +195,21 @@ declare const c: C; const constInitToCReadonlyStaticCall = C.readonlyStaticCall; >constInitToCReadonlyStaticCall : symbol ->C.readonlyStaticCall : symbol() +>C.readonlyStaticCall : unique symbol >C : typeof C ->readonlyStaticCall : symbol() +>readonlyStaticCall : unique symbol const constInitToCReadonlyStaticType = C.readonlyStaticType; >constInitToCReadonlyStaticType : symbol ->C.readonlyStaticType : symbol() +>C.readonlyStaticType : unique symbol >C : typeof C ->readonlyStaticType : symbol() +>readonlyStaticType : unique symbol const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; >constInitToCReadonlyStaticTypeAndCall : symbol ->C.readonlyStaticTypeAndCall : symbol() +>C.readonlyStaticTypeAndCall : unique symbol >C : typeof C ->readonlyStaticTypeAndCall : symbol() +>readonlyStaticTypeAndCall : unique symbol const constInitToCReadwriteStaticCall = C.readwriteStaticCall; >constInitToCReadwriteStaticCall : symbol @@ -218,31 +218,31 @@ const constInitToCReadwriteStaticCall = C.readwriteStaticCall; >readwriteStaticCall : symbol const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; ->constInitToCReadonlyStaticCallWithTypeQuery : symbol() ->C.readonlyStaticCall : symbol() +>constInitToCReadonlyStaticCallWithTypeQuery : unique symbol +>C.readonlyStaticCall : unique symbol >C : typeof C ->readonlyStaticCall : symbol() ->C.readonlyStaticCall : symbol() +>readonlyStaticCall : unique symbol +>C.readonlyStaticCall : unique symbol >C : typeof C ->readonlyStaticCall : symbol() +>readonlyStaticCall : unique symbol const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; ->constInitToCReadonlyStaticTypeWithTypeQuery : symbol() ->C.readonlyStaticType : symbol() +>constInitToCReadonlyStaticTypeWithTypeQuery : unique symbol +>C.readonlyStaticType : unique symbol >C : typeof C ->readonlyStaticType : symbol() ->C.readonlyStaticType : symbol() +>readonlyStaticType : unique symbol +>C.readonlyStaticType : unique symbol >C : typeof C ->readonlyStaticType : symbol() +>readonlyStaticType : unique symbol const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; ->constInitToCReadonlyStaticTypeAndCallWithTypeQuery : symbol() ->C.readonlyStaticTypeAndCall : symbol() +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : unique symbol +>C.readonlyStaticTypeAndCall : unique symbol >C : typeof C ->readonlyStaticTypeAndCall : symbol() ->C.readonlyStaticTypeAndCall : symbol() +>readonlyStaticTypeAndCall : unique symbol +>C.readonlyStaticTypeAndCall : unique symbol >C : typeof C ->readonlyStaticTypeAndCall : symbol() +>readonlyStaticTypeAndCall : unique symbol const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; >constInitToCReadwriteStaticCallWithTypeQuery : symbol @@ -301,8 +301,8 @@ const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwri interface I { >I : I - readonly readonlyType: symbol(); ->readonlyType : symbol() + readonly readonlyType: unique symbol; +>readonlyType : unique symbol } declare const i: I; >i : I @@ -310,38 +310,38 @@ declare const i: I; const constInitToIReadonlyType = i.readonlyType; >constInitToIReadonlyType : symbol ->i.readonlyType : symbol() +>i.readonlyType : unique symbol >i : I ->readonlyType : symbol() +>readonlyType : unique symbol const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; ->constInitToIReadonlyTypeWithTypeQuery : symbol() ->i.readonlyType : symbol() +>constInitToIReadonlyTypeWithTypeQuery : unique symbol +>i.readonlyType : unique symbol >i : I ->readonlyType : symbol() ->i.readonlyType : symbol() +>readonlyType : unique symbol +>i.readonlyType : unique symbol >i : I ->readonlyType : symbol() +>readonlyType : unique symbol const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; ->constInitToIReadonlyTypeWithIndexedAccess : symbol() +>constInitToIReadonlyTypeWithIndexedAccess : unique symbol >I : I ->i.readonlyType : symbol() +>i.readonlyType : unique symbol >i : I ->readonlyType : symbol() +>readonlyType : unique symbol // type literals type L = { >L : L - readonly readonlyType: symbol(); ->readonlyType : symbol() + readonly readonlyType: unique symbol; +>readonlyType : unique symbol nested: { ->nested : { readonly readonlyNestedType: symbol(); } +>nested : { readonly readonlyNestedType: unique symbol; } - readonly readonlyNestedType: symbol(); ->readonlyNestedType : symbol() + readonly readonlyNestedType: unique symbol; +>readonlyNestedType : unique symbol } }; declare const l: L; @@ -350,55 +350,55 @@ declare const l: L; const constInitToLReadonlyType = l.readonlyType; >constInitToLReadonlyType : symbol ->l.readonlyType : symbol() +>l.readonlyType : unique symbol >l : L ->readonlyType : symbol() +>readonlyType : unique symbol const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; >constInitToLReadonlyNestedType : symbol ->l.nested.readonlyNestedType : symbol() ->l.nested : { readonly readonlyNestedType: symbol(); } +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } >l : L ->nested : { readonly readonlyNestedType: symbol(); } ->readonlyNestedType : symbol() +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; ->constInitToLReadonlyTypeWithTypeQuery : symbol() ->l.readonlyType : symbol() +>constInitToLReadonlyTypeWithTypeQuery : unique symbol +>l.readonlyType : unique symbol >l : L ->readonlyType : symbol() ->l.readonlyType : symbol() +>readonlyType : unique symbol +>l.readonlyType : unique symbol >l : L ->readonlyType : symbol() +>readonlyType : unique symbol const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithTypeQuery : symbol() ->l.nested.readonlyNestedType : symbol() ->l.nested : { readonly readonlyNestedType: symbol(); } +>constInitToLReadonlyNestedTypeWithTypeQuery : unique symbol +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } >l : L ->nested : { readonly readonlyNestedType: symbol(); } ->readonlyNestedType : symbol() ->l.nested.readonlyNestedType : symbol() ->l.nested : { readonly readonlyNestedType: symbol(); } +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } >l : L ->nested : { readonly readonlyNestedType: symbol(); } ->readonlyNestedType : symbol() +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; ->constInitToLReadonlyTypeWithIndexedAccess : symbol() +>constInitToLReadonlyTypeWithIndexedAccess : unique symbol >L : L ->l.readonlyType : symbol() +>l.readonlyType : unique symbol >l : L ->readonlyType : symbol() +>readonlyType : unique symbol const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithIndexedAccess : symbol() +>constInitToLReadonlyNestedTypeWithIndexedAccess : unique symbol >L : L ->l.nested.readonlyNestedType : symbol() ->l.nested : { readonly readonlyNestedType: symbol(); } +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } >l : L ->nested : { readonly readonlyNestedType: symbol(); } ->readonlyNestedType : symbol() +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol // type argument inference const promiseForConstCall = Promise.resolve(constCall); @@ -407,10 +407,10 @@ const promiseForConstCall = Promise.resolve(constCall); >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->constCall : symbol() +>constCall : unique symbol const arrayOfConstCall = [constCall]; >arrayOfConstCall : symbol[] >[constCall] : symbol[] ->constCall : symbol() +>constCall : unique symbol diff --git a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt index 95c9132fb7549..356617779aa51 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt +++ b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt @@ -1,265 +1,265 @@ -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(2,19): error TS1337: Unique 'symbol()' types may not be used on a variable declaration with a binding name. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,13): error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(4,13): error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(7,38): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,45): error TS1331: Unique 'symbol()' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,39): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,40): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,53): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,59): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,50): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(17,44): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(19,14): error TS1335: 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(20,5): error TS1335: 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,25): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(22,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,26): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,27): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,40): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,46): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,37): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,26): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,28): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(31,12): error TS1335: 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(32,38): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(33,46): error TS1331: Unique 'symbol()' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,39): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,40): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,53): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,59): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,50): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,39): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,41): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(45,5): error TS1334: 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(46,25): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(47,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,26): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,27): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,40): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,46): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,37): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(57,5): error TS1334: 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(58,25): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(59,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,26): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,27): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,40): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,46): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,37): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(68,21): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,52): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,49): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(73,44): error TS1339: Unique 'symbol()' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,33): error TS1331: Unique 'symbol()' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1332: Unique 'symbol()' types are not allowed in a tuple type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(78,51): error TS1333: Unique 'symbol()' types are not allowed in a mapped type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,29): error TS1329: Unique 'symbol()' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,40): error TS1329: Unique 'symbol()' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,36): error TS1329: Unique 'symbol()' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,47): error TS1329: Unique 'symbol()' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(2,19): error TS1337: 'unique symbol' types may not be used on a variable declaration with a binding name. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,13): error TS1336: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(4,13): error TS1336: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(7,38): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,45): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,39): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,53): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,59): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,50): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(17,44): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(19,14): error TS1335: 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(20,5): error TS1335: 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,25): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(22,33): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,27): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,46): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,37): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,28): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(31,12): error TS1335: 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(32,38): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(33,46): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,39): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,53): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,59): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,50): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,39): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,41): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(45,5): error TS1334: 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(46,25): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(47,33): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,27): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,46): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,37): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(57,5): error TS1334: 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(58,25): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(59,33): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,27): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,46): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,37): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(68,21): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,52): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,49): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(73,44): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,33): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1332: 'unique symbol' types are not allowed in a tuple type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(78,51): error TS1333: 'unique symbol' types are not allowed in a mapped type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,29): error TS1329: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,45): error TS1329: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,36): error TS1329: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error TS1329: 'unique symbol' types are not allowed in a union type. ==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts (59 errors) ==== // declarations - declare const {}: symbol(); - ~~~~~~~~ -!!! error TS1337: Unique 'symbol()' types may not be used on a variable declaration with a binding name. - declare let invalidLetType: symbol(); + declare const {}: unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1337: 'unique symbol' types may not be used on a variable declaration with a binding name. + declare let invalidLetType: unique symbol; ~~~~~~~~~~~~~~ -!!! error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. - declare var invalidVarType: symbol(); +!!! error TS1336: A variable whose type is a 'unique symbol' type must be 'const'. + declare var invalidVarType: unique symbol; ~~~~~~~~~~~~~~ -!!! error TS1336: A variable whose type is a unique 'symbol()' type must be 'const'. +!!! error TS1336: A variable whose type is a 'unique symbol' type must be 'const'. // function arguments and return types - declare function invalidArgType(arg: symbol()): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - declare function invalidRestArgType(...arg: symbol()[]): void; - ~~~~~~~~ -!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. - declare function invalidReturnType(): symbol(); - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - declare function invalidThisType(this: symbol()): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - declare function invalidTypePredicate(n: any): n is symbol(); - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - declare function invalidTypeParameterConstraint(): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - declare function invalidTypeParameterDefault(): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. + declare function invalidArgType(arg: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + declare function invalidRestArgType(...arg: unique symbol[]): void; + ~~~~~~~~~~~~~ +!!! error TS1331: 'unique symbol' types are not allowed in an array type. + declare function invalidReturnType(): unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + declare function invalidThisType(this: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + declare function invalidTypePredicate(n: any): n is unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + declare function invalidTypeParameterConstraint(): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + declare function invalidTypeParameterDefault(): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. // classes class InvalidClass { - constructor(invalidConstructorArgType: symbol()) {} - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. + constructor(invalidConstructorArgType: unique symbol) {} + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. - readonly invalidReadonlyPropertyType: symbol(); + readonly invalidReadonlyPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1335: A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'. - invalidPropertyType: symbol(); +!!! error TS1335: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + invalidPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~ -!!! error TS1335: A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'. - invalidArgType(arg: symbol()): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidRestArgType(...args: symbol()[]): void { return; } - ~~~~~~~~ -!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. - invalidReturnType(): symbol() { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidThisType(this: symbol()): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypePredicate(n: any): n is symbol() { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypeParameterConstraint(): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypeParameterDefault(): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - get invalidGetter(): symbol() { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - set invalidSetter(arg: symbol()) { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. +!!! error TS1335: 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 TS1339: 'unique symbol' types are not allowed here. + invalidRestArgType(...args: unique symbol[]): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1331: 'unique symbol' types are not allowed in an array type. + invalidReturnType(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidThisType(this: unique symbol): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypePredicate(n: any): n is unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypeParameterConstraint(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypeParameterDefault(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + get invalidGetter(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + set invalidSetter(arg: unique symbol) { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. - static invalidStaticPropertyType: symbol(); + static invalidStaticPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1335: A property of a class whose type is a unique 'symbol()' type must be both 'static' and 'readonly'. - static invalidStaticArgType(arg: symbol()): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - static invalidStaticRestArgType(...args: symbol()[]): void { return; } - ~~~~~~~~ -!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. - static invalidStaticReturnType(): symbol() { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - static invalidStaticThisType(this: symbol()): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - static invalidStaticTypePredicate(n: any): n is symbol() { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - static invalidStaticTypeParameterConstraint(): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - static invalidStaticTypeParameterDefault(): void { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - static get invalidStaticGetter(): symbol() { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - static set invalidStaticSetter(arg: symbol()) { return; } - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. +!!! error TS1335: 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 TS1339: 'unique symbol' types are not allowed here. + static invalidStaticRestArgType(...args: unique symbol[]): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1331: 'unique symbol' types are not allowed in an array type. + static invalidStaticReturnType(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + static invalidStaticThisType(this: unique symbol): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + static invalidStaticTypeParameterConstraint(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + static invalidStaticTypeParameterDefault(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + static get invalidStaticGetter(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + static set invalidStaticSetter(arg: unique symbol) { return; } + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. } // interfaces interface InvalidInterface { - invalidPropertyType: symbol(); + invalidPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~ -!!! error TS1334: A property of an interface or type literal whose type is a unique 'symbol()' type must be 'readonly'. - invalidArgType(arg: symbol()): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidRestArgType(...args: symbol()[]): void; - ~~~~~~~~ -!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. - invalidReturnType(): symbol(); - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidThisType(this: symbol()); - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypePredicate(n: any): n is symbol() - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypeParameterConstraint(): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypeParameterDefault(): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. +!!! error TS1334: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. + invalidArgType(arg: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidRestArgType(...args: unique symbol[]): void; + ~~~~~~~~~~~~~ +!!! error TS1331: 'unique symbol' types are not allowed in an array type. + invalidReturnType(): unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidThisType(this: unique symbol); + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypePredicate(n: any): n is unique symbol + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypeParameterConstraint(): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypeParameterDefault(): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. } // type literals type InvalidTypeLiteral = { - invalidPropertyType: symbol(); + invalidPropertyType: unique symbol; ~~~~~~~~~~~~~~~~~~~ -!!! error TS1334: A property of an interface or type literal whose type is a unique 'symbol()' type must be 'readonly'. - invalidArgType(arg: symbol()): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidRestArgType(...args: symbol()[]): void; - ~~~~~~~~ -!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. - invalidReturnType(): symbol(); - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidThisType(this: symbol()); - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypePredicate(n: any): n is symbol() - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypeParameterConstraint(): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - invalidTypeParameterDefault(): void; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. +!!! error TS1334: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. + invalidArgType(arg: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidRestArgType(...args: unique symbol[]): void; + ~~~~~~~~~~~~~ +!!! error TS1331: 'unique symbol' types are not allowed in an array type. + invalidReturnType(): unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidThisType(this: unique symbol); + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypePredicate(n: any): n is unique symbol + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypeParameterConstraint(): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + invalidTypeParameterDefault(): void; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. }; // type alias - type InvalidAlias = symbol(); - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - type InvalidAliasTypeParameterConstraint = never; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - type InvalidAliasTypeParameterDefault = never; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. + type InvalidAlias = unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + type InvalidAliasTypeParameterConstraint = never; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + type InvalidAliasTypeParameterDefault = never; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. // type references - declare const invalidTypeArgument: Promise; - ~~~~~~~~ -!!! error TS1339: Unique 'symbol()' types are not allowed here. - declare const invalidArrayType: symbol()[]; - ~~~~~~~~ -!!! error TS1331: Unique 'symbol()' types are not allowed in an array type. - declare const invalidTupleType: [symbol()]; - ~~~~~~~~ -!!! error TS1332: Unique 'symbol()' types are not allowed in a tuple type. + declare const invalidTypeArgument: Promise; + ~~~~~~~~~~~~~ +!!! error TS1339: 'unique symbol' types are not allowed here. + declare const invalidArrayType: unique symbol[]; + ~~~~~~~~~~~~~ +!!! error TS1331: 'unique symbol' types are not allowed in an array type. + declare const invalidTupleType: [unique symbol]; + ~~~~~~~~~~~~~ +!!! error TS1332: 'unique symbol' types are not allowed in a tuple type. // mapped types - declare const invalidMappedType: { [P in string]: symbol() }; - ~~~~~~~~ -!!! error TS1333: Unique 'symbol()' types are not allowed in a mapped type. + declare const invalidMappedType: { [P in string]: unique symbol }; + ~~~~~~~~~~~~~ +!!! error TS1333: 'unique symbol' types are not allowed in a mapped type. // unions/intersection - declare const invalidUnion: symbol() | symbol(); - ~~~~~~~~ -!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. - ~~~~~~~~ -!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. - declare const invalidIntersection: symbol() | symbol(); - ~~~~~~~~ -!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. - ~~~~~~~~ -!!! error TS1329: Unique 'symbol()' types are not allowed in a union type. + declare const invalidUnion: unique symbol | unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1329: 'unique symbol' types are not allowed in a union type. + ~~~~~~~~~~~~~ +!!! error TS1329: 'unique symbol' types are not allowed in a union type. + declare const invalidIntersection: unique symbol | unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1329: 'unique symbol' types are not allowed in a union type. + ~~~~~~~~~~~~~ +!!! error TS1329: 'unique symbol' types are not allowed in a union type. \ No newline at end of file diff --git a/tests/baselines/reference/uniqueSymbolsErrors.js b/tests/baselines/reference/uniqueSymbolsErrors.js index 806e28a717848..0cb0427ea6453 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.js +++ b/tests/baselines/reference/uniqueSymbolsErrors.js @@ -1,86 +1,86 @@ //// [uniqueSymbolsErrors.ts] // declarations -declare const {}: symbol(); -declare let invalidLetType: symbol(); -declare var invalidVarType: symbol(); +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; +declare var invalidVarType: unique symbol; // function arguments and return types -declare function invalidArgType(arg: symbol()): void; -declare function invalidRestArgType(...arg: symbol()[]): void; -declare function invalidReturnType(): symbol(); -declare function invalidThisType(this: symbol()): void; -declare function invalidTypePredicate(n: any): n is symbol(); -declare function invalidTypeParameterConstraint(): void; -declare function invalidTypeParameterDefault(): void; +declare function invalidArgType(arg: unique symbol): void; +declare function invalidRestArgType(...arg: unique symbol[]): void; +declare function invalidReturnType(): unique symbol; +declare function invalidThisType(this: unique symbol): void; +declare function invalidTypePredicate(n: any): n is unique symbol; +declare function invalidTypeParameterConstraint(): void; +declare function invalidTypeParameterDefault(): void; // classes class InvalidClass { - constructor(invalidConstructorArgType: symbol()) {} + constructor(invalidConstructorArgType: unique symbol) {} - readonly invalidReadonlyPropertyType: symbol(); - invalidPropertyType: symbol(); - invalidArgType(arg: symbol()): void { return; } - invalidRestArgType(...args: symbol()[]): void { return; } - invalidReturnType(): symbol() { return; } - invalidThisType(this: symbol()): void { return; } - invalidTypePredicate(n: any): n is symbol() { return; } - invalidTypeParameterConstraint(): void { return; } - invalidTypeParameterDefault(): void { return; } - get invalidGetter(): symbol() { return; } - set invalidSetter(arg: symbol()) { return; } + readonly invalidReadonlyPropertyType: unique symbol; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void { return; } + invalidRestArgType(...args: unique symbol[]): void { return; } + invalidReturnType(): unique symbol { return; } + invalidThisType(this: unique symbol): void { return; } + invalidTypePredicate(n: any): n is unique symbol { return; } + invalidTypeParameterConstraint(): void { return; } + invalidTypeParameterDefault(): void { return; } + get invalidGetter(): unique symbol { return; } + set invalidSetter(arg: unique symbol) { return; } - static invalidStaticPropertyType: symbol(); - static invalidStaticArgType(arg: symbol()): void { return; } - static invalidStaticRestArgType(...args: symbol()[]): void { return; } - static invalidStaticReturnType(): symbol() { return; } - static invalidStaticThisType(this: symbol()): void { return; } - static invalidStaticTypePredicate(n: any): n is symbol() { return; } - static invalidStaticTypeParameterConstraint(): void { return; } - static invalidStaticTypeParameterDefault(): void { return; } - static get invalidStaticGetter(): symbol() { return; } - static set invalidStaticSetter(arg: symbol()) { return; } + static invalidStaticPropertyType: unique symbol; + static invalidStaticArgType(arg: unique symbol): void { return; } + static invalidStaticRestArgType(...args: unique symbol[]): void { return; } + static invalidStaticReturnType(): unique symbol { return; } + static invalidStaticThisType(this: unique symbol): void { return; } + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } + static invalidStaticTypeParameterConstraint(): void { return; } + static invalidStaticTypeParameterDefault(): void { return; } + static get invalidStaticGetter(): unique symbol { return; } + static set invalidStaticSetter(arg: unique symbol) { return; } } // interfaces interface InvalidInterface { - invalidPropertyType: symbol(); - invalidArgType(arg: symbol()): void; - invalidRestArgType(...args: symbol()[]): void; - invalidReturnType(): symbol(); - invalidThisType(this: symbol()); - invalidTypePredicate(n: any): n is symbol() - invalidTypeParameterConstraint(): void; - invalidTypeParameterDefault(): void; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: unique symbol[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; } // type literals type InvalidTypeLiteral = { - invalidPropertyType: symbol(); - invalidArgType(arg: symbol()): void; - invalidRestArgType(...args: symbol()[]): void; - invalidReturnType(): symbol(); - invalidThisType(this: symbol()); - invalidTypePredicate(n: any): n is symbol() - invalidTypeParameterConstraint(): void; - invalidTypeParameterDefault(): void; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: unique symbol[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; }; // type alias -type InvalidAlias = symbol(); -type InvalidAliasTypeParameterConstraint = never; -type InvalidAliasTypeParameterDefault = never; +type InvalidAlias = unique symbol; +type InvalidAliasTypeParameterConstraint = never; +type InvalidAliasTypeParameterDefault = never; // type references -declare const invalidTypeArgument: Promise; -declare const invalidArrayType: symbol()[]; -declare const invalidTupleType: [symbol()]; +declare const invalidTypeArgument: Promise; +declare const invalidArrayType: unique symbol[]; +declare const invalidTupleType: [unique symbol]; // mapped types -declare const invalidMappedType: { [P in string]: symbol() }; +declare const invalidMappedType: { [P in string]: unique symbol }; // unions/intersection -declare const invalidUnion: symbol() | symbol(); -declare const invalidIntersection: symbol() | symbol(); +declare const invalidUnion: unique symbol | unique symbol; +declare const invalidIntersection: unique symbol | unique symbol; diff --git a/tests/baselines/reference/uniqueSymbolsErrors.symbols b/tests/baselines/reference/uniqueSymbolsErrors.symbols index 75c06e720d5b6..2177e2db8a35c 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.symbols +++ b/tests/baselines/reference/uniqueSymbolsErrors.symbols @@ -1,125 +1,125 @@ === tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === // declarations -declare const {}: symbol(); -declare let invalidLetType: symbol(); +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; >invalidLetType : Symbol(invalidLetType, Decl(uniqueSymbolsErrors.ts, 2, 11)) -declare var invalidVarType: symbol(); +declare var invalidVarType: unique symbol; >invalidVarType : Symbol(invalidVarType, Decl(uniqueSymbolsErrors.ts, 3, 11)) // function arguments and return types -declare function invalidArgType(arg: symbol()): void; ->invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 3, 37)) +declare function invalidArgType(arg: unique symbol): void; +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 3, 42)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 6, 32)) -declare function invalidRestArgType(...arg: symbol()[]): void; ->invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 6, 53)) +declare function invalidRestArgType(...arg: unique symbol[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 6, 58)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 7, 36)) -declare function invalidReturnType(): symbol(); ->invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 7, 62)) +declare function invalidReturnType(): unique symbol; +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 7, 67)) -declare function invalidThisType(this: symbol()): void; ->invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 8, 47)) +declare function invalidThisType(this: unique symbol): void; +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 8, 52)) >this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 9, 33)) -declare function invalidTypePredicate(n: any): n is symbol(); ->invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 9, 55)) +declare function invalidTypePredicate(n: any): n is unique symbol; +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 9, 60)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 10, 38)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 10, 38)) -declare function invalidTypeParameterConstraint(): void; ->invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 10, 61)) +declare function invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 10, 66)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 11, 48)) -declare function invalidTypeParameterDefault(): void; ->invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 11, 76)) +declare function invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 11, 81)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 12, 45)) // classes class InvalidClass { ->InvalidClass : Symbol(InvalidClass, Decl(uniqueSymbolsErrors.ts, 12, 67)) +>InvalidClass : Symbol(InvalidClass, Decl(uniqueSymbolsErrors.ts, 12, 72)) - constructor(invalidConstructorArgType: symbol()) {} + constructor(invalidConstructorArgType: unique symbol) {} >invalidConstructorArgType : Symbol(invalidConstructorArgType, Decl(uniqueSymbolsErrors.ts, 16, 16)) - readonly invalidReadonlyPropertyType: symbol(); ->invalidReadonlyPropertyType : Symbol(InvalidClass.invalidReadonlyPropertyType, Decl(uniqueSymbolsErrors.ts, 16, 55)) + readonly invalidReadonlyPropertyType: unique symbol; +>invalidReadonlyPropertyType : Symbol(InvalidClass.invalidReadonlyPropertyType, Decl(uniqueSymbolsErrors.ts, 16, 60)) - invalidPropertyType: symbol(); ->invalidPropertyType : Symbol(InvalidClass.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 18, 51)) + invalidPropertyType: unique symbol; +>invalidPropertyType : Symbol(InvalidClass.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 18, 56)) - invalidArgType(arg: symbol()): void { return; } ->invalidArgType : Symbol(InvalidClass.invalidArgType, Decl(uniqueSymbolsErrors.ts, 19, 34)) + invalidArgType(arg: unique symbol): void { return; } +>invalidArgType : Symbol(InvalidClass.invalidArgType, Decl(uniqueSymbolsErrors.ts, 19, 39)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 20, 19)) - invalidRestArgType(...args: symbol()[]): void { return; } ->invalidRestArgType : Symbol(InvalidClass.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 20, 51)) + invalidRestArgType(...args: unique symbol[]): void { return; } +>invalidRestArgType : Symbol(InvalidClass.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 20, 56)) >args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 21, 23)) - invalidReturnType(): symbol() { return; } ->invalidReturnType : Symbol(InvalidClass.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 21, 61)) + invalidReturnType(): unique symbol { return; } +>invalidReturnType : Symbol(InvalidClass.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 21, 66)) - invalidThisType(this: symbol()): void { return; } ->invalidThisType : Symbol(InvalidClass.invalidThisType, Decl(uniqueSymbolsErrors.ts, 22, 45)) + invalidThisType(this: unique symbol): void { return; } +>invalidThisType : Symbol(InvalidClass.invalidThisType, Decl(uniqueSymbolsErrors.ts, 22, 50)) >this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 23, 20)) - invalidTypePredicate(n: any): n is symbol() { return; } ->invalidTypePredicate : Symbol(InvalidClass.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 23, 53)) + invalidTypePredicate(n: any): n is unique symbol { return; } +>invalidTypePredicate : Symbol(InvalidClass.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 23, 58)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 24, 25)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 24, 25)) - invalidTypeParameterConstraint(): void { return; } ->invalidTypeParameterConstraint : Symbol(InvalidClass.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 24, 59)) + invalidTypeParameterConstraint(): void { return; } +>invalidTypeParameterConstraint : Symbol(InvalidClass.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 24, 64)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 25, 35)) - invalidTypeParameterDefault(): void { return; } ->invalidTypeParameterDefault : Symbol(InvalidClass.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 25, 74)) + invalidTypeParameterDefault(): void { return; } +>invalidTypeParameterDefault : Symbol(InvalidClass.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 25, 79)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 26, 32)) - get invalidGetter(): symbol() { return; } ->invalidGetter : Symbol(InvalidClass.invalidGetter, Decl(uniqueSymbolsErrors.ts, 26, 65)) + get invalidGetter(): unique symbol { return; } +>invalidGetter : Symbol(InvalidClass.invalidGetter, Decl(uniqueSymbolsErrors.ts, 26, 70)) - set invalidSetter(arg: symbol()) { return; } ->invalidSetter : Symbol(InvalidClass.invalidSetter, Decl(uniqueSymbolsErrors.ts, 27, 45)) + set invalidSetter(arg: unique symbol) { return; } +>invalidSetter : Symbol(InvalidClass.invalidSetter, Decl(uniqueSymbolsErrors.ts, 27, 50)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 28, 22)) - static invalidStaticPropertyType: symbol(); ->invalidStaticPropertyType : Symbol(InvalidClass.invalidStaticPropertyType, Decl(uniqueSymbolsErrors.ts, 28, 48)) + static invalidStaticPropertyType: unique symbol; +>invalidStaticPropertyType : Symbol(InvalidClass.invalidStaticPropertyType, Decl(uniqueSymbolsErrors.ts, 28, 53)) - static invalidStaticArgType(arg: symbol()): void { return; } ->invalidStaticArgType : Symbol(InvalidClass.invalidStaticArgType, Decl(uniqueSymbolsErrors.ts, 30, 47)) + static invalidStaticArgType(arg: unique symbol): void { return; } +>invalidStaticArgType : Symbol(InvalidClass.invalidStaticArgType, Decl(uniqueSymbolsErrors.ts, 30, 52)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 31, 32)) - static invalidStaticRestArgType(...args: symbol()[]): void { return; } ->invalidStaticRestArgType : Symbol(InvalidClass.invalidStaticRestArgType, Decl(uniqueSymbolsErrors.ts, 31, 64)) + static invalidStaticRestArgType(...args: unique symbol[]): void { return; } +>invalidStaticRestArgType : Symbol(InvalidClass.invalidStaticRestArgType, Decl(uniqueSymbolsErrors.ts, 31, 69)) >args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 32, 36)) - static invalidStaticReturnType(): symbol() { return; } ->invalidStaticReturnType : Symbol(InvalidClass.invalidStaticReturnType, Decl(uniqueSymbolsErrors.ts, 32, 74)) + static invalidStaticReturnType(): unique symbol { return; } +>invalidStaticReturnType : Symbol(InvalidClass.invalidStaticReturnType, Decl(uniqueSymbolsErrors.ts, 32, 79)) - static invalidStaticThisType(this: symbol()): void { return; } ->invalidStaticThisType : Symbol(InvalidClass.invalidStaticThisType, Decl(uniqueSymbolsErrors.ts, 33, 58)) + static invalidStaticThisType(this: unique symbol): void { return; } +>invalidStaticThisType : Symbol(InvalidClass.invalidStaticThisType, Decl(uniqueSymbolsErrors.ts, 33, 63)) >this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 34, 33)) - static invalidStaticTypePredicate(n: any): n is symbol() { return; } ->invalidStaticTypePredicate : Symbol(InvalidClass.invalidStaticTypePredicate, Decl(uniqueSymbolsErrors.ts, 34, 66)) + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } +>invalidStaticTypePredicate : Symbol(InvalidClass.invalidStaticTypePredicate, Decl(uniqueSymbolsErrors.ts, 34, 71)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 35, 38)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 35, 38)) - static invalidStaticTypeParameterConstraint(): void { return; } ->invalidStaticTypeParameterConstraint : Symbol(InvalidClass.invalidStaticTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 35, 72)) + static invalidStaticTypeParameterConstraint(): void { return; } +>invalidStaticTypeParameterConstraint : Symbol(InvalidClass.invalidStaticTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 35, 77)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 36, 48)) - static invalidStaticTypeParameterDefault(): void { return; } ->invalidStaticTypeParameterDefault : Symbol(InvalidClass.invalidStaticTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 36, 87)) + static invalidStaticTypeParameterDefault(): void { return; } +>invalidStaticTypeParameterDefault : Symbol(InvalidClass.invalidStaticTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 36, 92)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 37, 45)) - static get invalidStaticGetter(): symbol() { return; } ->invalidStaticGetter : Symbol(InvalidClass.invalidStaticGetter, Decl(uniqueSymbolsErrors.ts, 37, 78)) + static get invalidStaticGetter(): unique symbol { return; } +>invalidStaticGetter : Symbol(InvalidClass.invalidStaticGetter, Decl(uniqueSymbolsErrors.ts, 37, 83)) - static set invalidStaticSetter(arg: symbol()) { return; } ->invalidStaticSetter : Symbol(InvalidClass.invalidStaticSetter, Decl(uniqueSymbolsErrors.ts, 38, 58)) + static set invalidStaticSetter(arg: unique symbol) { return; } +>invalidStaticSetter : Symbol(InvalidClass.invalidStaticSetter, Decl(uniqueSymbolsErrors.ts, 38, 63)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 39, 35)) } @@ -127,35 +127,35 @@ class InvalidClass { interface InvalidInterface { >InvalidInterface : Symbol(InvalidInterface, Decl(uniqueSymbolsErrors.ts, 40, 1)) - invalidPropertyType: symbol(); + invalidPropertyType: unique symbol; >invalidPropertyType : Symbol(InvalidInterface.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 43, 28)) - invalidArgType(arg: symbol()): void; ->invalidArgType : Symbol(InvalidInterface.invalidArgType, Decl(uniqueSymbolsErrors.ts, 44, 34)) + invalidArgType(arg: unique symbol): void; +>invalidArgType : Symbol(InvalidInterface.invalidArgType, Decl(uniqueSymbolsErrors.ts, 44, 39)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 45, 19)) - invalidRestArgType(...args: symbol()[]): void; ->invalidRestArgType : Symbol(InvalidInterface.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 45, 40)) + invalidRestArgType(...args: unique symbol[]): void; +>invalidRestArgType : Symbol(InvalidInterface.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 45, 45)) >args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 46, 23)) - invalidReturnType(): symbol(); ->invalidReturnType : Symbol(InvalidInterface.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 46, 50)) + invalidReturnType(): unique symbol; +>invalidReturnType : Symbol(InvalidInterface.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 46, 55)) - invalidThisType(this: symbol()); ->invalidThisType : Symbol(InvalidInterface.invalidThisType, Decl(uniqueSymbolsErrors.ts, 47, 34)) + invalidThisType(this: unique symbol); +>invalidThisType : Symbol(InvalidInterface.invalidThisType, Decl(uniqueSymbolsErrors.ts, 47, 39)) >this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 48, 20)) - invalidTypePredicate(n: any): n is symbol() ->invalidTypePredicate : Symbol(InvalidInterface.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 48, 36)) + invalidTypePredicate(n: any): n is unique symbol +>invalidTypePredicate : Symbol(InvalidInterface.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 48, 41)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 49, 25)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 49, 25)) - invalidTypeParameterConstraint(): void; ->invalidTypeParameterConstraint : Symbol(InvalidInterface.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 49, 47)) + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(InvalidInterface.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 49, 52)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 50, 35)) - invalidTypeParameterDefault(): void; ->invalidTypeParameterDefault : Symbol(InvalidInterface.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 50, 63)) + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(InvalidInterface.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 50, 68)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 51, 32)) } @@ -163,72 +163,72 @@ interface InvalidInterface { type InvalidTypeLiteral = { >InvalidTypeLiteral : Symbol(InvalidTypeLiteral, Decl(uniqueSymbolsErrors.ts, 52, 1)) - invalidPropertyType: symbol(); + invalidPropertyType: unique symbol; >invalidPropertyType : Symbol(invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 55, 27)) - invalidArgType(arg: symbol()): void; ->invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 56, 34)) + invalidArgType(arg: unique symbol): void; +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 56, 39)) >arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 57, 19)) - invalidRestArgType(...args: symbol()[]): void; ->invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 57, 40)) + invalidRestArgType(...args: unique symbol[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 57, 45)) >args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 58, 23)) - invalidReturnType(): symbol(); ->invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 58, 50)) + invalidReturnType(): unique symbol; +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 58, 55)) - invalidThisType(this: symbol()); ->invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 59, 34)) + invalidThisType(this: unique symbol); +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 59, 39)) >this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 60, 20)) - invalidTypePredicate(n: any): n is symbol() ->invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 60, 36)) + invalidTypePredicate(n: any): n is unique symbol +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 60, 41)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 61, 25)) >n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 61, 25)) - invalidTypeParameterConstraint(): void; ->invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 61, 47)) + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 61, 52)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 62, 35)) - invalidTypeParameterDefault(): void; ->invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 62, 63)) + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 62, 68)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 63, 32)) }; // type alias -type InvalidAlias = symbol(); +type InvalidAlias = unique symbol; >InvalidAlias : Symbol(InvalidAlias, Decl(uniqueSymbolsErrors.ts, 64, 2)) -type InvalidAliasTypeParameterConstraint = never; ->InvalidAliasTypeParameterConstraint : Symbol(InvalidAliasTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 67, 29)) +type InvalidAliasTypeParameterConstraint = never; +>InvalidAliasTypeParameterConstraint : Symbol(InvalidAliasTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 67, 34)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 68, 41)) -type InvalidAliasTypeParameterDefault = never; ->InvalidAliasTypeParameterDefault : Symbol(InvalidAliasTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 68, 69)) +type InvalidAliasTypeParameterDefault = never; +>InvalidAliasTypeParameterDefault : Symbol(InvalidAliasTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 68, 74)) >T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 69, 38)) // type references -declare const invalidTypeArgument: Promise; +declare const invalidTypeArgument: Promise; >invalidTypeArgument : Symbol(invalidTypeArgument, Decl(uniqueSymbolsErrors.ts, 72, 13)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -declare const invalidArrayType: symbol()[]; +declare const invalidArrayType: unique symbol[]; >invalidArrayType : Symbol(invalidArrayType, Decl(uniqueSymbolsErrors.ts, 73, 13)) -declare const invalidTupleType: [symbol()]; +declare const invalidTupleType: [unique symbol]; >invalidTupleType : Symbol(invalidTupleType, Decl(uniqueSymbolsErrors.ts, 74, 13)) // mapped types -declare const invalidMappedType: { [P in string]: symbol() }; +declare const invalidMappedType: { [P in string]: unique symbol }; >invalidMappedType : Symbol(invalidMappedType, Decl(uniqueSymbolsErrors.ts, 77, 13)) >P : Symbol(P, Decl(uniqueSymbolsErrors.ts, 77, 36)) // unions/intersection -declare const invalidUnion: symbol() | symbol(); +declare const invalidUnion: unique symbol | unique symbol; >invalidUnion : Symbol(invalidUnion, Decl(uniqueSymbolsErrors.ts, 80, 13)) -declare const invalidIntersection: symbol() | symbol(); +declare const invalidIntersection: unique symbol | unique symbol; >invalidIntersection : Symbol(invalidIntersection, Decl(uniqueSymbolsErrors.ts, 81, 13)) diff --git a/tests/baselines/reference/uniqueSymbolsErrors.types b/tests/baselines/reference/uniqueSymbolsErrors.types index 455dd13c58df0..d593b0c24ac8b 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.types +++ b/tests/baselines/reference/uniqueSymbolsErrors.types @@ -1,38 +1,38 @@ === tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === // declarations -declare const {}: symbol(); -declare let invalidLetType: symbol(); +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; >invalidLetType : symbol -declare var invalidVarType: symbol(); +declare var invalidVarType: unique symbol; >invalidVarType : symbol // function arguments and return types -declare function invalidArgType(arg: symbol()): void; +declare function invalidArgType(arg: unique symbol): void; >invalidArgType : (arg: symbol) => void >arg : symbol -declare function invalidRestArgType(...arg: symbol()[]): void; +declare function invalidRestArgType(...arg: unique symbol[]): void; >invalidRestArgType : (...arg: symbol[]) => void >arg : symbol[] -declare function invalidReturnType(): symbol(); +declare function invalidReturnType(): unique symbol; >invalidReturnType : () => symbol -declare function invalidThisType(this: symbol()): void; +declare function invalidThisType(this: unique symbol): void; >invalidThisType : (this: symbol) => void >this : symbol -declare function invalidTypePredicate(n: any): n is symbol(); +declare function invalidTypePredicate(n: any): n is unique symbol; >invalidTypePredicate : (n: any) => n is symbol >n : any >n : any -declare function invalidTypeParameterConstraint(): void; +declare function invalidTypeParameterConstraint(): void; >invalidTypeParameterConstraint : () => void >T : T -declare function invalidTypeParameterDefault(): void; +declare function invalidTypeParameterDefault(): void; >invalidTypeParameterDefault : () => void >T : T @@ -40,85 +40,85 @@ declare function invalidTypeParameterDefault(): void; class InvalidClass { >InvalidClass : InvalidClass - constructor(invalidConstructorArgType: symbol()) {} + constructor(invalidConstructorArgType: unique symbol) {} >invalidConstructorArgType : symbol - readonly invalidReadonlyPropertyType: symbol(); + readonly invalidReadonlyPropertyType: unique symbol; >invalidReadonlyPropertyType : symbol - invalidPropertyType: symbol(); + invalidPropertyType: unique symbol; >invalidPropertyType : symbol - invalidArgType(arg: symbol()): void { return; } + invalidArgType(arg: unique symbol): void { return; } >invalidArgType : (arg: symbol) => void >arg : symbol - invalidRestArgType(...args: symbol()[]): void { return; } + invalidRestArgType(...args: unique symbol[]): void { return; } >invalidRestArgType : (...args: symbol[]) => void >args : symbol[] - invalidReturnType(): symbol() { return; } + invalidReturnType(): unique symbol { return; } >invalidReturnType : () => symbol - invalidThisType(this: symbol()): void { return; } + invalidThisType(this: unique symbol): void { return; } >invalidThisType : (this: symbol) => void >this : symbol - invalidTypePredicate(n: any): n is symbol() { return; } + invalidTypePredicate(n: any): n is unique symbol { return; } >invalidTypePredicate : (n: any) => n is symbol >n : any >n : any - invalidTypeParameterConstraint(): void { return; } + invalidTypeParameterConstraint(): void { return; } >invalidTypeParameterConstraint : () => void >T : T - invalidTypeParameterDefault(): void { return; } + invalidTypeParameterDefault(): void { return; } >invalidTypeParameterDefault : () => void >T : T - get invalidGetter(): symbol() { return; } + get invalidGetter(): unique symbol { return; } >invalidGetter : symbol - set invalidSetter(arg: symbol()) { return; } + set invalidSetter(arg: unique symbol) { return; } >invalidSetter : symbol >arg : symbol - static invalidStaticPropertyType: symbol(); + static invalidStaticPropertyType: unique symbol; >invalidStaticPropertyType : symbol - static invalidStaticArgType(arg: symbol()): void { return; } + static invalidStaticArgType(arg: unique symbol): void { return; } >invalidStaticArgType : (arg: symbol) => void >arg : symbol - static invalidStaticRestArgType(...args: symbol()[]): void { return; } + static invalidStaticRestArgType(...args: unique symbol[]): void { return; } >invalidStaticRestArgType : (...args: symbol[]) => void >args : symbol[] - static invalidStaticReturnType(): symbol() { return; } + static invalidStaticReturnType(): unique symbol { return; } >invalidStaticReturnType : () => symbol - static invalidStaticThisType(this: symbol()): void { return; } + static invalidStaticThisType(this: unique symbol): void { return; } >invalidStaticThisType : (this: symbol) => void >this : symbol - static invalidStaticTypePredicate(n: any): n is symbol() { return; } + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } >invalidStaticTypePredicate : (n: any) => n is symbol >n : any >n : any - static invalidStaticTypeParameterConstraint(): void { return; } + static invalidStaticTypeParameterConstraint(): void { return; } >invalidStaticTypeParameterConstraint : () => void >T : T - static invalidStaticTypeParameterDefault(): void { return; } + static invalidStaticTypeParameterDefault(): void { return; } >invalidStaticTypeParameterDefault : () => void >T : T - static get invalidStaticGetter(): symbol() { return; } + static get invalidStaticGetter(): unique symbol { return; } >invalidStaticGetter : symbol - static set invalidStaticSetter(arg: symbol()) { return; } + static set invalidStaticSetter(arg: unique symbol) { return; } >invalidStaticSetter : symbol >arg : symbol } @@ -127,34 +127,34 @@ class InvalidClass { interface InvalidInterface { >InvalidInterface : InvalidInterface - invalidPropertyType: symbol(); + invalidPropertyType: unique symbol; >invalidPropertyType : symbol - invalidArgType(arg: symbol()): void; + invalidArgType(arg: unique symbol): void; >invalidArgType : (arg: symbol) => void >arg : symbol - invalidRestArgType(...args: symbol()[]): void; + invalidRestArgType(...args: unique symbol[]): void; >invalidRestArgType : (...args: symbol[]) => void >args : symbol[] - invalidReturnType(): symbol(); + invalidReturnType(): unique symbol; >invalidReturnType : () => symbol - invalidThisType(this: symbol()); + invalidThisType(this: unique symbol); >invalidThisType : (this: symbol) => any >this : symbol - invalidTypePredicate(n: any): n is symbol() + invalidTypePredicate(n: any): n is unique symbol >invalidTypePredicate : (n: any) => n is symbol >n : any >n : any - invalidTypeParameterConstraint(): void; + invalidTypeParameterConstraint(): void; >invalidTypeParameterConstraint : () => void >T : T - invalidTypeParameterDefault(): void; + invalidTypeParameterDefault(): void; >invalidTypeParameterDefault : () => void >T : T } @@ -163,72 +163,72 @@ interface InvalidInterface { type InvalidTypeLiteral = { >InvalidTypeLiteral : InvalidTypeLiteral - invalidPropertyType: symbol(); + invalidPropertyType: unique symbol; >invalidPropertyType : symbol - invalidArgType(arg: symbol()): void; + invalidArgType(arg: unique symbol): void; >invalidArgType : (arg: symbol) => void >arg : symbol - invalidRestArgType(...args: symbol()[]): void; + invalidRestArgType(...args: unique symbol[]): void; >invalidRestArgType : (...args: symbol[]) => void >args : symbol[] - invalidReturnType(): symbol(); + invalidReturnType(): unique symbol; >invalidReturnType : () => symbol - invalidThisType(this: symbol()); + invalidThisType(this: unique symbol); >invalidThisType : (this: symbol) => any >this : symbol - invalidTypePredicate(n: any): n is symbol() + invalidTypePredicate(n: any): n is unique symbol >invalidTypePredicate : (n: any) => n is symbol >n : any >n : any - invalidTypeParameterConstraint(): void; + invalidTypeParameterConstraint(): void; >invalidTypeParameterConstraint : () => void >T : T - invalidTypeParameterDefault(): void; + invalidTypeParameterDefault(): void; >invalidTypeParameterDefault : () => void >T : T }; // type alias -type InvalidAlias = symbol(); +type InvalidAlias = unique symbol; >InvalidAlias : symbol -type InvalidAliasTypeParameterConstraint = never; +type InvalidAliasTypeParameterConstraint = never; >InvalidAliasTypeParameterConstraint : never >T : T -type InvalidAliasTypeParameterDefault = never; +type InvalidAliasTypeParameterDefault = never; >InvalidAliasTypeParameterDefault : never >T : T // type references -declare const invalidTypeArgument: Promise; +declare const invalidTypeArgument: Promise; >invalidTypeArgument : Promise >Promise : Promise -declare const invalidArrayType: symbol()[]; +declare const invalidArrayType: unique symbol[]; >invalidArrayType : symbol[] -declare const invalidTupleType: [symbol()]; +declare const invalidTupleType: [unique symbol]; >invalidTupleType : [symbol] // mapped types -declare const invalidMappedType: { [P in string]: symbol() }; +declare const invalidMappedType: { [P in string]: unique symbol }; >invalidMappedType : { [x: string]: symbol; } >P : P // unions/intersection -declare const invalidUnion: symbol() | symbol(); +declare const invalidUnion: unique symbol | unique symbol; >invalidUnion : symbol -declare const invalidIntersection: symbol() | symbol(); +declare const invalidIntersection: unique symbol | unique symbol; >invalidIntersection : symbol diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts index e21e6eb195dc5..66b9a08169192 100644 --- a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts @@ -8,10 +8,10 @@ let letCall = Symbol(); var varCall = Symbol(); // ambient declaration with type -declare const constType: symbol(); +declare const constType: unique symbol; // declaration with type and call initializer -const constTypeAndCall: symbol() = Symbol(); +const constTypeAndCall: unique symbol = Symbol(); // declaration from initializer const constInitToConstCall = constCall; @@ -60,8 +60,8 @@ async function* asyncGenFuncYieldVarCall() { yield varCall; } // classes class C { static readonly readonlyStaticCall = Symbol(); - static readonly readonlyStaticType: symbol(); - static readonly readonlyStaticTypeAndCall: symbol() = Symbol(); + static readonly readonlyStaticType: unique symbol; + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); static readwriteStaticCall = Symbol(); readonly readonlyCall = Symbol(); @@ -88,7 +88,7 @@ const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwri // interfaces interface I { - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; } declare const i: I; @@ -98,9 +98,9 @@ const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyT // type literals type L = { - readonly readonlyType: symbol(); + readonly readonlyType: unique symbol; nested: { - readonly readonlyNestedType: symbol(); + readonly readonlyNestedType: unique symbol; } }; declare const l: L; diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts index c077d5852ad1c..a1c01538767fb 100644 --- a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts @@ -1,86 +1,86 @@ // @target: esnext // declarations -declare const {}: symbol(); -declare let invalidLetType: symbol(); -declare var invalidVarType: symbol(); +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; +declare var invalidVarType: unique symbol; // function arguments and return types -declare function invalidArgType(arg: symbol()): void; -declare function invalidRestArgType(...arg: symbol()[]): void; -declare function invalidReturnType(): symbol(); -declare function invalidThisType(this: symbol()): void; -declare function invalidTypePredicate(n: any): n is symbol(); -declare function invalidTypeParameterConstraint(): void; -declare function invalidTypeParameterDefault(): void; +declare function invalidArgType(arg: unique symbol): void; +declare function invalidRestArgType(...arg: unique symbol[]): void; +declare function invalidReturnType(): unique symbol; +declare function invalidThisType(this: unique symbol): void; +declare function invalidTypePredicate(n: any): n is unique symbol; +declare function invalidTypeParameterConstraint(): void; +declare function invalidTypeParameterDefault(): void; // classes class InvalidClass { - constructor(invalidConstructorArgType: symbol()) {} + constructor(invalidConstructorArgType: unique symbol) {} - readonly invalidReadonlyPropertyType: symbol(); - invalidPropertyType: symbol(); - invalidArgType(arg: symbol()): void { return; } - invalidRestArgType(...args: symbol()[]): void { return; } - invalidReturnType(): symbol() { return; } - invalidThisType(this: symbol()): void { return; } - invalidTypePredicate(n: any): n is symbol() { return; } - invalidTypeParameterConstraint(): void { return; } - invalidTypeParameterDefault(): void { return; } - get invalidGetter(): symbol() { return; } - set invalidSetter(arg: symbol()) { return; } + readonly invalidReadonlyPropertyType: unique symbol; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void { return; } + invalidRestArgType(...args: unique symbol[]): void { return; } + invalidReturnType(): unique symbol { return; } + invalidThisType(this: unique symbol): void { return; } + invalidTypePredicate(n: any): n is unique symbol { return; } + invalidTypeParameterConstraint(): void { return; } + invalidTypeParameterDefault(): void { return; } + get invalidGetter(): unique symbol { return; } + set invalidSetter(arg: unique symbol) { return; } - static invalidStaticPropertyType: symbol(); - static invalidStaticArgType(arg: symbol()): void { return; } - static invalidStaticRestArgType(...args: symbol()[]): void { return; } - static invalidStaticReturnType(): symbol() { return; } - static invalidStaticThisType(this: symbol()): void { return; } - static invalidStaticTypePredicate(n: any): n is symbol() { return; } - static invalidStaticTypeParameterConstraint(): void { return; } - static invalidStaticTypeParameterDefault(): void { return; } - static get invalidStaticGetter(): symbol() { return; } - static set invalidStaticSetter(arg: symbol()) { return; } + static invalidStaticPropertyType: unique symbol; + static invalidStaticArgType(arg: unique symbol): void { return; } + static invalidStaticRestArgType(...args: unique symbol[]): void { return; } + static invalidStaticReturnType(): unique symbol { return; } + static invalidStaticThisType(this: unique symbol): void { return; } + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } + static invalidStaticTypeParameterConstraint(): void { return; } + static invalidStaticTypeParameterDefault(): void { return; } + static get invalidStaticGetter(): unique symbol { return; } + static set invalidStaticSetter(arg: unique symbol) { return; } } // interfaces interface InvalidInterface { - invalidPropertyType: symbol(); - invalidArgType(arg: symbol()): void; - invalidRestArgType(...args: symbol()[]): void; - invalidReturnType(): symbol(); - invalidThisType(this: symbol()); - invalidTypePredicate(n: any): n is symbol() - invalidTypeParameterConstraint(): void; - invalidTypeParameterDefault(): void; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: unique symbol[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; } // type literals type InvalidTypeLiteral = { - invalidPropertyType: symbol(); - invalidArgType(arg: symbol()): void; - invalidRestArgType(...args: symbol()[]): void; - invalidReturnType(): symbol(); - invalidThisType(this: symbol()); - invalidTypePredicate(n: any): n is symbol() - invalidTypeParameterConstraint(): void; - invalidTypeParameterDefault(): void; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: unique symbol[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; }; // type alias -type InvalidAlias = symbol(); -type InvalidAliasTypeParameterConstraint = never; -type InvalidAliasTypeParameterDefault = never; +type InvalidAlias = unique symbol; +type InvalidAliasTypeParameterConstraint = never; +type InvalidAliasTypeParameterDefault = never; // type references -declare const invalidTypeArgument: Promise; -declare const invalidArrayType: symbol()[]; -declare const invalidTupleType: [symbol()]; +declare const invalidTypeArgument: Promise; +declare const invalidArrayType: unique symbol[]; +declare const invalidTupleType: [unique symbol]; // mapped types -declare const invalidMappedType: { [P in string]: symbol() }; +declare const invalidMappedType: { [P in string]: unique symbol }; // unions/intersection -declare const invalidUnion: symbol() | symbol(); -declare const invalidIntersection: symbol() | symbol(); +declare const invalidUnion: unique symbol | unique symbol; +declare const invalidIntersection: unique symbol | unique symbol; diff --git a/tests/cases/fourslash/completionInJSDocFunctionNew.ts b/tests/cases/fourslash/completionInJSDocFunctionNew.ts index 0d3391cf7745b..6a06ec76fe5b9 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionNew.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionNew.ts @@ -6,5 +6,5 @@ ////var f = function () { return new/**/; } goTo.marker(); -verify.completionListCount(115); +verify.completionListCount(116); verify.completionListContains('new'); diff --git a/tests/cases/fourslash/completionInJSDocFunctionThis.ts b/tests/cases/fourslash/completionInJSDocFunctionThis.ts index c28eeeb397f1c..b161b4eff68fc 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionThis.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionThis.ts @@ -5,6 +5,6 @@ ////var f = function (s) { return this/**/; } goTo.marker(); -verify.completionListCount(116); +verify.completionListCount(117); verify.completionListContains('this'); From 51ded0be7faed73b23972c90117ba50c34105153 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 4 Oct 2017 19:41:48 -0700 Subject: [PATCH 21/43] Additional tests --- .../reference/uniqueSymbolsErrors.errors.txt | 146 ++++++------ .../reference/uniqueSymbolsErrors.js | 13 +- .../reference/uniqueSymbolsErrors.symbols | 213 +++++++++--------- .../reference/uniqueSymbolsErrors.types | 15 +- .../types/uniqueSymbol/uniqueSymbolsErrors.ts | 13 +- 5 files changed, 206 insertions(+), 194 deletions(-) diff --git a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt index 356617779aa51..a8ae981e4edf9 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt +++ b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt @@ -1,66 +1,70 @@ -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(2,19): error TS1337: 'unique symbol' types may not be used on a variable declaration with a binding name. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,13): error TS1336: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(2,41): error TS1005: 'symbol' expected. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,19): error TS1337: '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 TS1336: A variable whose type is a 'unique symbol' type must be 'const'. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(7,38): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,45): error TS1331: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,39): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,40): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,53): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,59): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,50): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(17,44): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(19,14): error TS1335: 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(20,5): error TS1335: 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,25): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(22,33): error TS1331: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,26): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,27): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,40): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,46): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,37): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,26): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,28): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(31,12): error TS1335: 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(32,38): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(33,46): error TS1331: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,39): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,40): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,53): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,59): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,50): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,39): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,41): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(45,5): error TS1334: 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(46,25): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(47,33): error TS1331: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,26): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,27): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,40): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,46): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,37): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(57,5): error TS1334: 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(58,25): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(59,33): error TS1331: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,26): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,27): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,40): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,46): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,37): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(68,21): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,52): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,49): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(73,44): error TS1339: 'unique symbol' types are not allowed here. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,33): error TS1331: 'unique symbol' types are not allowed in an array type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1332: 'unique symbol' types are not allowed in a tuple type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(78,51): error TS1333: 'unique symbol' types are not allowed in a mapped type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,29): error TS1329: 'unique symbol' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(81,45): error TS1329: 'unique symbol' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,36): error TS1329: 'unique symbol' types are not allowed in a union type. -tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error TS1329: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(5,13): error TS1336: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,38): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,46): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,39): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,53): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,59): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(14,50): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(18,44): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(20,14): error TS1335: 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 TS1335: 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 TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,34): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,27): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,46): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,37): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(30,28): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(32,12): error TS1335: 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 TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,47): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,39): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,53): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,59): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,50): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,39): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(41,41): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(46,5): error TS1334: 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 TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,34): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,27): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,46): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(53,37): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(58,5): error TS1334: 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 TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,34): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,26): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,27): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,40): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,46): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(65,37): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,21): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,52): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(71,49): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,44): error TS1339: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1331: 'unique symbol' types are not allowed in an array type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(76,34): error TS1332: 'unique symbol' types are not allowed in a tuple type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(79,51): error TS1333: 'unique symbol' types are not allowed in a mapped type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,29): error TS1329: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,45): error TS1329: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,36): error TS1329: 'unique symbol' types are not allowed in a union type. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,52): error TS1329: 'unique symbol' types are not allowed in a union type. -==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts (59 errors) ==== +==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts (60 errors) ==== // declarations + declare const invalidUniqueType: unique number; + ~~~~~~ +!!! error TS1005: 'symbol' expected. declare const {}: unique symbol; ~~~~~~~~~~~~~ !!! error TS1337: 'unique symbol' types may not be used on a variable declaration with a binding name. @@ -75,8 +79,8 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error declare function invalidArgType(arg: unique symbol): void; ~~~~~~~~~~~~~ !!! error TS1339: 'unique symbol' types are not allowed here. - declare function invalidRestArgType(...arg: unique symbol[]): void; - ~~~~~~~~~~~~~ + declare function invalidRestArgType(...arg: (unique symbol)[]): void; + ~~~~~~~~~~~~~ !!! error TS1331: 'unique symbol' types are not allowed in an array type. declare function invalidReturnType(): unique symbol; ~~~~~~~~~~~~~ @@ -109,8 +113,8 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error invalidArgType(arg: unique symbol): void { return; } ~~~~~~~~~~~~~ !!! error TS1339: 'unique symbol' types are not allowed here. - invalidRestArgType(...args: unique symbol[]): void { return; } - ~~~~~~~~~~~~~ + invalidRestArgType(...args: (unique symbol)[]): void { return; } + ~~~~~~~~~~~~~ !!! error TS1331: 'unique symbol' types are not allowed in an array type. invalidReturnType(): unique symbol { return; } ~~~~~~~~~~~~~ @@ -140,8 +144,8 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error static invalidStaticArgType(arg: unique symbol): void { return; } ~~~~~~~~~~~~~ !!! error TS1339: 'unique symbol' types are not allowed here. - static invalidStaticRestArgType(...args: unique symbol[]): void { return; } - ~~~~~~~~~~~~~ + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } + ~~~~~~~~~~~~~ !!! error TS1331: 'unique symbol' types are not allowed in an array type. static invalidStaticReturnType(): unique symbol { return; } ~~~~~~~~~~~~~ @@ -174,8 +178,8 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error invalidArgType(arg: unique symbol): void; ~~~~~~~~~~~~~ !!! error TS1339: 'unique symbol' types are not allowed here. - invalidRestArgType(...args: unique symbol[]): void; - ~~~~~~~~~~~~~ + invalidRestArgType(...args: (unique symbol)[]): void; + ~~~~~~~~~~~~~ !!! error TS1331: 'unique symbol' types are not allowed in an array type. invalidReturnType(): unique symbol; ~~~~~~~~~~~~~ @@ -202,8 +206,8 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error invalidArgType(arg: unique symbol): void; ~~~~~~~~~~~~~ !!! error TS1339: 'unique symbol' types are not allowed here. - invalidRestArgType(...args: unique symbol[]): void; - ~~~~~~~~~~~~~ + invalidRestArgType(...args: (unique symbol)[]): void; + ~~~~~~~~~~~~~ !!! error TS1331: 'unique symbol' types are not allowed in an array type. invalidReturnType(): unique symbol; ~~~~~~~~~~~~~ @@ -237,8 +241,8 @@ tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,52): error declare const invalidTypeArgument: Promise; ~~~~~~~~~~~~~ !!! error TS1339: 'unique symbol' types are not allowed here. - declare const invalidArrayType: unique symbol[]; - ~~~~~~~~~~~~~ + declare const invalidArrayType: (unique symbol)[]; + ~~~~~~~~~~~~~ !!! error TS1331: 'unique symbol' types are not allowed in an array type. declare const invalidTupleType: [unique symbol]; ~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/uniqueSymbolsErrors.js b/tests/baselines/reference/uniqueSymbolsErrors.js index 0cb0427ea6453..f1e1bfaacdcde 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.js +++ b/tests/baselines/reference/uniqueSymbolsErrors.js @@ -1,12 +1,13 @@ //// [uniqueSymbolsErrors.ts] // declarations +declare const invalidUniqueType: unique number; declare const {}: unique symbol; declare let invalidLetType: unique symbol; declare var invalidVarType: unique symbol; // function arguments and return types declare function invalidArgType(arg: unique symbol): void; -declare function invalidRestArgType(...arg: unique symbol[]): void; +declare function invalidRestArgType(...arg: (unique symbol)[]): void; declare function invalidReturnType(): unique symbol; declare function invalidThisType(this: unique symbol): void; declare function invalidTypePredicate(n: any): n is unique symbol; @@ -20,7 +21,7 @@ class InvalidClass { readonly invalidReadonlyPropertyType: unique symbol; invalidPropertyType: unique symbol; invalidArgType(arg: unique symbol): void { return; } - invalidRestArgType(...args: unique symbol[]): void { return; } + invalidRestArgType(...args: (unique symbol)[]): void { return; } invalidReturnType(): unique symbol { return; } invalidThisType(this: unique symbol): void { return; } invalidTypePredicate(n: any): n is unique symbol { return; } @@ -31,7 +32,7 @@ class InvalidClass { static invalidStaticPropertyType: unique symbol; static invalidStaticArgType(arg: unique symbol): void { return; } - static invalidStaticRestArgType(...args: unique symbol[]): void { return; } + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } static invalidStaticReturnType(): unique symbol { return; } static invalidStaticThisType(this: unique symbol): void { return; } static invalidStaticTypePredicate(n: any): n is unique symbol { return; } @@ -45,7 +46,7 @@ class InvalidClass { interface InvalidInterface { invalidPropertyType: unique symbol; invalidArgType(arg: unique symbol): void; - invalidRestArgType(...args: unique symbol[]): void; + invalidRestArgType(...args: (unique symbol)[]): void; invalidReturnType(): unique symbol; invalidThisType(this: unique symbol); invalidTypePredicate(n: any): n is unique symbol @@ -57,7 +58,7 @@ interface InvalidInterface { type InvalidTypeLiteral = { invalidPropertyType: unique symbol; invalidArgType(arg: unique symbol): void; - invalidRestArgType(...args: unique symbol[]): void; + invalidRestArgType(...args: (unique symbol)[]): void; invalidReturnType(): unique symbol; invalidThisType(this: unique symbol); invalidTypePredicate(n: any): n is unique symbol @@ -72,7 +73,7 @@ type InvalidAliasTypeParameterDefault = never; // type references declare const invalidTypeArgument: Promise; -declare const invalidArrayType: unique symbol[]; +declare const invalidArrayType: (unique symbol)[]; declare const invalidTupleType: [unique symbol]; // mapped types diff --git a/tests/baselines/reference/uniqueSymbolsErrors.symbols b/tests/baselines/reference/uniqueSymbolsErrors.symbols index 2177e2db8a35c..2788870bf7c7d 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.symbols +++ b/tests/baselines/reference/uniqueSymbolsErrors.symbols @@ -1,235 +1,238 @@ === tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === // declarations +declare const invalidUniqueType: unique number; +>invalidUniqueType : Symbol(invalidUniqueType, Decl(uniqueSymbolsErrors.ts, 1, 13)) + declare const {}: unique symbol; declare let invalidLetType: unique symbol; ->invalidLetType : Symbol(invalidLetType, Decl(uniqueSymbolsErrors.ts, 2, 11)) +>invalidLetType : Symbol(invalidLetType, Decl(uniqueSymbolsErrors.ts, 3, 11)) declare var invalidVarType: unique symbol; ->invalidVarType : Symbol(invalidVarType, Decl(uniqueSymbolsErrors.ts, 3, 11)) +>invalidVarType : Symbol(invalidVarType, Decl(uniqueSymbolsErrors.ts, 4, 11)) // function arguments and return types declare function invalidArgType(arg: unique symbol): void; ->invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 3, 42)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 6, 32)) +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 4, 42)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 7, 32)) -declare function invalidRestArgType(...arg: unique symbol[]): void; ->invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 6, 58)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 7, 36)) +declare function invalidRestArgType(...arg: (unique symbol)[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 7, 58)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 8, 36)) declare function invalidReturnType(): unique symbol; ->invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 7, 67)) +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 8, 69)) declare function invalidThisType(this: unique symbol): void; ->invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 8, 52)) ->this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 9, 33)) +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 9, 52)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 10, 33)) declare function invalidTypePredicate(n: any): n is unique symbol; ->invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 9, 60)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 10, 38)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 10, 38)) +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 10, 60)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 11, 38)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 11, 38)) declare function invalidTypeParameterConstraint(): void; ->invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 10, 66)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 11, 48)) +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 11, 66)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 12, 48)) declare function invalidTypeParameterDefault(): void; ->invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 11, 81)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 12, 45)) +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 12, 81)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 13, 45)) // classes class InvalidClass { ->InvalidClass : Symbol(InvalidClass, Decl(uniqueSymbolsErrors.ts, 12, 72)) +>InvalidClass : Symbol(InvalidClass, Decl(uniqueSymbolsErrors.ts, 13, 72)) constructor(invalidConstructorArgType: unique symbol) {} ->invalidConstructorArgType : Symbol(invalidConstructorArgType, Decl(uniqueSymbolsErrors.ts, 16, 16)) +>invalidConstructorArgType : Symbol(invalidConstructorArgType, Decl(uniqueSymbolsErrors.ts, 17, 16)) readonly invalidReadonlyPropertyType: unique symbol; ->invalidReadonlyPropertyType : Symbol(InvalidClass.invalidReadonlyPropertyType, Decl(uniqueSymbolsErrors.ts, 16, 60)) +>invalidReadonlyPropertyType : Symbol(InvalidClass.invalidReadonlyPropertyType, Decl(uniqueSymbolsErrors.ts, 17, 60)) invalidPropertyType: unique symbol; ->invalidPropertyType : Symbol(InvalidClass.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 18, 56)) +>invalidPropertyType : Symbol(InvalidClass.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 19, 56)) invalidArgType(arg: unique symbol): void { return; } ->invalidArgType : Symbol(InvalidClass.invalidArgType, Decl(uniqueSymbolsErrors.ts, 19, 39)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 20, 19)) +>invalidArgType : Symbol(InvalidClass.invalidArgType, Decl(uniqueSymbolsErrors.ts, 20, 39)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 21, 19)) - invalidRestArgType(...args: unique symbol[]): void { return; } ->invalidRestArgType : Symbol(InvalidClass.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 20, 56)) ->args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 21, 23)) + invalidRestArgType(...args: (unique symbol)[]): void { return; } +>invalidRestArgType : Symbol(InvalidClass.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 21, 56)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 22, 23)) invalidReturnType(): unique symbol { return; } ->invalidReturnType : Symbol(InvalidClass.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 21, 66)) +>invalidReturnType : Symbol(InvalidClass.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 22, 68)) invalidThisType(this: unique symbol): void { return; } ->invalidThisType : Symbol(InvalidClass.invalidThisType, Decl(uniqueSymbolsErrors.ts, 22, 50)) ->this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 23, 20)) +>invalidThisType : Symbol(InvalidClass.invalidThisType, Decl(uniqueSymbolsErrors.ts, 23, 50)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 24, 20)) invalidTypePredicate(n: any): n is unique symbol { return; } ->invalidTypePredicate : Symbol(InvalidClass.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 23, 58)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 24, 25)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 24, 25)) +>invalidTypePredicate : Symbol(InvalidClass.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 24, 58)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 25, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 25, 25)) invalidTypeParameterConstraint(): void { return; } ->invalidTypeParameterConstraint : Symbol(InvalidClass.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 24, 64)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 25, 35)) +>invalidTypeParameterConstraint : Symbol(InvalidClass.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 25, 64)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 26, 35)) invalidTypeParameterDefault(): void { return; } ->invalidTypeParameterDefault : Symbol(InvalidClass.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 25, 79)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 26, 32)) +>invalidTypeParameterDefault : Symbol(InvalidClass.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 26, 79)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 27, 32)) get invalidGetter(): unique symbol { return; } ->invalidGetter : Symbol(InvalidClass.invalidGetter, Decl(uniqueSymbolsErrors.ts, 26, 70)) +>invalidGetter : Symbol(InvalidClass.invalidGetter, Decl(uniqueSymbolsErrors.ts, 27, 70)) set invalidSetter(arg: unique symbol) { return; } ->invalidSetter : Symbol(InvalidClass.invalidSetter, Decl(uniqueSymbolsErrors.ts, 27, 50)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 28, 22)) +>invalidSetter : Symbol(InvalidClass.invalidSetter, Decl(uniqueSymbolsErrors.ts, 28, 50)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 29, 22)) static invalidStaticPropertyType: unique symbol; ->invalidStaticPropertyType : Symbol(InvalidClass.invalidStaticPropertyType, Decl(uniqueSymbolsErrors.ts, 28, 53)) +>invalidStaticPropertyType : Symbol(InvalidClass.invalidStaticPropertyType, Decl(uniqueSymbolsErrors.ts, 29, 53)) static invalidStaticArgType(arg: unique symbol): void { return; } ->invalidStaticArgType : Symbol(InvalidClass.invalidStaticArgType, Decl(uniqueSymbolsErrors.ts, 30, 52)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 31, 32)) +>invalidStaticArgType : Symbol(InvalidClass.invalidStaticArgType, Decl(uniqueSymbolsErrors.ts, 31, 52)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 32, 32)) - static invalidStaticRestArgType(...args: unique symbol[]): void { return; } ->invalidStaticRestArgType : Symbol(InvalidClass.invalidStaticRestArgType, Decl(uniqueSymbolsErrors.ts, 31, 69)) ->args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 32, 36)) + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } +>invalidStaticRestArgType : Symbol(InvalidClass.invalidStaticRestArgType, Decl(uniqueSymbolsErrors.ts, 32, 69)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 33, 36)) static invalidStaticReturnType(): unique symbol { return; } ->invalidStaticReturnType : Symbol(InvalidClass.invalidStaticReturnType, Decl(uniqueSymbolsErrors.ts, 32, 79)) +>invalidStaticReturnType : Symbol(InvalidClass.invalidStaticReturnType, Decl(uniqueSymbolsErrors.ts, 33, 81)) static invalidStaticThisType(this: unique symbol): void { return; } ->invalidStaticThisType : Symbol(InvalidClass.invalidStaticThisType, Decl(uniqueSymbolsErrors.ts, 33, 63)) ->this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 34, 33)) +>invalidStaticThisType : Symbol(InvalidClass.invalidStaticThisType, Decl(uniqueSymbolsErrors.ts, 34, 63)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 35, 33)) static invalidStaticTypePredicate(n: any): n is unique symbol { return; } ->invalidStaticTypePredicate : Symbol(InvalidClass.invalidStaticTypePredicate, Decl(uniqueSymbolsErrors.ts, 34, 71)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 35, 38)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 35, 38)) +>invalidStaticTypePredicate : Symbol(InvalidClass.invalidStaticTypePredicate, Decl(uniqueSymbolsErrors.ts, 35, 71)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 36, 38)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 36, 38)) static invalidStaticTypeParameterConstraint(): void { return; } ->invalidStaticTypeParameterConstraint : Symbol(InvalidClass.invalidStaticTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 35, 77)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 36, 48)) +>invalidStaticTypeParameterConstraint : Symbol(InvalidClass.invalidStaticTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 36, 77)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 37, 48)) static invalidStaticTypeParameterDefault(): void { return; } ->invalidStaticTypeParameterDefault : Symbol(InvalidClass.invalidStaticTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 36, 92)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 37, 45)) +>invalidStaticTypeParameterDefault : Symbol(InvalidClass.invalidStaticTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 37, 92)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 38, 45)) static get invalidStaticGetter(): unique symbol { return; } ->invalidStaticGetter : Symbol(InvalidClass.invalidStaticGetter, Decl(uniqueSymbolsErrors.ts, 37, 83)) +>invalidStaticGetter : Symbol(InvalidClass.invalidStaticGetter, Decl(uniqueSymbolsErrors.ts, 38, 83)) static set invalidStaticSetter(arg: unique symbol) { return; } ->invalidStaticSetter : Symbol(InvalidClass.invalidStaticSetter, Decl(uniqueSymbolsErrors.ts, 38, 63)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 39, 35)) +>invalidStaticSetter : Symbol(InvalidClass.invalidStaticSetter, Decl(uniqueSymbolsErrors.ts, 39, 63)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 40, 35)) } // interfaces interface InvalidInterface { ->InvalidInterface : Symbol(InvalidInterface, Decl(uniqueSymbolsErrors.ts, 40, 1)) +>InvalidInterface : Symbol(InvalidInterface, Decl(uniqueSymbolsErrors.ts, 41, 1)) invalidPropertyType: unique symbol; ->invalidPropertyType : Symbol(InvalidInterface.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 43, 28)) +>invalidPropertyType : Symbol(InvalidInterface.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 44, 28)) invalidArgType(arg: unique symbol): void; ->invalidArgType : Symbol(InvalidInterface.invalidArgType, Decl(uniqueSymbolsErrors.ts, 44, 39)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 45, 19)) +>invalidArgType : Symbol(InvalidInterface.invalidArgType, Decl(uniqueSymbolsErrors.ts, 45, 39)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 46, 19)) - invalidRestArgType(...args: unique symbol[]): void; ->invalidRestArgType : Symbol(InvalidInterface.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 45, 45)) ->args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 46, 23)) + invalidRestArgType(...args: (unique symbol)[]): void; +>invalidRestArgType : Symbol(InvalidInterface.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 46, 45)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 47, 23)) invalidReturnType(): unique symbol; ->invalidReturnType : Symbol(InvalidInterface.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 46, 55)) +>invalidReturnType : Symbol(InvalidInterface.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 47, 57)) invalidThisType(this: unique symbol); ->invalidThisType : Symbol(InvalidInterface.invalidThisType, Decl(uniqueSymbolsErrors.ts, 47, 39)) ->this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 48, 20)) +>invalidThisType : Symbol(InvalidInterface.invalidThisType, Decl(uniqueSymbolsErrors.ts, 48, 39)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 49, 20)) invalidTypePredicate(n: any): n is unique symbol ->invalidTypePredicate : Symbol(InvalidInterface.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 48, 41)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 49, 25)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 49, 25)) +>invalidTypePredicate : Symbol(InvalidInterface.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 49, 41)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 50, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 50, 25)) invalidTypeParameterConstraint(): void; ->invalidTypeParameterConstraint : Symbol(InvalidInterface.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 49, 52)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 50, 35)) +>invalidTypeParameterConstraint : Symbol(InvalidInterface.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 50, 52)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 51, 35)) invalidTypeParameterDefault(): void; ->invalidTypeParameterDefault : Symbol(InvalidInterface.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 50, 68)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 51, 32)) +>invalidTypeParameterDefault : Symbol(InvalidInterface.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 51, 68)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 52, 32)) } // type literals type InvalidTypeLiteral = { ->InvalidTypeLiteral : Symbol(InvalidTypeLiteral, Decl(uniqueSymbolsErrors.ts, 52, 1)) +>InvalidTypeLiteral : Symbol(InvalidTypeLiteral, Decl(uniqueSymbolsErrors.ts, 53, 1)) invalidPropertyType: unique symbol; ->invalidPropertyType : Symbol(invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 55, 27)) +>invalidPropertyType : Symbol(invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 56, 27)) invalidArgType(arg: unique symbol): void; ->invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 56, 39)) ->arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 57, 19)) +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 57, 39)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 58, 19)) - invalidRestArgType(...args: unique symbol[]): void; ->invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 57, 45)) ->args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 58, 23)) + invalidRestArgType(...args: (unique symbol)[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 58, 45)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 59, 23)) invalidReturnType(): unique symbol; ->invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 58, 55)) +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 59, 57)) invalidThisType(this: unique symbol); ->invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 59, 39)) ->this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 60, 20)) +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 60, 39)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 61, 20)) invalidTypePredicate(n: any): n is unique symbol ->invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 60, 41)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 61, 25)) ->n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 61, 25)) +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 61, 41)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 62, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 62, 25)) invalidTypeParameterConstraint(): void; ->invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 61, 52)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 62, 35)) +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 62, 52)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 63, 35)) invalidTypeParameterDefault(): void; ->invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 62, 68)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 63, 32)) +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 63, 68)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 64, 32)) }; // type alias type InvalidAlias = unique symbol; ->InvalidAlias : Symbol(InvalidAlias, Decl(uniqueSymbolsErrors.ts, 64, 2)) +>InvalidAlias : Symbol(InvalidAlias, Decl(uniqueSymbolsErrors.ts, 65, 2)) type InvalidAliasTypeParameterConstraint = never; ->InvalidAliasTypeParameterConstraint : Symbol(InvalidAliasTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 67, 34)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 68, 41)) +>InvalidAliasTypeParameterConstraint : Symbol(InvalidAliasTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 68, 34)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 69, 41)) type InvalidAliasTypeParameterDefault = never; ->InvalidAliasTypeParameterDefault : Symbol(InvalidAliasTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 68, 74)) ->T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 69, 38)) +>InvalidAliasTypeParameterDefault : Symbol(InvalidAliasTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 69, 74)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 70, 38)) // type references declare const invalidTypeArgument: Promise; ->invalidTypeArgument : Symbol(invalidTypeArgument, Decl(uniqueSymbolsErrors.ts, 72, 13)) +>invalidTypeArgument : Symbol(invalidTypeArgument, Decl(uniqueSymbolsErrors.ts, 73, 13)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -declare const invalidArrayType: unique symbol[]; ->invalidArrayType : Symbol(invalidArrayType, Decl(uniqueSymbolsErrors.ts, 73, 13)) +declare const invalidArrayType: (unique symbol)[]; +>invalidArrayType : Symbol(invalidArrayType, Decl(uniqueSymbolsErrors.ts, 74, 13)) declare const invalidTupleType: [unique symbol]; ->invalidTupleType : Symbol(invalidTupleType, Decl(uniqueSymbolsErrors.ts, 74, 13)) +>invalidTupleType : Symbol(invalidTupleType, Decl(uniqueSymbolsErrors.ts, 75, 13)) // mapped types declare const invalidMappedType: { [P in string]: unique symbol }; ->invalidMappedType : Symbol(invalidMappedType, Decl(uniqueSymbolsErrors.ts, 77, 13)) ->P : Symbol(P, Decl(uniqueSymbolsErrors.ts, 77, 36)) +>invalidMappedType : Symbol(invalidMappedType, Decl(uniqueSymbolsErrors.ts, 78, 13)) +>P : Symbol(P, Decl(uniqueSymbolsErrors.ts, 78, 36)) // unions/intersection declare const invalidUnion: unique symbol | unique symbol; ->invalidUnion : Symbol(invalidUnion, Decl(uniqueSymbolsErrors.ts, 80, 13)) +>invalidUnion : Symbol(invalidUnion, Decl(uniqueSymbolsErrors.ts, 81, 13)) declare const invalidIntersection: unique symbol | unique symbol; ->invalidIntersection : Symbol(invalidIntersection, Decl(uniqueSymbolsErrors.ts, 81, 13)) +>invalidIntersection : Symbol(invalidIntersection, Decl(uniqueSymbolsErrors.ts, 82, 13)) diff --git a/tests/baselines/reference/uniqueSymbolsErrors.types b/tests/baselines/reference/uniqueSymbolsErrors.types index d593b0c24ac8b..20eda66b9ef8f 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.types +++ b/tests/baselines/reference/uniqueSymbolsErrors.types @@ -1,5 +1,8 @@ === tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === // declarations +declare const invalidUniqueType: unique number; +>invalidUniqueType : any + declare const {}: unique symbol; declare let invalidLetType: unique symbol; >invalidLetType : symbol @@ -12,7 +15,7 @@ declare function invalidArgType(arg: unique symbol): void; >invalidArgType : (arg: symbol) => void >arg : symbol -declare function invalidRestArgType(...arg: unique symbol[]): void; +declare function invalidRestArgType(...arg: (unique symbol)[]): void; >invalidRestArgType : (...arg: symbol[]) => void >arg : symbol[] @@ -53,7 +56,7 @@ class InvalidClass { >invalidArgType : (arg: symbol) => void >arg : symbol - invalidRestArgType(...args: unique symbol[]): void { return; } + invalidRestArgType(...args: (unique symbol)[]): void { return; } >invalidRestArgType : (...args: symbol[]) => void >args : symbol[] @@ -91,7 +94,7 @@ class InvalidClass { >invalidStaticArgType : (arg: symbol) => void >arg : symbol - static invalidStaticRestArgType(...args: unique symbol[]): void { return; } + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } >invalidStaticRestArgType : (...args: symbol[]) => void >args : symbol[] @@ -134,7 +137,7 @@ interface InvalidInterface { >invalidArgType : (arg: symbol) => void >arg : symbol - invalidRestArgType(...args: unique symbol[]): void; + invalidRestArgType(...args: (unique symbol)[]): void; >invalidRestArgType : (...args: symbol[]) => void >args : symbol[] @@ -170,7 +173,7 @@ type InvalidTypeLiteral = { >invalidArgType : (arg: symbol) => void >arg : symbol - invalidRestArgType(...args: unique symbol[]): void; + invalidRestArgType(...args: (unique symbol)[]): void; >invalidRestArgType : (...args: symbol[]) => void >args : symbol[] @@ -213,7 +216,7 @@ declare const invalidTypeArgument: Promise; >invalidTypeArgument : Promise >Promise : Promise -declare const invalidArrayType: unique symbol[]; +declare const invalidArrayType: (unique symbol)[]; >invalidArrayType : symbol[] declare const invalidTupleType: [unique symbol]; diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts index a1c01538767fb..505efcc4e14ab 100644 --- a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts @@ -1,13 +1,14 @@ // @target: esnext // declarations +declare const invalidUniqueType: unique number; declare const {}: unique symbol; declare let invalidLetType: unique symbol; declare var invalidVarType: unique symbol; // function arguments and return types declare function invalidArgType(arg: unique symbol): void; -declare function invalidRestArgType(...arg: unique symbol[]): void; +declare function invalidRestArgType(...arg: (unique symbol)[]): void; declare function invalidReturnType(): unique symbol; declare function invalidThisType(this: unique symbol): void; declare function invalidTypePredicate(n: any): n is unique symbol; @@ -21,7 +22,7 @@ class InvalidClass { readonly invalidReadonlyPropertyType: unique symbol; invalidPropertyType: unique symbol; invalidArgType(arg: unique symbol): void { return; } - invalidRestArgType(...args: unique symbol[]): void { return; } + invalidRestArgType(...args: (unique symbol)[]): void { return; } invalidReturnType(): unique symbol { return; } invalidThisType(this: unique symbol): void { return; } invalidTypePredicate(n: any): n is unique symbol { return; } @@ -32,7 +33,7 @@ class InvalidClass { static invalidStaticPropertyType: unique symbol; static invalidStaticArgType(arg: unique symbol): void { return; } - static invalidStaticRestArgType(...args: unique symbol[]): void { return; } + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } static invalidStaticReturnType(): unique symbol { return; } static invalidStaticThisType(this: unique symbol): void { return; } static invalidStaticTypePredicate(n: any): n is unique symbol { return; } @@ -46,7 +47,7 @@ class InvalidClass { interface InvalidInterface { invalidPropertyType: unique symbol; invalidArgType(arg: unique symbol): void; - invalidRestArgType(...args: unique symbol[]): void; + invalidRestArgType(...args: (unique symbol)[]): void; invalidReturnType(): unique symbol; invalidThisType(this: unique symbol); invalidTypePredicate(n: any): n is unique symbol @@ -58,7 +59,7 @@ interface InvalidInterface { type InvalidTypeLiteral = { invalidPropertyType: unique symbol; invalidArgType(arg: unique symbol): void; - invalidRestArgType(...args: unique symbol[]): void; + invalidRestArgType(...args: (unique symbol)[]): void; invalidReturnType(): unique symbol; invalidThisType(this: unique symbol); invalidTypePredicate(n: any): n is unique symbol @@ -73,7 +74,7 @@ type InvalidAliasTypeParameterDefault = never; // type references declare const invalidTypeArgument: Promise; -declare const invalidArrayType: unique symbol[]; +declare const invalidArrayType: (unique symbol)[]; declare const invalidTupleType: [unique symbol]; // mapped types From fea6a87965574e7003ee0f8c335b8b5f5dc263e6 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 4 Oct 2017 20:39:02 -0700 Subject: [PATCH 22/43] General tidying up and comments. --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 249 +++++++++-------- src/compiler/types.ts | 17 +- .../reference/api/tsserverlibrary.d.ts | 256 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 256 +++++++++--------- 5 files changed, 405 insertions(+), 375 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 796c960342384..7e5330d2844ea 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1678,7 +1678,7 @@ namespace ts { function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: __String) { const symbol = createSymbol(symbolFlags, name); - if (symbolFlags & SymbolFlags.EnumMember) { + if (symbolFlags & (SymbolFlags.EnumMember | SymbolFlags.ClassMember)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2653b822a5f2a..a8e4bef670fca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -34,9 +34,6 @@ namespace ts { (preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly); } - type LateBoundName = ComputedPropertyName & { expression: EntityNameExpression; }; - type LateBoundDeclaration = Declaration & { name: LateBoundName; }; - export function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker { // Cancellation that controls whether or not we can cancel in the middle of type checking. // In general cancelling is *not* safe for the type checker. We might be in the middle of @@ -3525,7 +3522,7 @@ namespace ts { } if (prop.flags & SymbolFlags.Late) { const decl = firstOrUndefined(prop.declarations); - const name = hasLateBoundName(decl) && resolveEntityName(decl.name.expression, SymbolFlags.Value); + const name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, SymbolFlags.Value); if (name) { writer.trackSymbol(name, enclosingDeclaration, SymbolFlags.Value); } @@ -4340,7 +4337,7 @@ namespace ts { if (declaration.kind === SyntaxKind.Parameter) { const func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === SyntaxKind.SetAccessor && !hasUnboundDynamicName(func)) { + if (func.kind === SyntaxKind.SetAccessor && !hasNonBindableDynamicName(func)) { const getter = getDeclarationOfKind(getSymbolOfNode(declaration.parent), SyntaxKind.GetAccessor); if (getter) { const getterSignature = getSignatureFromDeclaration(getter); @@ -5446,80 +5443,46 @@ namespace ts { } /** - * Gets a SymbolTable containing both the early- and late-bound members of a symbol. - */ - function getMembersOfSymbol(symbol: Symbol) { - const links = getSymbolLinks(symbol); - if (!links.resolvedMembers) { - links.resolvedMembers = emptySymbols; - const lateMembers = getLateBoundMembersOfSymbol(symbol); - if (lateMembers) { - for (const decl of symbol.declarations) { - lateBindMembers(lateMembers, decl); - } - } - links.resolvedMembers = combineSymbolTables(symbol.members, lateMembers) || emptySymbols; - } - return links.resolvedMembers; - } - - /** - * Gets the late-bound members of a symbol. + * Indicates whether a type can be used as a late-bound name. */ - function getLateBoundMembersOfSymbol(symbol: Symbol): UnderscoreEscapedMap | undefined { - if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral)) { - const links = getSymbolLinks(symbol); - return links.lateMembers || (links.lateMembers = createUnderscoreEscapedMap()); - } - } - - /** - * Tests whether a declaration has a late-bound dynamic name. - */ - function hasLateBoundName(node: Declaration): node is LateBoundDeclaration { - const name = getNameOfDeclaration(node); - return name && isLateBoundName(name); + function isTypeUsableAsLateBoundName(type: Type): type is LiteralType | UniqueESSymbolType { + return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique); } /** - * Tests whether a declaration name is definitely late-bindable. + * Indicates whether a declaration name is definitely late-bindable. + * A declaration name is only late-bindable if: + * - It is a `ComputedPropertyName`. + * - Its expression is either an `Identifier` or is a `PropertyAccessExpression` consisting only of + * other `PropertyAccessExpression` or `Identifier` nodes. + * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ - function isLateBoundName(node: DeclarationName): node is LateBoundName { + function isLateBindableName(node: DeclarationName): node is LateBoundName { return isComputedPropertyName(node) && isEntityNameExpression(node.expression) - && isLateBoundNameType(checkComputedPropertyName(node)); - } - - function isLateBoundNameType(type: Type): type is LiteralType | UniqueESSymbolType { - return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique); + && isTypeUsableAsLateBoundName(checkComputedPropertyName(node)); } /** - * Performs late-binding of the dynamic members of a declaration. + * Indicates whether a declaration has a late-bindable dynamic name. */ - function lateBindMembers(lateMembers: UnderscoreEscapedMap, node: Declaration) { - const members = getMembersOfDeclaration(node); - if (members) { - for (const member of members) { - if (hasLateBoundName(member)) { - lateBindMember(lateMembers, node.symbol, member); - } - } - } + function hasLateBindableName(node: Declaration): node is LateBoundDeclaration { + const name = getNameOfDeclaration(node); + return name && isLateBindableName(name); } /** - * Tests whether a declaration has a dynamic name that cannot be late-bound. + * Indicates whether a declaration has a dynamic name that cannot be late-bound. */ - function hasUnboundDynamicName(node: Declaration) { - return hasDynamicName(node) && !hasLateBoundName(node); + function hasNonBindableDynamicName(node: Declaration) { + return hasDynamicName(node) && !hasLateBindableName(node); } /** - * Tests whether a declaration name is a dynamic name that cannot be late-bound. + * Indicates whether a declaration name is a dynamic name that cannot be late-bound. */ - function isUnboundDynamicName(node: DeclarationName) { - return isDynamicName(node) && !isLateBoundName(node); + function isNonBindableDynamicName(node: DeclarationName) { + return isDynamicName(node) && !isLateBindableName(node); } /** @@ -5535,52 +5498,73 @@ namespace ts { } /** - * Gets the late-bound symbol for a symbol (if it has one). + * Gets the symbol table used to store members added during late-binding. + * This table is filled in as the late-bound names for dynamic members are resolved. */ - function getLateBoundSymbol(symbol: Symbol) { - if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.escapedName === InternalSymbolName.Computed) { - const links = getSymbolLinks(symbol); - if (!links.lateSymbol) { - links.lateSymbol = symbol; - const parent = symbol.parent; - if (parent && (parent.flags & SymbolFlags.HasMembers)) { - const lateMembers = getLateBoundMembersOfSymbol(parent); - for (const decl of symbol.declarations) { - if (hasLateBoundName(decl)) { - lateBindMember(lateMembers, parent, decl); - } - } - } + function getLateBoundMembersOfSymbol(symbol: Symbol): SymbolTable { + Debug.assert(!!(symbol.flags & SymbolFlags.LateBindableContainer), "Expected a container that supports late-binding."); + const links = getSymbolLinks(symbol); + return links.lateMembers || (links.lateMembers = createSymbolTable()); + } + + /** + * Adds a declaration to a late-bound dynamic member. This performs the same function for + * late-bound members that `addDeclarationToSymbol` in binder.ts performs for early-bound + * members. + */ + function addDeclarationToLateBoundMember(symbol: Symbol, member: LateBoundDeclaration, symbolFlags: SymbolFlags) { + Debug.assert(!!(symbol.flags & SymbolFlags.Late), "Expected a late-bound symbol."); + symbol.flags |= symbolFlags; + getSymbolLinks(member.symbol).lateSymbol = symbol; + if (!symbol.declarations) { + symbol.declarations = [member]; + } + else { + symbol.declarations.push(member); + } + if (symbolFlags & SymbolFlags.Value) { + const valueDeclaration = symbol.valueDeclaration; + if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + symbol.valueDeclaration = member; } - return links.lateSymbol; } - return symbol; } /** - * Performs late-binding of a dynamic member. + * Performs late-binding of a dynamic member. This performs the same function for + * late-bound members that `declareSymbol` in binder.ts performs for early-bound + * members. */ - function lateBindMember(lateMembers: UnderscoreEscapedMap, parent: Symbol, member: LateBoundDeclaration) { + function lateBindMember(lateMembers: SymbolTable, parent: Symbol, member: LateBoundDeclaration) { + Debug.assert(!!member.symbol, "The member is expected to have a symbol."); const links = getNodeLinks(member); if (!links.resolvedSymbol) { - const memberSymbol = member.symbol; - links.resolvedSymbol = memberSymbol || unknownSymbol; + // In the event we attempt to resolve the late-bound name of this member recursively, + // fall back to the early-bound name of this member. + links.resolvedSymbol = member.symbol; const type = checkComputedPropertyName(member.name); - if (isLateBoundNameType(type)) { + if (isTypeUsableAsLateBoundName(type)) { const memberName = getLateBoundNameFromType(type); + + // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. let symbol = lateMembers.get(memberName); - if (!symbol) { - lateMembers.set(memberName, symbol = createSymbol(SymbolFlags.Late, memberName)); - } - const staticMember = parent.members && parent.members.get(memberName); - if (symbol.flags & getExcludedSymbolFlags(memberSymbol.flags) || staticMember) { - const declarations = staticMember ? concatenate(staticMember.declarations, symbol.declarations) : symbol.declarations; + if (!symbol) lateMembers.set(memberName, symbol = createSymbol(SymbolFlags.Late, memberName)); + + // Report an error if a late-bound member has the same name as an early-bound member, + // or if we have another early-bound symbol declaration with the same name and + // conflicting flags. + const earlyMember = parent.members && parent.members.get(memberName); + if (symbol.flags & getExcludedSymbolFlags(member.symbol.flags) || earlyMember) { + // If we have an existing early-bound member, combine its declarations so that we can + // report an error at each declaration. + const declarations = earlyMember ? concatenate(earlyMember.declarations, symbol.declarations) : symbol.declarations; const name = declarationNameToString(member.name); forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name)); error(member.name || member, Diagnostics.Duplicate_declaration_0, name); symbol = createSymbol(SymbolFlags.Late, memberName); } - addDeclarationToLateBoundMember(symbol, member, memberSymbol.flags); + + addDeclarationToLateBoundMember(symbol, member, member.symbol.flags); symbol.parent = parent; return links.resolvedSymbol = symbol; } @@ -5589,23 +5573,62 @@ namespace ts { } /** - * Adds a declaration to a late-bound dynamic member. + * Gets a SymbolTable containing both the early- and late-bound members of a symbol. */ - function addDeclarationToLateBoundMember(symbol: TransientSymbol, member: LateBoundDeclaration, symbolFlags: SymbolFlags) { - symbol.flags |= symbolFlags; - getSymbolLinks(member.symbol).lateSymbol = symbol; - if (!symbol.declarations) { - symbol.declarations = [member]; - } - else { - symbol.declarations.push(member); + function getMembersOfSymbol(symbol: Symbol) { + if (symbol.flags & SymbolFlags.LateBindableContainer) { + const links = getSymbolLinks(symbol); + if (!links.resolvedMembers) { + // In the event we recursively resolve the members of the symbol, we + // should only see the early-bound members of the symbol here. + links.resolvedMembers = symbol.members || emptySymbols; + + // fill in any as-yet-unresolved late-bound members. + const lateMembers = getLateBoundMembersOfSymbol(symbol); + for (const decl of symbol.declarations) { + const members = getMembersOfDeclaration(decl); + if (members) { + for (const member of members) { + if (hasLateBindableName(member)) { + lateBindMember(lateMembers, decl.symbol, member); + } + } + } + } + links.resolvedMembers = combineSymbolTables(symbol.members, lateMembers) || emptySymbols; + } + return links.resolvedMembers; } - if (symbolFlags & SymbolFlags.Value) { - const valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || valueDeclaration.kind !== member.kind) { - symbol.valueDeclaration = member; + return symbol.members || emptySymbols; + } + + /** + * Gets the late-bound symbol for a symbol (if it has one). The symbol is + * resolved dynamically but allows accessors to share the same symbol. + * + * We do not aggressively resolve the entire late-bound symbol table here as + * that requires a type-check on every computed property name. + */ + function getLateBoundSymbol(symbol: Symbol) { + if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.escapedName === InternalSymbolName.Computed && + symbol.parent && (symbol.parent.flags & SymbolFlags.LateBindableContainer)) { + const links = getSymbolLinks(symbol); + if (!links.lateSymbol) { + // In the event we attempt to get the late-bound symbol for a symbol recursively, + // fall back to the early-bound symbol. + links.lateSymbol = symbol; + + // Fill in the late-bound symbol for each declaration of this symbol. + const lateMembers = getLateBoundMembersOfSymbol(symbol.parent); + for (const decl of symbol.declarations) { + if (hasLateBindableName(decl)) { + lateBindMember(lateMembers, symbol.parent, decl); + } + } } + return links.lateSymbol; } + return symbol; } function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { @@ -6649,7 +6672,7 @@ namespace ts { // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation if ((declaration.kind === SyntaxKind.GetAccessor || declaration.kind === SyntaxKind.SetAccessor) && - !hasUnboundDynamicName(declaration) && + !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { const otherKind = declaration.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; const other = getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); @@ -6696,7 +6719,7 @@ namespace ts { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === SyntaxKind.GetAccessor && !hasUnboundDynamicName(declaration)) { + if (declaration.kind === SyntaxKind.GetAccessor && !hasNonBindableDynamicName(declaration)) { const setter = getDeclarationOfKind(getSymbolOfNode(declaration), SyntaxKind.SetAccessor); return getAnnotatedAccessorType(setter); } @@ -7853,7 +7876,7 @@ namespace ts { function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode, cacheSymbol: boolean) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; - const propName = isLateBoundNameType(indexType) ? getLateBoundNameFromType(indexType) : + const propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? getPropertyNameForKnownSymbolName(idText(((accessExpression.argumentExpression).name))) : undefined; @@ -13585,7 +13608,7 @@ namespace ts { const objectLiteral = element.parent; const type = getApparentTypeOfContextualType(objectLiteral); if (type) { - if (!hasUnboundDynamicName(element)) { + if (!hasNonBindableDynamicName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -14072,9 +14095,9 @@ namespace ts { typeFlags |= type.flags; let prop: TransientSymbol; - if (hasLateBoundName(memberDecl)) { + if (hasLateBindableName(memberDecl)) { const nameType = checkComputedPropertyName(memberDecl.name); - if (nameType && isLateBoundNameType(nameType)) { + if (nameType && isTypeUsableAsLateBoundName(nameType)) { prop = createSymbol(SymbolFlags.Property | SymbolFlags.Late | member.flags, getLateBoundNameFromType(nameType)); } } @@ -14150,7 +14173,7 @@ namespace ts { checkNodeDeferred(memberDecl); } - if (!literalName && hasUnboundDynamicName(memberDecl)) { + if (!literalName && hasNonBindableDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -19261,7 +19284,7 @@ namespace ts { if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkComputedPropertyName(node.name); } - if (!hasUnboundDynamicName(node)) { + if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; @@ -20319,7 +20342,7 @@ namespace ts { checkComputedPropertyName(node.name); } - if (!hasUnboundDynamicName(node)) { + if (!hasNonBindableDynamicName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -21729,7 +21752,7 @@ namespace ts { // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!hasModifier(member, ModifierFlags.Static) && hasUnboundDynamicName(member)) { + if (!hasModifier(member, ModifierFlags.Static) && hasNonBindableDynamicName(member)) { const symbol = getSymbolOfNode(member); const propType = getTypeOfSymbol(symbol); checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); @@ -25399,7 +25422,7 @@ namespace ts { } function checkGrammarForInvalidDynamicName(node: DeclarationName, message: DiagnosticMessage) { - if (isUnboundDynamicName(node)) { + if (isNonBindableDynamicName(node)) { return grammarErrorOnNode(node, message); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a8e8e79e49397..c06aa571bfc9f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -662,6 +662,12 @@ namespace ts { name?: DeclarationName; } + /* @internal */ + // A declaration that supports late-binding (used in checker) + export interface LateBoundDeclaration extends NamedDeclaration { + name: LateBoundName; + } + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } @@ -671,6 +677,12 @@ namespace ts { expression: Expression; } + /* @internal */ + // A name that supports late-binding (used in checker) + export interface LateBoundName extends ComputedPropertyName { + expression: EntityNameExpression; + } + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent?: NamedDeclaration; @@ -3008,6 +3020,9 @@ namespace ts { // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module, + + /* @internal */ + LateBindableContainer = Class | Interface | TypeLiteral | ObjectLiteral, } export interface Symbol { @@ -3053,7 +3068,7 @@ namespace ts { exportsSomeValue?: boolean; // True if module exports some value (not just types) enumKind?: EnumKind; // Enum declaration classification lateSymbol?: Symbol; // Late-bound symbol for a computed property - lateMembers?: UnderscoreEscapedMap; // Late-bound members resolved during check + lateMembers?: SymbolTable; // Late-bound members resolved during check resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 63f60edb2dc22..6ec91ef65bc82 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -235,126 +235,125 @@ declare namespace ts { IndexedAccessType = 172, MappedType = 173, LiteralType = 174, - UniqueESSymbolType = 175, - ObjectBindingPattern = 176, - ArrayBindingPattern = 177, - BindingElement = 178, - ArrayLiteralExpression = 179, - ObjectLiteralExpression = 180, - PropertyAccessExpression = 181, - ElementAccessExpression = 182, - CallExpression = 183, - NewExpression = 184, - TaggedTemplateExpression = 185, - TypeAssertionExpression = 186, - ParenthesizedExpression = 187, - FunctionExpression = 188, - ArrowFunction = 189, - DeleteExpression = 190, - TypeOfExpression = 191, - VoidExpression = 192, - AwaitExpression = 193, - PrefixUnaryExpression = 194, - PostfixUnaryExpression = 195, - BinaryExpression = 196, - ConditionalExpression = 197, - TemplateExpression = 198, - YieldExpression = 199, - SpreadElement = 200, - ClassExpression = 201, - OmittedExpression = 202, - ExpressionWithTypeArguments = 203, - AsExpression = 204, - NonNullExpression = 205, - MetaProperty = 206, - TemplateSpan = 207, - SemicolonClassElement = 208, - Block = 209, - VariableStatement = 210, - EmptyStatement = 211, - ExpressionStatement = 212, - IfStatement = 213, - DoStatement = 214, - WhileStatement = 215, - ForStatement = 216, - ForInStatement = 217, - ForOfStatement = 218, - ContinueStatement = 219, - BreakStatement = 220, - ReturnStatement = 221, - WithStatement = 222, - SwitchStatement = 223, - LabeledStatement = 224, - ThrowStatement = 225, - TryStatement = 226, - DebuggerStatement = 227, - VariableDeclaration = 228, - VariableDeclarationList = 229, - FunctionDeclaration = 230, - ClassDeclaration = 231, - InterfaceDeclaration = 232, - TypeAliasDeclaration = 233, - EnumDeclaration = 234, - ModuleDeclaration = 235, - ModuleBlock = 236, - CaseBlock = 237, - NamespaceExportDeclaration = 238, - ImportEqualsDeclaration = 239, - ImportDeclaration = 240, - ImportClause = 241, - NamespaceImport = 242, - NamedImports = 243, - ImportSpecifier = 244, - ExportAssignment = 245, - ExportDeclaration = 246, - NamedExports = 247, - ExportSpecifier = 248, - MissingDeclaration = 249, - ExternalModuleReference = 250, - JsxElement = 251, - JsxSelfClosingElement = 252, - JsxOpeningElement = 253, - JsxClosingElement = 254, - JsxAttribute = 255, - JsxAttributes = 256, - JsxSpreadAttribute = 257, - JsxExpression = 258, - CaseClause = 259, - DefaultClause = 260, - HeritageClause = 261, - CatchClause = 262, - PropertyAssignment = 263, - ShorthandPropertyAssignment = 264, - SpreadAssignment = 265, - EnumMember = 266, - SourceFile = 267, - Bundle = 268, - JSDocTypeExpression = 269, - JSDocAllType = 270, - JSDocUnknownType = 271, - JSDocNullableType = 272, - JSDocNonNullableType = 273, - JSDocOptionalType = 274, - JSDocFunctionType = 275, - JSDocVariadicType = 276, - JSDocComment = 277, - JSDocTag = 278, - JSDocAugmentsTag = 279, - JSDocClassTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - SyntaxList = 288, - NotEmittedStatement = 289, - PartiallyEmittedExpression = 290, - CommaListExpression = 291, - MergeDeclarationMarker = 292, - EndOfDeclarationMarker = 293, - Count = 294, + ObjectBindingPattern = 175, + ArrayBindingPattern = 176, + BindingElement = 177, + ArrayLiteralExpression = 178, + ObjectLiteralExpression = 179, + PropertyAccessExpression = 180, + ElementAccessExpression = 181, + CallExpression = 182, + NewExpression = 183, + TaggedTemplateExpression = 184, + TypeAssertionExpression = 185, + ParenthesizedExpression = 186, + FunctionExpression = 187, + ArrowFunction = 188, + DeleteExpression = 189, + TypeOfExpression = 190, + VoidExpression = 191, + AwaitExpression = 192, + PrefixUnaryExpression = 193, + PostfixUnaryExpression = 194, + BinaryExpression = 195, + ConditionalExpression = 196, + TemplateExpression = 197, + YieldExpression = 198, + SpreadElement = 199, + ClassExpression = 200, + OmittedExpression = 201, + ExpressionWithTypeArguments = 202, + AsExpression = 203, + NonNullExpression = 204, + MetaProperty = 205, + TemplateSpan = 206, + SemicolonClassElement = 207, + Block = 208, + VariableStatement = 209, + EmptyStatement = 210, + ExpressionStatement = 211, + IfStatement = 212, + DoStatement = 213, + WhileStatement = 214, + ForStatement = 215, + ForInStatement = 216, + ForOfStatement = 217, + ContinueStatement = 218, + BreakStatement = 219, + ReturnStatement = 220, + WithStatement = 221, + SwitchStatement = 222, + LabeledStatement = 223, + ThrowStatement = 224, + TryStatement = 225, + DebuggerStatement = 226, + VariableDeclaration = 227, + VariableDeclarationList = 228, + FunctionDeclaration = 229, + ClassDeclaration = 230, + InterfaceDeclaration = 231, + TypeAliasDeclaration = 232, + EnumDeclaration = 233, + ModuleDeclaration = 234, + ModuleBlock = 235, + CaseBlock = 236, + NamespaceExportDeclaration = 237, + ImportEqualsDeclaration = 238, + ImportDeclaration = 239, + ImportClause = 240, + NamespaceImport = 241, + NamedImports = 242, + ImportSpecifier = 243, + ExportAssignment = 244, + ExportDeclaration = 245, + NamedExports = 246, + ExportSpecifier = 247, + MissingDeclaration = 248, + ExternalModuleReference = 249, + JsxElement = 250, + JsxSelfClosingElement = 251, + JsxOpeningElement = 252, + JsxClosingElement = 253, + JsxAttribute = 254, + JsxAttributes = 255, + JsxSpreadAttribute = 256, + JsxExpression = 257, + CaseClause = 258, + DefaultClause = 259, + HeritageClause = 260, + CatchClause = 261, + PropertyAssignment = 262, + ShorthandPropertyAssignment = 263, + SpreadAssignment = 264, + EnumMember = 265, + SourceFile = 266, + Bundle = 267, + JSDocTypeExpression = 268, + JSDocAllType = 269, + JSDocUnknownType = 270, + JSDocNullableType = 271, + JSDocNonNullableType = 272, + JSDocOptionalType = 273, + JSDocFunctionType = 274, + JSDocVariadicType = 275, + JSDocComment = 276, + JSDocTag = 277, + JSDocAugmentsTag = 278, + JSDocClassTag = 279, + JSDocParameterTag = 280, + JSDocReturnTag = 281, + JSDocTypeTag = 282, + JSDocTemplateTag = 283, + JSDocTypedefTag = 284, + JSDocPropertyTag = 285, + JSDocTypeLiteral = 286, + SyntaxList = 287, + NotEmittedStatement = 288, + PartiallyEmittedExpression = 289, + CommaListExpression = 290, + MergeDeclarationMarker = 291, + EndOfDeclarationMarker = 292, + Count = 293, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -366,7 +365,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 159, - LastTypeNode = 175, + LastTypeNode = 174, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -380,10 +379,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 144, - FirstJSDocNode = 269, - LastJSDocNode = 287, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 287, + FirstJSDocNode = 268, + LastJSDocNode = 286, + FirstJSDocTagNode = 277, + LastJSDocTagNode = 286, } enum NodeFlags { None = 0, @@ -738,7 +737,7 @@ declare namespace ts { } interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword; type: TypeNode; } interface IndexedAccessTypeNode extends TypeNode { @@ -757,9 +756,6 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface UniqueESSymbolTypeNode extends TypeNode { - kind: SyntaxKind.UniqueESSymbolType; - } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } @@ -3330,6 +3326,7 @@ declare namespace ts { function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; @@ -3337,7 +3334,6 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createUniqueESSymbolTypeNode(): UniqueESSymbolTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6f88bf241eea2..30c5cfd0233c3 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -235,126 +235,125 @@ declare namespace ts { IndexedAccessType = 172, MappedType = 173, LiteralType = 174, - UniqueESSymbolType = 175, - ObjectBindingPattern = 176, - ArrayBindingPattern = 177, - BindingElement = 178, - ArrayLiteralExpression = 179, - ObjectLiteralExpression = 180, - PropertyAccessExpression = 181, - ElementAccessExpression = 182, - CallExpression = 183, - NewExpression = 184, - TaggedTemplateExpression = 185, - TypeAssertionExpression = 186, - ParenthesizedExpression = 187, - FunctionExpression = 188, - ArrowFunction = 189, - DeleteExpression = 190, - TypeOfExpression = 191, - VoidExpression = 192, - AwaitExpression = 193, - PrefixUnaryExpression = 194, - PostfixUnaryExpression = 195, - BinaryExpression = 196, - ConditionalExpression = 197, - TemplateExpression = 198, - YieldExpression = 199, - SpreadElement = 200, - ClassExpression = 201, - OmittedExpression = 202, - ExpressionWithTypeArguments = 203, - AsExpression = 204, - NonNullExpression = 205, - MetaProperty = 206, - TemplateSpan = 207, - SemicolonClassElement = 208, - Block = 209, - VariableStatement = 210, - EmptyStatement = 211, - ExpressionStatement = 212, - IfStatement = 213, - DoStatement = 214, - WhileStatement = 215, - ForStatement = 216, - ForInStatement = 217, - ForOfStatement = 218, - ContinueStatement = 219, - BreakStatement = 220, - ReturnStatement = 221, - WithStatement = 222, - SwitchStatement = 223, - LabeledStatement = 224, - ThrowStatement = 225, - TryStatement = 226, - DebuggerStatement = 227, - VariableDeclaration = 228, - VariableDeclarationList = 229, - FunctionDeclaration = 230, - ClassDeclaration = 231, - InterfaceDeclaration = 232, - TypeAliasDeclaration = 233, - EnumDeclaration = 234, - ModuleDeclaration = 235, - ModuleBlock = 236, - CaseBlock = 237, - NamespaceExportDeclaration = 238, - ImportEqualsDeclaration = 239, - ImportDeclaration = 240, - ImportClause = 241, - NamespaceImport = 242, - NamedImports = 243, - ImportSpecifier = 244, - ExportAssignment = 245, - ExportDeclaration = 246, - NamedExports = 247, - ExportSpecifier = 248, - MissingDeclaration = 249, - ExternalModuleReference = 250, - JsxElement = 251, - JsxSelfClosingElement = 252, - JsxOpeningElement = 253, - JsxClosingElement = 254, - JsxAttribute = 255, - JsxAttributes = 256, - JsxSpreadAttribute = 257, - JsxExpression = 258, - CaseClause = 259, - DefaultClause = 260, - HeritageClause = 261, - CatchClause = 262, - PropertyAssignment = 263, - ShorthandPropertyAssignment = 264, - SpreadAssignment = 265, - EnumMember = 266, - SourceFile = 267, - Bundle = 268, - JSDocTypeExpression = 269, - JSDocAllType = 270, - JSDocUnknownType = 271, - JSDocNullableType = 272, - JSDocNonNullableType = 273, - JSDocOptionalType = 274, - JSDocFunctionType = 275, - JSDocVariadicType = 276, - JSDocComment = 277, - JSDocTag = 278, - JSDocAugmentsTag = 279, - JSDocClassTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - SyntaxList = 288, - NotEmittedStatement = 289, - PartiallyEmittedExpression = 290, - CommaListExpression = 291, - MergeDeclarationMarker = 292, - EndOfDeclarationMarker = 293, - Count = 294, + ObjectBindingPattern = 175, + ArrayBindingPattern = 176, + BindingElement = 177, + ArrayLiteralExpression = 178, + ObjectLiteralExpression = 179, + PropertyAccessExpression = 180, + ElementAccessExpression = 181, + CallExpression = 182, + NewExpression = 183, + TaggedTemplateExpression = 184, + TypeAssertionExpression = 185, + ParenthesizedExpression = 186, + FunctionExpression = 187, + ArrowFunction = 188, + DeleteExpression = 189, + TypeOfExpression = 190, + VoidExpression = 191, + AwaitExpression = 192, + PrefixUnaryExpression = 193, + PostfixUnaryExpression = 194, + BinaryExpression = 195, + ConditionalExpression = 196, + TemplateExpression = 197, + YieldExpression = 198, + SpreadElement = 199, + ClassExpression = 200, + OmittedExpression = 201, + ExpressionWithTypeArguments = 202, + AsExpression = 203, + NonNullExpression = 204, + MetaProperty = 205, + TemplateSpan = 206, + SemicolonClassElement = 207, + Block = 208, + VariableStatement = 209, + EmptyStatement = 210, + ExpressionStatement = 211, + IfStatement = 212, + DoStatement = 213, + WhileStatement = 214, + ForStatement = 215, + ForInStatement = 216, + ForOfStatement = 217, + ContinueStatement = 218, + BreakStatement = 219, + ReturnStatement = 220, + WithStatement = 221, + SwitchStatement = 222, + LabeledStatement = 223, + ThrowStatement = 224, + TryStatement = 225, + DebuggerStatement = 226, + VariableDeclaration = 227, + VariableDeclarationList = 228, + FunctionDeclaration = 229, + ClassDeclaration = 230, + InterfaceDeclaration = 231, + TypeAliasDeclaration = 232, + EnumDeclaration = 233, + ModuleDeclaration = 234, + ModuleBlock = 235, + CaseBlock = 236, + NamespaceExportDeclaration = 237, + ImportEqualsDeclaration = 238, + ImportDeclaration = 239, + ImportClause = 240, + NamespaceImport = 241, + NamedImports = 242, + ImportSpecifier = 243, + ExportAssignment = 244, + ExportDeclaration = 245, + NamedExports = 246, + ExportSpecifier = 247, + MissingDeclaration = 248, + ExternalModuleReference = 249, + JsxElement = 250, + JsxSelfClosingElement = 251, + JsxOpeningElement = 252, + JsxClosingElement = 253, + JsxAttribute = 254, + JsxAttributes = 255, + JsxSpreadAttribute = 256, + JsxExpression = 257, + CaseClause = 258, + DefaultClause = 259, + HeritageClause = 260, + CatchClause = 261, + PropertyAssignment = 262, + ShorthandPropertyAssignment = 263, + SpreadAssignment = 264, + EnumMember = 265, + SourceFile = 266, + Bundle = 267, + JSDocTypeExpression = 268, + JSDocAllType = 269, + JSDocUnknownType = 270, + JSDocNullableType = 271, + JSDocNonNullableType = 272, + JSDocOptionalType = 273, + JSDocFunctionType = 274, + JSDocVariadicType = 275, + JSDocComment = 276, + JSDocTag = 277, + JSDocAugmentsTag = 278, + JSDocClassTag = 279, + JSDocParameterTag = 280, + JSDocReturnTag = 281, + JSDocTypeTag = 282, + JSDocTemplateTag = 283, + JSDocTypedefTag = 284, + JSDocPropertyTag = 285, + JSDocTypeLiteral = 286, + SyntaxList = 287, + NotEmittedStatement = 288, + PartiallyEmittedExpression = 289, + CommaListExpression = 290, + MergeDeclarationMarker = 291, + EndOfDeclarationMarker = 292, + Count = 293, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -366,7 +365,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 159, - LastTypeNode = 175, + LastTypeNode = 174, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -380,10 +379,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 144, - FirstJSDocNode = 269, - LastJSDocNode = 287, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 287, + FirstJSDocNode = 268, + LastJSDocNode = 286, + FirstJSDocTagNode = 277, + LastJSDocTagNode = 286, } enum NodeFlags { None = 0, @@ -738,7 +737,7 @@ declare namespace ts { } interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword; type: TypeNode; } interface IndexedAccessTypeNode extends TypeNode { @@ -757,9 +756,6 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface UniqueESSymbolTypeNode extends TypeNode { - kind: SyntaxKind.UniqueESSymbolType; - } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } @@ -3277,6 +3273,7 @@ declare namespace ts { function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; @@ -3284,7 +3281,6 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createUniqueESSymbolTypeNode(): UniqueESSymbolTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; From 36f90b6ec3321eb9d26192b340171c9d56ef7787 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 4 Oct 2017 21:09:35 -0700 Subject: [PATCH 23/43] General tidying up and comments. --- src/compiler/checker.ts | 78 ++++++++++++++++++++++++----------------- src/compiler/types.ts | 4 +-- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a8e4bef670fca..5b2782cef8d0c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5512,7 +5512,7 @@ namespace ts { * late-bound members that `addDeclarationToSymbol` in binder.ts performs for early-bound * members. */ - function addDeclarationToLateBoundMember(symbol: Symbol, member: LateBoundDeclaration, symbolFlags: SymbolFlags) { + function addDeclarationToLateBoundSymbol(symbol: Symbol, member: LateBoundDeclaration, symbolFlags: SymbolFlags) { Debug.assert(!!(symbol.flags & SymbolFlags.Late), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; @@ -5534,37 +5534,41 @@ namespace ts { * Performs late-binding of a dynamic member. This performs the same function for * late-bound members that `declareSymbol` in binder.ts performs for early-bound * members. + * @param parent The containing symbol for the member. + * @param earlySymbols The early-bound symbols of the parent. + * @param lateSymbols The late-bound symbols of the parent. + * @param decl The member to bind. */ - function lateBindMember(lateMembers: SymbolTable, parent: Symbol, member: LateBoundDeclaration) { - Debug.assert(!!member.symbol, "The member is expected to have a symbol."); - const links = getNodeLinks(member); + function lateBindMember(parent: Symbol, earlySymbols: SymbolTable | undefined, lateSymbols: SymbolTable, decl: LateBoundDeclaration) { + Debug.assert(!!decl.symbol, "The member is expected to have a symbol."); + const links = getNodeLinks(decl); if (!links.resolvedSymbol) { // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. - links.resolvedSymbol = member.symbol; - const type = checkComputedPropertyName(member.name); + links.resolvedSymbol = decl.symbol; + const type = checkComputedPropertyName(decl.name); if (isTypeUsableAsLateBoundName(type)) { const memberName = getLateBoundNameFromType(type); // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. - let symbol = lateMembers.get(memberName); - if (!symbol) lateMembers.set(memberName, symbol = createSymbol(SymbolFlags.Late, memberName)); + let symbol = lateSymbols.get(memberName); + if (!symbol) lateSymbols.set(memberName, symbol = createSymbol(SymbolFlags.Late, memberName)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. - const earlyMember = parent.members && parent.members.get(memberName); - if (symbol.flags & getExcludedSymbolFlags(member.symbol.flags) || earlyMember) { + const earlySymbol = earlySymbols && earlySymbols.get(memberName); + if (symbol.flags & getExcludedSymbolFlags(decl.symbol.flags) || earlySymbol) { // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. - const declarations = earlyMember ? concatenate(earlyMember.declarations, symbol.declarations) : symbol.declarations; - const name = declarationNameToString(member.name); + const declarations = earlySymbol ? concatenate(earlySymbol.declarations, symbol.declarations) : symbol.declarations; + const name = declarationNameToString(decl.name); forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name)); - error(member.name || member, Diagnostics.Duplicate_declaration_0, name); + error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name); symbol = createSymbol(SymbolFlags.Late, memberName); } - addDeclarationToLateBoundMember(symbol, member, member.symbol.flags); + addDeclarationToLateBoundSymbol(symbol, decl, decl.symbol.flags); symbol.parent = parent; return links.resolvedSymbol = symbol; } @@ -5579,23 +5583,25 @@ namespace ts { if (symbol.flags & SymbolFlags.LateBindableContainer) { const links = getSymbolLinks(symbol); if (!links.resolvedMembers) { + const earlyMembers = symbol.members; + const lateMembers = getLateBoundMembersOfSymbol(symbol); + // In the event we recursively resolve the members of the symbol, we // should only see the early-bound members of the symbol here. - links.resolvedMembers = symbol.members || emptySymbols; + links.resolvedMembers = earlyMembers || emptySymbols; // fill in any as-yet-unresolved late-bound members. - const lateMembers = getLateBoundMembersOfSymbol(symbol); for (const decl of symbol.declarations) { const members = getMembersOfDeclaration(decl); if (members) { for (const member of members) { - if (hasLateBindableName(member)) { - lateBindMember(lateMembers, decl.symbol, member); + if (!hasModifier(member, ModifierFlags.Static) && hasLateBindableName(member)) { + lateBindMember(decl.symbol, earlyMembers, lateMembers, member); } } } } - links.resolvedMembers = combineSymbolTables(symbol.members, lateMembers) || emptySymbols; + links.resolvedMembers = combineSymbolTables(earlyMembers, lateMembers) || emptySymbols; } return links.resolvedMembers; } @@ -5610,23 +5616,29 @@ namespace ts { * that requires a type-check on every computed property name. */ function getLateBoundSymbol(symbol: Symbol) { - if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.escapedName === InternalSymbolName.Computed && - symbol.parent && (symbol.parent.flags & SymbolFlags.LateBindableContainer)) { - const links = getSymbolLinks(symbol); - if (!links.lateSymbol) { - // In the event we attempt to get the late-bound symbol for a symbol recursively, - // fall back to the early-bound symbol. - links.lateSymbol = symbol; - - // Fill in the late-bound symbol for each declaration of this symbol. - const lateMembers = getLateBoundMembersOfSymbol(symbol.parent); - for (const decl of symbol.declarations) { - if (hasLateBindableName(decl)) { - lateBindMember(lateMembers, symbol.parent, decl); + if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.escapedName === InternalSymbolName.Computed) { + // NOTE: This does not yet support late-bound static members of a class. + const isStaticMember = some(symbol.declarations, declaration => hasModifier(declaration, ModifierFlags.Static)); + const parent = symbol.parent; + if (parent && (parent.flags & (isStaticMember ? SymbolFlags.Class : SymbolFlags.LateBindableContainer)) && !isStaticMember) { + const links = getSymbolLinks(symbol); + if (!links.lateSymbol) { + const earlySymbols = parent.members; + const lateSymbols = getLateBoundMembersOfSymbol(symbol.parent); + + // In the event we attempt to get the late-bound symbol for a symbol recursively, + // fall back to the early-bound symbol. + links.lateSymbol = symbol; + + // Fill in the late-bound symbol for each declaration of this symbol. + for (const decl of symbol.declarations) { + if (hasLateBindableName(decl)) { + lateBindMember(parent, earlySymbols, lateSymbols, decl); + } } } + return links.lateSymbol; } - return links.lateSymbol; } return symbol; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c06aa571bfc9f..54386fb04e893 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3060,7 +3060,8 @@ namespace ts { syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property syntheticLiteralTypeOrigin?: StringLiteralType; // For a property on a mapped type, indicates the type whose text to use as the declaration name, instead of the symbol name isDiscriminantProperty?: boolean; // True if discriminant synthetic property - resolvedExports?: SymbolTable; // Resolved exports of module + resolvedExports?: SymbolTable; // Resolved exports of module or combined early- and late-bound static members of a class. + resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol exportsChecked?: boolean; // True if exports of external module have been checked typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked. isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration @@ -3069,7 +3070,6 @@ namespace ts { enumKind?: EnumKind; // Enum declaration classification lateSymbol?: Symbol; // Late-bound symbol for a computed property lateMembers?: SymbolTable; // Late-bound members resolved during check - resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol } /* @internal */ From 906a79df763f8aeebe4a72fed0a6aac3b93a144e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 4 Oct 2017 21:24:32 -0700 Subject: [PATCH 24/43] Support dynamic names on static members of class. --- src/compiler/checker.ts | 48 ++++- src/compiler/types.ts | 1 + tests/baselines/reference/dynamicNames.js | 8 + .../baselines/reference/dynamicNames.symbols | 201 ++++++++++-------- tests/baselines/reference/dynamicNames.types | 16 ++ tests/cases/compiler/dynamicNames.ts | 7 + 6 files changed, 183 insertions(+), 98 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5b2782cef8d0c..9e0bcf90813c9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1867,7 +1867,9 @@ namespace ts { } function getExportsOfSymbol(symbol: Symbol): SymbolTable { - return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; + return symbol.flags & SymbolFlags.Class ? getExportsOfClass(symbol) : + symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : + symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol: Symbol): SymbolTable { @@ -1875,6 +1877,33 @@ namespace ts { return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol)); } + function getExportsOfClass(symbol: Symbol) { + const links = getSymbolLinks(symbol); + if (!links.resolvedExports) { + const earlySymbols = symbol.flags & SymbolFlags.Module ? getExportsOfModuleWorker(symbol) : symbol.exports; + const lateSymbols = getLateBoundExportsOfSymbol(symbol); + + // In the event we recursively resolve the members of the symbol, we + // should only see the early-bound members of the symbol here. + links.resolvedExports = earlySymbols || emptySymbols; + + // fill in any as-yet-unresolved late-bound members. + for (const decl of symbol.declarations) { + const members = getMembersOfDeclaration(decl); + if (members) { + for (const member of members) { + if (hasModifier(member, ModifierFlags.Static) && hasLateBindableName(member)) { + lateBindMember(decl.symbol, earlySymbols, lateSymbols, member); + } + } + } + } + + links.resolvedExports = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; + } + return links.resolvedExports; + } + interface ExportCollisionTracker { specifierText: string; exportsWithDuplicate: ExportDeclaration[]; @@ -5507,6 +5536,16 @@ namespace ts { return links.lateMembers || (links.lateMembers = createSymbolTable()); } + /** + * Gets the symbol table used to store exports added during late-binding. + * This table is filled in as the late-bound names for dynamic members are resolved. + */ + function getLateBoundExportsOfSymbol(symbol: Symbol): SymbolTable { + Debug.assert(!!(symbol.flags & SymbolFlags.Class), "Expected a container that supports late-binding of exports."); + const links = getSymbolLinks(symbol); + return links.lateExports || (links.lateExports = createSymbolTable()); + } + /** * Adds a declaration to a late-bound dynamic member. This performs the same function for * late-bound members that `addDeclarationToSymbol` in binder.ts performs for early-bound @@ -5617,14 +5656,13 @@ namespace ts { */ function getLateBoundSymbol(symbol: Symbol) { if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.escapedName === InternalSymbolName.Computed) { - // NOTE: This does not yet support late-bound static members of a class. const isStaticMember = some(symbol.declarations, declaration => hasModifier(declaration, ModifierFlags.Static)); const parent = symbol.parent; - if (parent && (parent.flags & (isStaticMember ? SymbolFlags.Class : SymbolFlags.LateBindableContainer)) && !isStaticMember) { + if (parent && (parent.flags & (isStaticMember ? SymbolFlags.Class : SymbolFlags.LateBindableContainer))) { const links = getSymbolLinks(symbol); if (!links.lateSymbol) { - const earlySymbols = parent.members; - const lateSymbols = getLateBoundMembersOfSymbol(symbol.parent); + const earlySymbols = isStaticMember ? parent.exports : parent.members; + const lateSymbols = isStaticMember ? getLateBoundExportsOfSymbol(parent) : getLateBoundMembersOfSymbol(parent); // In the event we attempt to get the late-bound symbol for a symbol recursively, // fall back to the early-bound symbol. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 54386fb04e893..eb492562961bb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3070,6 +3070,7 @@ namespace ts { enumKind?: EnumKind; // Enum declaration classification lateSymbol?: Symbol; // Late-bound symbol for a computed property lateMembers?: SymbolTable; // Late-bound members resolved during check + lateExports?: SymbolTable; // Late-bound exports resolved during check } /* @internal */ diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index 869f7282639ec..3180aa3531042 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -90,6 +90,12 @@ declare type T15 = { [s2]: boolean; }; +declare class C { + static a: number; + static 1: string; + static [s2]: boolean; +} + let t0: T0; let t1: T1; let t2: T2; @@ -115,6 +121,7 @@ let t15: T15; t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +t0 = C; // static side // object literals export const o1 = { @@ -173,6 +180,7 @@ let t15; t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +t0 = C; // static side // object literals exports.o1 = { [exports.c4]: 1, diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index 6ac8b66baa6d7..2e0a5cadfcdca 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -232,168 +232,183 @@ declare type T15 = { }; +declare class C { +>C : Symbol(C, Decl(main.ts, 65, 2)) + + static a: number; +>a : Symbol(C.a, Decl(main.ts, 67, 17)) + + static 1: string; + static [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +} + let t0: T0; ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) >T0 : Symbol(T0, Decl(main.ts, 0, 20)) let t1: T1; ->t1 : Symbol(t1, Decl(main.ts, 68, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) >T1 : Symbol(T1, Decl(main.ts, 0, 24)) let t2: T2; ->t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) >T2 : Symbol(T2, Decl(main.ts, 0, 28)) let t3: T3; ->t3 : Symbol(t3, Decl(main.ts, 70, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) >T3 : Symbol(T3, Decl(main.ts, 0, 32)) let t0_1: M.T0; ->t0_1 : Symbol(t0_1, Decl(main.ts, 71, 3)) +>t0_1 : Symbol(t0_1, Decl(main.ts, 77, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T0 : Symbol(T0, Decl(module.ts, 2, 27)) let t1_1: M.T1; ->t1_1 : Symbol(t1_1, Decl(main.ts, 72, 3)) +>t1_1 : Symbol(t1_1, Decl(main.ts, 78, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T1 : Symbol(T1, Decl(module.ts, 7, 1)) let t2_1: M.T2; ->t2_1 : Symbol(t2_1, Decl(main.ts, 73, 3)) +>t2_1 : Symbol(t2_1, Decl(main.ts, 79, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T2 : Symbol(T2, Decl(module.ts, 12, 1)) let t3_1: M.T3; ->t3_1 : Symbol(t3_1, Decl(main.ts, 74, 3)) +>t3_1 : Symbol(t3_1, Decl(main.ts, 80, 3)) >M : Symbol(M, Decl(main.ts, 1, 6)) >T3 : Symbol(T3, Decl(module.ts, 14, 1)) let t4: N.T4; ->t4 : Symbol(t4, Decl(main.ts, 75, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T4 : Symbol(N.T4, Decl(main.ts, 6, 36)) let t5: N.T5; ->t5 : Symbol(t5, Decl(main.ts, 76, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T5 : Symbol(N.T5, Decl(main.ts, 12, 5)) let t6: N.T6; ->t6 : Symbol(t6, Decl(main.ts, 77, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T6 : Symbol(N.T6, Decl(main.ts, 17, 5)) let t7: N.T7; ->t7 : Symbol(t7, Decl(main.ts, 78, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) >N : Symbol(N, Decl(main.ts, 1, 30)) >T7 : Symbol(N.T7, Decl(main.ts, 19, 5)) let t8: T8; ->t8 : Symbol(t8, Decl(main.ts, 79, 3)) +>t8 : Symbol(t8, Decl(main.ts, 85, 3)) >T8 : Symbol(T8, Decl(main.ts, 29, 32)) let t9: T9; ->t9 : Symbol(t9, Decl(main.ts, 80, 3)) +>t9 : Symbol(t9, Decl(main.ts, 86, 3)) >T9 : Symbol(T9, Decl(main.ts, 35, 1)) let t10: T10; ->t10 : Symbol(t10, Decl(main.ts, 81, 3)) +>t10 : Symbol(t10, Decl(main.ts, 87, 3)) >T10 : Symbol(T10, Decl(main.ts, 40, 1)) let t11: T11; ->t11 : Symbol(t11, Decl(main.ts, 82, 3)) +>t11 : Symbol(t11, Decl(main.ts, 88, 3)) >T11 : Symbol(T11, Decl(main.ts, 42, 1)) let t12: T12; ->t12 : Symbol(t12, Decl(main.ts, 83, 3)) +>t12 : Symbol(t12, Decl(main.ts, 89, 3)) >T12 : Symbol(T12, Decl(main.ts, 47, 2)) let t13: T13; ->t13 : Symbol(t13, Decl(main.ts, 84, 3)) +>t13 : Symbol(t13, Decl(main.ts, 90, 3)) >T13 : Symbol(T13, Decl(main.ts, 53, 1)) let t14: T14; ->t14 : Symbol(t14, Decl(main.ts, 85, 3)) +>t14 : Symbol(t14, Decl(main.ts, 91, 3)) >T14 : Symbol(T14, Decl(main.ts, 58, 1)) let t15: T15; ->t15 : Symbol(t15, Decl(main.ts, 86, 3)) +>t15 : Symbol(t15, Decl(main.ts, 92, 3)) >T15 : Symbol(T15, Decl(main.ts, 60, 1)) // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t1 : Symbol(t1, Decl(main.ts, 68, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t2 : Symbol(t2, Decl(main.ts, 69, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t3 : Symbol(t3, Decl(main.ts, 70, 3)) ->t1 : Symbol(t1, Decl(main.ts, 68, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t1 : Symbol(t1, Decl(main.ts, 68, 3)) ->t2 : Symbol(t2, Decl(main.ts, 69, 3)) ->t1 : Symbol(t1, Decl(main.ts, 68, 3)) ->t3 : Symbol(t3, Decl(main.ts, 70, 3)) ->t2 : Symbol(t2, Decl(main.ts, 69, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t2 : Symbol(t2, Decl(main.ts, 69, 3)) ->t1 : Symbol(t1, Decl(main.ts, 68, 3)) ->t2 : Symbol(t2, Decl(main.ts, 69, 3)) ->t3 : Symbol(t3, Decl(main.ts, 70, 3)) ->t3 : Symbol(t3, Decl(main.ts, 70, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t3 : Symbol(t3, Decl(main.ts, 70, 3)) ->t1 : Symbol(t1, Decl(main.ts, 68, 3)) ->t3 : Symbol(t3, Decl(main.ts, 70, 3)) ->t2 : Symbol(t2, Decl(main.ts, 69, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; ->t4 : Symbol(t4, Decl(main.ts, 75, 3)) ->t5 : Symbol(t5, Decl(main.ts, 76, 3)) ->t4 : Symbol(t4, Decl(main.ts, 75, 3)) ->t6 : Symbol(t6, Decl(main.ts, 77, 3)) ->t4 : Symbol(t4, Decl(main.ts, 75, 3)) ->t7 : Symbol(t7, Decl(main.ts, 78, 3)) ->t5 : Symbol(t5, Decl(main.ts, 76, 3)) ->t4 : Symbol(t4, Decl(main.ts, 75, 3)) ->t5 : Symbol(t5, Decl(main.ts, 76, 3)) ->t6 : Symbol(t6, Decl(main.ts, 77, 3)) ->t5 : Symbol(t5, Decl(main.ts, 76, 3)) ->t7 : Symbol(t7, Decl(main.ts, 78, 3)) ->t6 : Symbol(t6, Decl(main.ts, 77, 3)) ->t4 : Symbol(t4, Decl(main.ts, 75, 3)) ->t6 : Symbol(t6, Decl(main.ts, 77, 3)) ->t5 : Symbol(t5, Decl(main.ts, 76, 3)) ->t6 : Symbol(t6, Decl(main.ts, 77, 3)) ->t7 : Symbol(t7, Decl(main.ts, 78, 3)) ->t7 : Symbol(t7, Decl(main.ts, 78, 3)) ->t4 : Symbol(t4, Decl(main.ts, 75, 3)) ->t7 : Symbol(t7, Decl(main.ts, 78, 3)) ->t5 : Symbol(t5, Decl(main.ts, 76, 3)) ->t7 : Symbol(t7, Decl(main.ts, 78, 3)) ->t6 : Symbol(t6, Decl(main.ts, 77, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t12 : Symbol(t12, Decl(main.ts, 83, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t13 : Symbol(t13, Decl(main.ts, 84, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t14 : Symbol(t14, Decl(main.ts, 85, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t15 : Symbol(t15, Decl(main.ts, 86, 3)) ->t12 : Symbol(t12, Decl(main.ts, 83, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t13 : Symbol(t13, Decl(main.ts, 84, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t14 : Symbol(t14, Decl(main.ts, 85, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) ->t15 : Symbol(t15, Decl(main.ts, 86, 3)) ->t0 : Symbol(t0, Decl(main.ts, 67, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t12 : Symbol(t12, Decl(main.ts, 89, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t13 : Symbol(t13, Decl(main.ts, 90, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t14 : Symbol(t14, Decl(main.ts, 91, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t15 : Symbol(t15, Decl(main.ts, 92, 3)) +>t12 : Symbol(t12, Decl(main.ts, 89, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t13 : Symbol(t13, Decl(main.ts, 90, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t14 : Symbol(t14, Decl(main.ts, 91, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t15 : Symbol(t15, Decl(main.ts, 92, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) + +t0 = C; // static side +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>C : Symbol(C, Decl(main.ts, 65, 2)) // object literals export const o1 = { ->o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) [c4]: 1, >c4 : Symbol(c4, Decl(main.ts, 27, 12)) @@ -408,22 +423,22 @@ export const o1 = { // check element access types export const o1_c4 = o1[c4]; ->o1_c4 : Symbol(o1_c4, Decl(main.ts, 101, 12)) ->o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>o1_c4 : Symbol(o1_c4, Decl(main.ts, 108, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) >c4 : Symbol(c4, Decl(main.ts, 27, 12)) export const o1_c5 = o1[c5]; ->o1_c5 : Symbol(o1_c5, Decl(main.ts, 102, 12)) ->o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>o1_c5 : Symbol(o1_c5, Decl(main.ts, 109, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) >c5 : Symbol(c5, Decl(main.ts, 28, 12)) export const o1_s2 = o1[s2]; ->o1_s2 : Symbol(o1_s2, Decl(main.ts, 103, 12)) ->o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>o1_s2 : Symbol(o1_s2, Decl(main.ts, 110, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) >s2 : Symbol(s2, Decl(main.ts, 29, 12)) export const o2: T0 = o1; ->o2 : Symbol(o2, Decl(main.ts, 105, 12)) +>o2 : Symbol(o2, Decl(main.ts, 112, 12)) >T0 : Symbol(T0, Decl(main.ts, 0, 20)) ->o1 : Symbol(o1, Decl(main.ts, 94, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 07d4673697863..a568000e13ec2 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -239,6 +239,17 @@ declare type T15 = { }; +declare class C { +>C : C + + static a: number; +>a : number + + static 1: string; + static [s2]: boolean; +>s2 : unique symbol +} + let t0: T0; >t0 : T0 >T0 : T0 @@ -459,6 +470,11 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; >t15 : { a: number; 1: string; [s2]: boolean; } >t0 : T0 +t0 = C; // static side +>t0 = C : typeof C +>t0 : T0 +>C : typeof C + // object literals export const o1 = { >o1 : { [c4]: number; [c5]: string; [s2]: boolean; } diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index e07febc7c7c27..2184ee73b33c5 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -92,6 +92,12 @@ declare type T15 = { [s2]: boolean; }; +declare class C { + static a: number; + static 1: string; + static [s2]: boolean; +} + let t0: T0; let t1: T1; let t2: T2; @@ -117,6 +123,7 @@ let t15: T15; t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +t0 = C; // static side // object literals export const o1 = { From 180ca23384bda2de2ce2deadd2bd94110470e77d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 5 Oct 2017 11:34:42 -0700 Subject: [PATCH 25/43] Additional documentation --- src/compiler/checker.ts | 63 ++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9e0bcf90813c9..0aa287e4138cb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5573,6 +5573,25 @@ namespace ts { * Performs late-binding of a dynamic member. This performs the same function for * late-bound members that `declareSymbol` in binder.ts performs for early-bound * members. + * + * If a symbol is a dynamic name from a computed property, we perform an additional "late" + * binding phase to attempt to resolve the name for the symbol from the type of the computed + * property's expression. If the type of the expression is a string-literal, numeric-literal, + * or unique symbol type, we can use that type as the name of the symbol. + * + * For example, given: + * + * const x = Symbol(); + * + * interface I { + * [x]: number; + * } + * + * The binder gives the property `[x]: number` a special symbol with the name "__computed". + * In the late-binding phase we can type-check the expression `x` and see that it has a + * unique symbol type which we can then use as the name of the member. This allows users + * to define custom symbols that can be used in the members of an object type. + * * @param parent The containing symbol for the member. * @param earlySymbols The early-bound symbols of the parent. * @param lateSymbols The late-bound symbols of the parent. @@ -5590,26 +5609,26 @@ namespace ts { const memberName = getLateBoundNameFromType(type); // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. - let symbol = lateSymbols.get(memberName); - if (!symbol) lateSymbols.set(memberName, symbol = createSymbol(SymbolFlags.Late, memberName)); + let lateSymbol = lateSymbols.get(memberName); + if (!lateSymbol) lateSymbols.set(memberName, lateSymbol = createSymbol(SymbolFlags.Late, memberName)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. const earlySymbol = earlySymbols && earlySymbols.get(memberName); - if (symbol.flags & getExcludedSymbolFlags(decl.symbol.flags) || earlySymbol) { + if (lateSymbol.flags & getExcludedSymbolFlags(decl.symbol.flags) || earlySymbol) { // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. - const declarations = earlySymbol ? concatenate(earlySymbol.declarations, symbol.declarations) : symbol.declarations; + const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; const name = declarationNameToString(decl.name); forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name)); error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name); - symbol = createSymbol(SymbolFlags.Late, memberName); + lateSymbol = createSymbol(SymbolFlags.Late, memberName); } - addDeclarationToLateBoundSymbol(symbol, decl, decl.symbol.flags); - symbol.parent = parent; - return links.resolvedSymbol = symbol; + addDeclarationToLateBoundSymbol(lateSymbol, decl, decl.symbol.flags); + lateSymbol.parent = parent; + return links.resolvedSymbol = lateSymbol; } } return links.resolvedSymbol; @@ -5617,16 +5636,22 @@ namespace ts { /** * Gets a SymbolTable containing both the early- and late-bound members of a symbol. + * + * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol: Symbol) { if (symbol.flags & SymbolFlags.LateBindableContainer) { const links = getSymbolLinks(symbol); if (!links.resolvedMembers) { - const earlyMembers = symbol.members; + // Get (or create) the SymbolTable from the parent used to store late- + // bound symbols. We get a shared table so that we can correctly merge + // late-bound symbols across accessor pairs. const lateMembers = getLateBoundMembersOfSymbol(symbol); + const earlyMembers = symbol.members; // In the event we recursively resolve the members of the symbol, we - // should only see the early-bound members of the symbol here. + // set the initial value of resolvedMembers to the early-bound members + // of the symbol. links.resolvedMembers = earlyMembers || emptySymbols; // fill in any as-yet-unresolved late-bound members. @@ -5635,11 +5660,12 @@ namespace ts { if (members) { for (const member of members) { if (!hasModifier(member, ModifierFlags.Static) && hasLateBindableName(member)) { - lateBindMember(decl.symbol, earlyMembers, lateMembers, member); + lateBindMember(symbol, earlyMembers, lateMembers, member); } } } } + links.resolvedMembers = combineSymbolTables(earlyMembers, lateMembers) || emptySymbols; } return links.resolvedMembers; @@ -5648,11 +5674,9 @@ namespace ts { } /** - * Gets the late-bound symbol for a symbol (if it has one). The symbol is - * resolved dynamically but allows accessors to share the same symbol. + * If a symbol is the dynamic name of the member of an object type, get its late-bound member. * - * We do not aggressively resolve the entire late-bound symbol table here as - * that requires a type-check on every computed property name. + * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol: Symbol) { if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.escapedName === InternalSymbolName.Computed) { @@ -5661,8 +5685,15 @@ namespace ts { if (parent && (parent.flags & (isStaticMember ? SymbolFlags.Class : SymbolFlags.LateBindableContainer))) { const links = getSymbolLinks(symbol); if (!links.lateSymbol) { - const earlySymbols = isStaticMember ? parent.exports : parent.members; + // Get (or create) the SymbolTable from the parent used to store late- + // bound symbols. We get a shared table so that we can correctly merge + // late-bound symbols across accessor pairs. + // + // We do not eagerly resolve all of the members of the parent here as + // that results in an eager type-check of the expression of every member + // with a computed property name. const lateSymbols = isStaticMember ? getLateBoundExportsOfSymbol(parent) : getLateBoundMembersOfSymbol(parent); + const earlySymbols = isStaticMember ? parent.exports : parent.members; // In the event we attempt to get the late-bound symbol for a symbol recursively, // fall back to the early-bound symbol. From 55e63a8288147e451ef5559f61f3a3b82605e258 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 20 Oct 2017 15:04:04 -0700 Subject: [PATCH 26/43] Simplify getLateBoundSymbol --- src/compiler/checker.ts | 55 +++++++++++++++++---------------------- src/compiler/utilities.ts | 4 +++ 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 14ca23c0cec37..d95fcdcf2fd6a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1996,11 +1996,11 @@ namespace ts { } function getSymbolOfNode(node: Node): Symbol { - return getMergedSymbol(getLateBoundSymbol(node.symbol)); + return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol)); } function getParentOfSymbol(symbol: Symbol): Symbol { - return getMergedSymbol(getLateBoundSymbol(symbol.parent)); + return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent)); } function getExportSymbolOfValueSymbolIfExported(symbol: Symbol): Symbol { @@ -5511,6 +5511,15 @@ namespace ts { return isDynamicName(node) && !isLateBindableName(node); } + /** + * Indicates whether a symbol has a late-bindable name. + */ + function symbolHasLateBindableName(symbol: Symbol) { + return symbol.flags & SymbolFlags.ClassMember + && symbol.escapedName === InternalSymbolName.Computed + && some(symbol.declarations, hasLateBindableName); + } + /** * Gets the symbolic name for a late-bound member from its type. */ @@ -5671,42 +5680,26 @@ namespace ts { } /** - * If a symbol is the dynamic name of the member of an object type, get its late-bound member. + * If a symbol is the dynamic name of the member of an object type, get the late-bound + * symbol of the member. * * For a description of late-binding, see `lateBindMember`. */ - function getLateBoundSymbol(symbol: Symbol) { - if (symbol && (symbol.flags & SymbolFlags.ClassMember) && symbol.escapedName === InternalSymbolName.Computed) { - const isStaticMember = some(symbol.declarations, declaration => hasModifier(declaration, ModifierFlags.Static)); + function getLateBoundSymbol(symbol: Symbol): Symbol { + const links = getSymbolLinks(symbol); + if (!links.lateSymbol) { const parent = symbol.parent; - if (parent && (parent.flags & (isStaticMember ? SymbolFlags.Class : SymbolFlags.LateBindableContainer))) { - const links = getSymbolLinks(symbol); - if (!links.lateSymbol) { - // Get (or create) the SymbolTable from the parent used to store late- - // bound symbols. We get a shared table so that we can correctly merge - // late-bound symbols across accessor pairs. - // - // We do not eagerly resolve all of the members of the parent here as - // that results in an eager type-check of the expression of every member - // with a computed property name. - const lateSymbols = isStaticMember ? getLateBoundExportsOfSymbol(parent) : getLateBoundMembersOfSymbol(parent); - const earlySymbols = isStaticMember ? parent.exports : parent.members; - - // In the event we attempt to get the late-bound symbol for a symbol recursively, - // fall back to the early-bound symbol. - links.lateSymbol = symbol; - - // Fill in the late-bound symbol for each declaration of this symbol. - for (const decl of symbol.declarations) { - if (hasLateBindableName(decl)) { - lateBindMember(parent, earlySymbols, lateSymbols, decl); - } - } + if (symbolHasLateBindableName(symbol) && parent && parent.flags & SymbolFlags.LateBindableContainer) { + // force late binding of members/exports. This will set the late-bound symbol + if (some(symbol.declarations, hasStaticModifier)) { + getExportsOfSymbol(parent); + } + else { + getMembersOfSymbol(parent); } - return links.lateSymbol; } } - return symbol; + return links.lateSymbol || (links.lateSymbol = symbol); } function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 624e55e403e3d..71d30a1ab9b9e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3005,6 +3005,10 @@ namespace ts { return !!getSelectedModifierFlags(node, flags); } + export function hasStaticModifier(node: Node): boolean { + return hasModifier(node, ModifierFlags.Static); + } + export function getSelectedModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags { return getModifierFlags(node) & flags; } From 3341e07e67f4f3a3b8027b4d190d4a42aacec49d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 20 Oct 2017 22:52:20 -0700 Subject: [PATCH 27/43] Refactor widening --- src/compiler/checker.ts | 96 ++++-- src/compiler/types.ts | 11 +- tests/baselines/reference/dynamicNames.js | 15 +- .../baselines/reference/dynamicNames.symbols | 32 ++ tests/baselines/reference/dynamicNames.types | 32 ++ tests/baselines/reference/uniqueSymbols.js | 181 +++++++++- .../baselines/reference/uniqueSymbols.symbols | 272 +++++++++++++++ tests/baselines/reference/uniqueSymbols.types | 326 ++++++++++++++++++ tests/cases/compiler/dynamicNames.ts | 15 +- .../types/uniqueSymbol/uniqueSymbols.ts | 86 ++++- 10 files changed, 1036 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d95fcdcf2fd6a..1a3cb8f66630f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5479,8 +5479,8 @@ namespace ts { * Indicates whether a declaration name is definitely late-bindable. * A declaration name is only late-bindable if: * - It is a `ComputedPropertyName`. - * - Its expression is either an `Identifier` or is a `PropertyAccessExpression` consisting only of - * other `PropertyAccessExpression` or `Identifier` nodes. + * - Its expression is an `Identifier` or either a `PropertyAccessExpression` an + * `ElementAccessExpression` consisting only of these same three types of nodes. * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node: DeclarationName): node is LateBoundName { @@ -8299,13 +8299,6 @@ namespace ts { return links.resolvedType; } - function getWidenedTypeOfUniqueESSymbolType(type: Type): Type { - return type.flags & TypeFlags.UniqueESSymbol ? esSymbolType : - type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedTypeOfUniqueESSymbolType)) : - type.flags & TypeFlags.Intersection ? getIntersectionType(sameMap((type).types, getWidenedTypeOfUniqueESSymbolType)) : - type; - } - function createUniqueESSymbolType(symbol: Symbol) { const type = createType(TypeFlags.UniqueESSymbol); type.symbol = symbol; @@ -10569,12 +10562,67 @@ namespace ts { type; } + function getWidenedLiteralLikeMapper(wideningFlags: TypeFlags) { + return !(wideningFlags & TypeFlags.UniqueESSymbol) ? getWidenedLiteralType : + !(wideningFlags & TypeFlags.WidenableLiteral) ? getWidenedUniqueESSymbolType : + getWidenedLiteralLikeType; + } + + /** + * Widens string literal, number literal, boolean literal, enum literal, and unique symbol + * types, as well as unions of the same. + * + * We don't always want to widen literals in all of the same places we widen unique symbol + * types, and vice versa. However, there are some cases where we do widen both sets of + * types at the same time. + * + * In general, this function should not be called directly. Instead it should be called + * through either `getWidenedLiteralType` (which does not widen unique symbol types), + * `getWidenedUniqueESSymbolType` (which only widenes unique symbol types), or + * `getWidenedLiteralLikeType` (which widens both). + */ + function getWidenedLiteralLikeTypeWorker(type: Type, wideningFlags: TypeFlags): Type { + return type.flags & wideningFlags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : + type.flags & wideningFlags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : + type.flags & wideningFlags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : + type.flags & wideningFlags & TypeFlags.BooleanLiteral ? booleanType : + type.flags & wideningFlags & TypeFlags.UniqueESSymbol ? esSymbolType : + type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedLiteralLikeMapper(wideningFlags))) : + type; + } + + /** + * Widens string literal, number literal, boolean literal, enum literal, and unique symbol + * types, as well as unions of the same. + */ + function getWidenedLiteralLikeType(type: Type): Type { + return getWidenedLiteralLikeTypeWorker(type, TypeFlags.WidenableLiteralLike); + } + + /** + * Widens string literal, number literal, boolean literal, and enum literal types, as well + * as unions of the same. + */ function getWidenedLiteralType(type: Type): Type { - return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : - type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : - type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : - type.flags & TypeFlags.BooleanLiteral ? booleanType : - type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedLiteralType)) : + return getWidenedLiteralLikeTypeWorker(type, TypeFlags.WidenableLiteral); + } + + /** + * Widens unique symbol types and unions of unique symbol types. + */ + function getWidenedUniqueESSymbolType(type: Type): Type { + return getWidenedLiteralLikeTypeWorker(type, TypeFlags.UniqueESSymbol); + } + + /** + * Widens a literal-like type when the contextual type is not literal-like. + */ + function getWidenedLiteralLikeTypeForContextualType(type: Type, contextualType: Type) { + const widenLiterals = !isLiteralContextualType(contextualType); + const widenSymbols = !isUniqueESSymbolContextualType(contextualType); + return widenLiterals && widenSymbols ? getWidenedLiteralLikeType(type) : + widenLiterals ? getWidenedLiteralType(type) : + widenSymbols ? getWidenedUniqueESSymbolType(type) : type; } @@ -11341,7 +11389,8 @@ namespace ts { } } } - return getWidenedTypeOfUniqueESSymbolType(inferredType); + + return getWidenedUniqueESSymbolType(inferredType); } function getDefaultTypeArgumentType(isInJavaScriptFile: boolean): Type { @@ -13986,7 +14035,7 @@ namespace ts { else { const elementContextualType = getContextualTypeForElementExpression(contextualType, index); const type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); - elementTypes.push(getWidenedTypeOfUniqueESSymbolType(type)); + elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElement; } @@ -17426,7 +17475,7 @@ namespace ts { } // widen 'unique symbol' types when we infer the return type. - type = getWidenedTypeOfUniqueESSymbolType(type); + type = getWidenedUniqueESSymbolType(type); } else { let types: Type[]; @@ -17462,7 +17511,7 @@ namespace ts { type = getUnionType(types, /*subtypeReduction*/ true); // widen 'unique symbol' types when we infer the return type. - type = getWidenedTypeOfUniqueESSymbolType(type); + type = getWidenedUniqueESSymbolType(type); if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function type = functionFlags & FunctionFlags.Async @@ -18592,13 +18641,17 @@ namespace ts { return false; } + function isUniqueESSymbolContextualType(contextualType: Type) { + return contextualType ? maybeTypeOfKind(contextualType, TypeFlags.UniqueESSymbol) : false; + } + function checkExpressionForMutableLocation(node: Expression, checkMode: CheckMode, contextualType?: Type): Type { if (arguments.length === 2) { contextualType = getContextualType(node); } const type = checkExpression(node, checkMode); - const shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); - return shouldWiden ? type : getWidenedLiteralType(type); + return isTypeAssertion(node) ? type : + getWidenedLiteralLikeTypeForContextualType(type, contextualType); } function checkPropertyAssignment(node: PropertyAssignment, checkMode?: CheckMode): Type { @@ -24392,8 +24445,7 @@ namespace ts { function isLiteralDynamicName(name: ComputedPropertyName) { name = getParseTreeNode(name, isComputedPropertyName); if (name) { - const nameType = checkComputedPropertyName(name); - return (nameType.flags & TypeFlags.StringOrNumberLiteralOrUnique) !== 0; + return isLateBindableName(name); } return false; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index eb492562961bb..a3a522cec2756 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3246,8 +3246,8 @@ namespace ts { /* @internal */ Nullable = Undefined | Null, - Literal = StringLiteral | NumberLiteral | BooleanLiteral | UniqueESSymbol, - Unit = Literal | Nullable, + Literal = StringLiteral | NumberLiteral | BooleanLiteral, + Unit = Literal | UniqueESSymbol | Nullable, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ StringOrNumberLiteralOrUnique = StringOrNumberLiteral | UniqueESSymbol, @@ -3257,7 +3257,7 @@ namespace ts { /* @internal */ Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive, /* @internal */ - Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal, + Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol, StringLike = String | StringLiteral | Index, NumberLike = Number | NumberLiteral | Enum, BooleanLike = Boolean | BooleanLiteral, @@ -3275,7 +3275,10 @@ namespace ts { /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ - PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType + PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType, + + WidenableLiteral = Literal | EnumLiteral, + WidenableLiteralLike = WidenableLiteral | UniqueESSymbol, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js index 3180aa3531042..6582dab44d47d 100644 --- a/tests/baselines/reference/dynamicNames.js +++ b/tests/baselines/reference/dynamicNames.js @@ -135,7 +135,20 @@ export const o1_c4 = o1[c4]; export const o1_c5 = o1[c5]; export const o1_s2 = o1[s2]; -export const o2: T0 = o1; +export const o2: T0 = o1; + +// recursive declarations +declare const rI: RI; +interface RI { + x: "a"; + [rI.x]: "b"; +} + +declare const rC: RC; +declare class RC { + x: "a"; + [rC.x]: "b"; +} //// [module.js] "use strict"; diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index 2e0a5cadfcdca..e030a9686e5e0 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -442,3 +442,35 @@ export const o2: T0 = o1; >T0 : Symbol(T0, Decl(main.ts, 0, 20)) >o1 : Symbol(o1, Decl(main.ts, 101, 12)) +// recursive declarations +declare const rI: RI; +>rI : Symbol(rI, Decl(main.ts, 115, 13)) +>RI : Symbol(RI, Decl(main.ts, 115, 21)) + +interface RI { +>RI : Symbol(RI, Decl(main.ts, 115, 21)) + + x: "a"; +>x : Symbol(RI.x, Decl(main.ts, 116, 14)) + + [rI.x]: "b"; +>rI.x : Symbol(RI.x, Decl(main.ts, 116, 14)) +>rI : Symbol(rI, Decl(main.ts, 115, 13)) +>x : Symbol(RI.x, Decl(main.ts, 116, 14)) +} + +declare const rC: RC; +>rC : Symbol(rC, Decl(main.ts, 121, 13)) +>RC : Symbol(RC, Decl(main.ts, 121, 21)) + +declare class RC { +>RC : Symbol(RC, Decl(main.ts, 121, 21)) + + x: "a"; +>x : Symbol(RC.x, Decl(main.ts, 122, 18)) + + [rC.x]: "b"; +>rC.x : Symbol(RC.x, Decl(main.ts, 122, 18)) +>rC : Symbol(rC, Decl(main.ts, 121, 13)) +>x : Symbol(RC.x, Decl(main.ts, 122, 18)) +} diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index a568000e13ec2..b2125d673069c 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -518,3 +518,35 @@ export const o2: T0 = o1; >T0 : T0 >o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +// recursive declarations +declare const rI: RI; +>rI : RI +>RI : RI + +interface RI { +>RI : RI + + x: "a"; +>x : "a" + + [rI.x]: "b"; +>rI.x : "a" +>rI : RI +>x : "a" +} + +declare const rC: RC; +>rC : RC +>RC : RC + +declare class RC { +>RC : RC + + x: "a"; +>x : "a" + + [rC.x]: "b"; +>rC.x : "a" +>rC : RC +>x : "a" +} diff --git a/tests/baselines/reference/uniqueSymbols.js b/tests/baselines/reference/uniqueSymbols.js index 7da555e6b1f0e..4de307ee197a7 100644 --- a/tests/baselines/reference/uniqueSymbols.js +++ b/tests/baselines/reference/uniqueSymbols.js @@ -111,7 +111,91 @@ const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNest // type argument inference const promiseForConstCall = Promise.resolve(constCall); -const arrayOfConstCall = [constCall]; +const arrayOfConstCall = [constCall]; + +// unique symbol widening in expressions +declare const s: unique symbol; +declare namespace N { const s: unique symbol; } +declare const o: { [s]: "a", [N.s]: "b" }; +declare function f(x: T): T; +declare function g(x: typeof s): void; +declare function g(x: typeof N.s): void; + +// widening positions +// argument inference +f(s); +f(N.s); +f(N["s"]); + +// array literal elements +[s]; +[N.s]; +[N["s"]]; + +// property assignments +const o2 = { + a: s, + b: N.s, + c: N["s"] +}; + +// property initializers +class C0 { + static readonly a = s; + static readonly b = N.s; + static readonly c = N["s"]; + + static d = s; + static e = N.s; + static f = N["s"]; + + readonly a = s; + readonly b = N.s; + readonly c = N["s"]; + + d = s; + e = N.s; + f = N["s"]; +} + +// non-widening positions + +// element access +o[s]; +o[N.s]; +o[N["s"]]; + +// arguments (no-inference) +f(s); +f(N.s); +f(N["s"]); +g(s); +g(N.s); +g(N["s"]); + +// falsy expressions +s || ""; +N.s || ""; +N["s"] || ""; + +// conditionals +Math.random() * 2 ? s : "a"; +Math.random() * 2 ? N.s : "a"; +Math.random() * 2 ? N["s"] : "a"; + +// computed property names +({ + [s]: "a", + [N.s]: "b", +}); + +class C1 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} //// [uniqueSymbols.js] // declarations with call initializer @@ -192,6 +276,65 @@ const constInitToLReadonlyNestedTypeWithIndexedAccess = l.nested.readonlyNestedT // type argument inference const promiseForConstCall = Promise.resolve(constCall); const arrayOfConstCall = [constCall]; +// widening positions +// argument inference +f(s); +f(N.s); +f(N["s"]); +// array literal elements +[s]; +[N.s]; +[N["s"]]; +// property assignments +const o2 = { + a: s, + b: N.s, + c: N["s"] +}; +// property initializers +class C0 { + constructor() { + this.a = s; + this.b = N.s; + this.c = N["s"]; + this.d = s; + this.e = N.s; + this.f = N["s"]; + } +} +C0.a = s; +C0.b = N.s; +C0.c = N["s"]; +C0.d = s; +C0.e = N.s; +C0.f = N["s"]; +// non-widening positions +// element access +o[s]; +o[N.s]; +o[N["s"]]; +// arguments (no-inference) +f(s); +f(N.s); +f(N["s"]); +g(s); +g(N.s); +g(N["s"]); +// falsy expressions +s || ""; +N.s || ""; +N["s"] || ""; +// conditionals +Math.random() * 2 ? s : "a"; +Math.random() * 2 ? N.s : "a"; +Math.random() * 2 ? N["s"] : "a"; +// computed property names +({ + [s]: "a", + [N.s]: "b", +}); +class C1 { +} //// [uniqueSymbols.d.ts] @@ -273,3 +416,39 @@ declare const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"]; declare const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"]; declare const promiseForConstCall: Promise; declare const arrayOfConstCall: symbol[]; +declare const s: unique symbol; +declare namespace N { + const s: unique symbol; +} +declare const o: { + [s]: "a"; + [N.s]: "b"; +}; +declare function f(x: T): T; +declare function g(x: typeof s): void; +declare function g(x: typeof N.s): void; +declare const o2: { + a: symbol; + b: symbol; + c: symbol; +}; +declare class C0 { + static readonly a: symbol; + static readonly b: symbol; + static readonly c: symbol; + static d: symbol; + static e: symbol; + static f: symbol; + readonly a: symbol; + readonly b: symbol; + readonly c: symbol; + d: symbol; + e: symbol; + f: symbol; +} +declare class C1 { + static [s]: "a"; + static [N.s]: "b"; + [s]: "a"; + [N.s]: "b"; +} diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols index 970938094ca98..80c0611ce74b4 100644 --- a/tests/baselines/reference/uniqueSymbols.symbols +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -396,3 +396,275 @@ const arrayOfConstCall = [constCall]; >arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbols.ts, 112, 5)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +// unique symbol widening in expressions +declare const s: unique symbol; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +declare namespace N { const s: unique symbol; } +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 116, 27)) + +declare const o: { [s]: "a", [N.s]: "b" }; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +declare function f(x: T): T; +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 118, 22)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) + +declare function g(x: typeof s): void; +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 119, 19)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +declare function g(x: typeof N.s): void; +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 120, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// widening positions +// argument inference +f(s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +f(N.s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +f(N["s"]); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// array literal elements +[s]; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +[N.s]; +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +[N["s"]]; +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// property assignments +const o2 = { +>o2 : Symbol(o2, Decl(uniqueSymbols.ts, 134, 5)) + + a: s, +>a : Symbol(a, Decl(uniqueSymbols.ts, 134, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + b: N.s, +>b : Symbol(b, Decl(uniqueSymbols.ts, 135, 9)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + c: N["s"] +>c : Symbol(c, Decl(uniqueSymbols.ts, 136, 11)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +}; + +// property initializers +class C0 { +>C0 : Symbol(C0, Decl(uniqueSymbols.ts, 138, 2)) + + static readonly a = s; +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 141, 10)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + static readonly b = N.s; +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 142, 26)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + static readonly c = N["s"]; +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 143, 28)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + static d = s; +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 144, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + static e = N.s; +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 146, 17)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + static f = N["s"]; +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 147, 19)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + readonly a = s; +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 148, 22)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + readonly b = N.s; +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 150, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + readonly c = N["s"]; +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 151, 21)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + d = s; +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 152, 24)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + e = N.s; +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 154, 10)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + f = N["s"]; +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 155, 12)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +} + +// non-widening positions + +// element access +o[s]; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +o[N.s]; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +o[N["s"]]; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// arguments (no-inference) +f(s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +f(N.s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +f(N["s"]); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +g(s); +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +g(N.s); +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +g(N["s"]); +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// falsy expressions +s || ""; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +N.s || ""; +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +N["s"] || ""; +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// conditionals +Math.random() * 2 ? s : "a"; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +Math.random() * 2 ? N.s : "a"; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +Math.random() * 2 ? N["s"] : "a"; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// computed property names +({ + [s]: "a", +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + [N.s]: "b", +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +}); + +class C1 { +>C1 : Symbol(C1, Decl(uniqueSymbols.ts, 188, 3)) + + static [s]: "a"; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + static [N.s]: "b"; +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + [s]: "a"; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + [N.s]: "b"; +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +} diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index 495cf583294e2..3deaf4572f4be 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -414,3 +414,329 @@ const arrayOfConstCall = [constCall]; >[constCall] : symbol[] >constCall : unique symbol +// unique symbol widening in expressions +declare const s: unique symbol; +>s : unique symbol + +declare namespace N { const s: unique symbol; } +>N : typeof N +>s : unique symbol + +declare const o: { [s]: "a", [N.s]: "b" }; +>o : { [s]: "a"; [N.s]: "b"; } +>s : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +declare function f(x: T): T; +>f : (x: T) => T +>T : T +>x : T +>T : T +>T : T + +declare function g(x: typeof s): void; +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>x : unique symbol +>s : unique symbol + +declare function g(x: typeof N.s): void; +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>x : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +// widening positions +// argument inference +f(s); +>f(s) : symbol +>f : (x: T) => T +>s : unique symbol + +f(N.s); +>f(N.s) : symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : symbol +>f : (x: T) => T +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// array literal elements +[s]; +>[s] : symbol[] +>s : unique symbol + +[N.s]; +>[N.s] : symbol[] +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +[N["s"]]; +>[N["s"]] : symbol[] +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// property assignments +const o2 = { +>o2 : { a: symbol; b: symbol; c: symbol; } +>{ a: s, b: N.s, c: N["s"]} : { a: symbol; b: symbol; c: symbol; } + + a: s, +>a : symbol +>s : unique symbol + + b: N.s, +>b : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + c: N["s"] +>c : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +}; + +// property initializers +class C0 { +>C0 : C0 + + static readonly a = s; +>a : symbol +>s : unique symbol + + static readonly b = N.s; +>b : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + static readonly c = N["s"]; +>c : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + static d = s; +>d : symbol +>s : unique symbol + + static e = N.s; +>e : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + static f = N["s"]; +>f : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + readonly a = s; +>a : symbol +>s : unique symbol + + readonly b = N.s; +>b : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + readonly c = N["s"]; +>c : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + d = s; +>d : symbol +>s : unique symbol + + e = N.s; +>e : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + f = N["s"]; +>f : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" +} + +// non-widening positions + +// element access +o[s]; +>o[s] : "a" +>o : { [s]: "a"; [N.s]: "b"; } +>s : unique symbol + +o[N.s]; +>o[N.s] : "b" +>o : { [s]: "a"; [N.s]: "b"; } +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +o[N["s"]]; +>o[N["s"]] : "b" +>o : { [s]: "a"; [N.s]: "b"; } +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// arguments (no-inference) +f(s); +>f(s) : unique symbol +>f : (x: T) => T +>s : unique symbol +>s : unique symbol + +f(N.s); +>f(N.s) : unique symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : unique symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +g(s); +>g(s) : void +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>s : unique symbol + +g(N.s); +>g(N.s) : void +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +g(N["s"]); +>g(N["s"]) : void +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// falsy expressions +s || ""; +>s || "" : unique symbol | "" +>s : unique symbol +>"" : "" + +N.s || ""; +>N.s || "" : unique symbol | "" +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>"" : "" + +N["s"] || ""; +>N["s"] || "" : unique symbol | "" +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" +>"" : "" + +// conditionals +Math.random() * 2 ? s : "a"; +>Math.random() * 2 ? s : "a" : unique symbol | "a" +>Math.random() * 2 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>2 : 2 +>s : unique symbol +>"a" : "a" + +Math.random() * 2 ? N.s : "a"; +>Math.random() * 2 ? N.s : "a" : unique symbol | "a" +>Math.random() * 2 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>2 : 2 +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>"a" : "a" + +Math.random() * 2 ? N["s"] : "a"; +>Math.random() * 2 ? N["s"] : "a" : unique symbol | "a" +>Math.random() * 2 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>2 : 2 +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" +>"a" : "a" + +// computed property names +({ +>({ [s]: "a", [N.s]: "b",}) : { [s]: string; [N.s]: string; } +>{ [s]: "a", [N.s]: "b",} : { [s]: string; [N.s]: string; } + + [s]: "a", +>s : unique symbol +>"a" : "a" + + [N.s]: "b", +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>"b" : "b" + +}); + +class C1 { +>C1 : C1 + + static [s]: "a"; +>s : unique symbol + + static [N.s]: "b"; +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + [s]: "a"; +>s : unique symbol + + [N.s]: "b"; +>N.s : unique symbol +>N : typeof N +>s : unique symbol +} diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts index 2184ee73b33c5..9562685b08f7a 100644 --- a/tests/cases/compiler/dynamicNames.ts +++ b/tests/cases/compiler/dynamicNames.ts @@ -137,4 +137,17 @@ export const o1_c4 = o1[c4]; export const o1_c5 = o1[c5]; export const o1_s2 = o1[s2]; -export const o2: T0 = o1; \ No newline at end of file +export const o2: T0 = o1; + +// recursive declarations +declare const rI: RI; +interface RI { + x: "a"; + [rI.x]: "b"; +} + +declare const rC: RC; +declare class RC { + x: "a"; + [rC.x]: "b"; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts index 66b9a08169192..a804ed8d20a44 100644 --- a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts @@ -114,4 +114,88 @@ const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNest // type argument inference const promiseForConstCall = Promise.resolve(constCall); -const arrayOfConstCall = [constCall]; \ No newline at end of file +const arrayOfConstCall = [constCall]; + +// unique symbol widening in expressions +declare const s: unique symbol; +declare namespace N { const s: unique symbol; } +declare const o: { [s]: "a", [N.s]: "b" }; +declare function f(x: T): T; +declare function g(x: typeof s): void; +declare function g(x: typeof N.s): void; + +// widening positions +// argument inference +f(s); +f(N.s); +f(N["s"]); + +// array literal elements +[s]; +[N.s]; +[N["s"]]; + +// property assignments +const o2 = { + a: s, + b: N.s, + c: N["s"] +}; + +// property initializers +class C0 { + static readonly a = s; + static readonly b = N.s; + static readonly c = N["s"]; + + static d = s; + static e = N.s; + static f = N["s"]; + + readonly a = s; + readonly b = N.s; + readonly c = N["s"]; + + d = s; + e = N.s; + f = N["s"]; +} + +// non-widening positions + +// element access +o[s]; +o[N.s]; +o[N["s"]]; + +// arguments (no-inference) +f(s); +f(N.s); +f(N["s"]); +g(s); +g(N.s); +g(N["s"]); + +// falsy expressions +s || ""; +N.s || ""; +N["s"] || ""; + +// conditionals +Math.random() * 2 ? s : "a"; +Math.random() * 2 ? N.s : "a"; +Math.random() * 2 ? N["s"] : "a"; + +// computed property names +({ + [s]: "a", + [N.s]: "b", +}); + +class C1 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} \ No newline at end of file From 0b31860c721e94bc3e64bd44a065fe14af2f0051 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 20 Oct 2017 22:58:52 -0700 Subject: [PATCH 28/43] Revert some minor changes to clean up PR --- src/compiler/checker.ts | 84 ++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1a3cb8f66630f..360b7c8800e84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9142,8 +9142,12 @@ namespace ts { } function isTypeRelatedTo(source: Type, target: Type, relation: Map) { - source = getRegularTypeOfLiteralType(source); - target = getRegularTypeOfLiteralType(target); + if (source.flags & TypeFlags.StringOrNumberLiteral && source.flags & TypeFlags.FreshLiteral) { + source = (source).regularType; + } + if (target.flags & TypeFlags.StringOrNumberLiteral && target.flags & TypeFlags.FreshLiteral) { + target = (target).regularType; + } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } @@ -9274,8 +9278,12 @@ namespace ts { * * Ternary.False if they are not related. */ function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { - source = getRegularTypeOfLiteralType(source); - target = getRegularTypeOfLiteralType(target); + if (source.flags & TypeFlags.StringOrNumberLiteral && source.flags & TypeFlags.FreshLiteral) { + source = (source).regularType; + } + if (target.flags & TypeFlags.StringOrNumberLiteral && target.flags & TypeFlags.FreshLiteral) { + target = (target).regularType; + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; @@ -17205,36 +17213,6 @@ namespace ts { return globalESSymbol === resolveName(left, "Symbol" as __String, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } - function isCommonJsRequire(node: Node) { - if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { - return false; - } - - // Make sure require is not a local function - if (!isIdentifier(node.expression)) throw Debug.fail(); - const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (!resolvedRequire) { - // project does not contain symbol named 'require' - assume commonjs require - return true; - } - // project includes symbol named 'require' - make sure that it it ambient and local non-alias - if (resolvedRequire.flags & SymbolFlags.Alias) { - return false; - } - - const targetDeclarationKind = resolvedRequire.flags & SymbolFlags.Function - ? SyntaxKind.FunctionDeclaration - : resolvedRequire.flags & SymbolFlags.Variable - ? SyntaxKind.VariableDeclaration - : SyntaxKind.Unknown; - if (targetDeclarationKind !== SyntaxKind.Unknown) { - const decl = getDeclarationOfKind(resolvedRequire, targetDeclarationKind); - // function/variable declaration should be ambient - return isInAmbientContext(decl); - } - return false; - } - function checkImportCallExpression(node: ImportCall): Type { // Check grammar of dynamic import checkGrammarArguments(node.arguments) || checkGrammarImportCallExpression(node); @@ -17287,6 +17265,36 @@ namespace ts { return type; } + function isCommonJsRequire(node: Node) { + if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + return false; + } + + // Make sure require is not a local function + if (!isIdentifier(node.expression)) throw Debug.fail(); + const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + if (!resolvedRequire) { + // project does not contain symbol named 'require' - assume commonjs require + return true; + } + // project includes symbol named 'require' - make sure that it it ambient and local non-alias + if (resolvedRequire.flags & SymbolFlags.Alias) { + return false; + } + + const targetDeclarationKind = resolvedRequire.flags & SymbolFlags.Function + ? SyntaxKind.FunctionDeclaration + : resolvedRequire.flags & SymbolFlags.Variable + ? SyntaxKind.VariableDeclaration + : SyntaxKind.Unknown; + if (targetDeclarationKind !== SyntaxKind.Unknown) { + const decl = getDeclarationOfKind(resolvedRequire, targetDeclarationKind); + // function/variable declaration should be ambient + return isInAmbientContext(decl); + } + return false; + } + function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { if (languageVersion < ScriptTarget.ES2015) { checkExternalEmitHelpers(node, ExternalEmitHelpers.MakeTemplateObject); @@ -24384,11 +24392,9 @@ namespace ts { function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { // Get type of the symbol if this is the valid symbol otherwise get type at location const symbol = getSymbolOfNode(declaration); - let type: Type = unknownType; - if (symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature))) { - type = getTypeOfSymbol(symbol); - type = getWidenedLiteralType(type); - } + let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) + ? getWidenedLiteralType(getTypeOfSymbol(symbol)) + : unknownType; if (flags & TypeFormatFlags.AddUndefined) { type = getNullableType(type, TypeFlags.Undefined); } From ccd98af1ba334400d536c4057cacbba7d12e1f4e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 20 Oct 2017 23:05:03 -0700 Subject: [PATCH 29/43] Simplify property symbol logic in checkObjectLiteral --- src/compiler/checker.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 360b7c8800e84..ea9c428603817 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5459,7 +5459,7 @@ namespace ts { if (!(type).declaredProperties) { const symbol = type.symbol; const members = getMembersOfSymbol(symbol); - (type).declaredProperties = getNamedMembers(getMembersOfSymbol(symbol)); + (type).declaredProperties = getNamedMembers(members); (type).declaredCallSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.Call)); (type).declaredConstructSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.New)); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); @@ -14222,17 +14222,10 @@ namespace ts { typeFlags |= type.flags; - let prop: TransientSymbol; - if (hasLateBindableName(memberDecl)) { - const nameType = checkComputedPropertyName(memberDecl.name); - if (nameType && isTypeUsableAsLateBoundName(nameType)) { - prop = createSymbol(SymbolFlags.Property | SymbolFlags.Late | member.flags, getLateBoundNameFromType(nameType)); - } - } - - if (!prop) { - prop = createSymbol(SymbolFlags.Property | member.flags, literalName || member.escapedName); - } + const nameType = hasLateBindableName(memberDecl) ? checkComputedPropertyName(memberDecl.name) : undefined; + const prop = nameType && isTypeUsableAsLateBoundName(nameType) + ? createSymbol(SymbolFlags.Property | SymbolFlags.Late | member.flags, getLateBoundNameFromType(nameType)) + : createSymbol(SymbolFlags.Property | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value From b5a7b036c32a58592c5cabd9747fa8f8b2981917 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 20 Oct 2017 23:51:58 -0700 Subject: [PATCH 30/43] Address PR feedback --- src/compiler/checker.ts | 62 ++--- src/compiler/diagnosticMessages.json | 32 +-- src/compiler/types.ts | 5 + src/compiler/utilities.ts | 21 +- .../reference/api/tsserverlibrary.d.ts | 4 +- tests/baselines/reference/api/typescript.d.ts | 4 +- .../reference/uniqueSymbolsErrors.errors.txt | 236 +++++++++--------- 7 files changed, 174 insertions(+), 190 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ea9c428603817..63977ffd41c36 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 87fd4db040786..7d1afd98e9933 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.": { - "category": "Error", - "code": 1330 - }, - "'unique symbol' types are not allowed in an intersection type.": { - "category": "Error", - "code": 1331 - }, - "'unique symbol' types are not allowed in an array type.": { - "category": "Error", - "code": 1332 - }, - "'unique symbol' types are not allowed in a tuple type.": { - "category": "Error", - "code": 1333 - }, - "'unique symbol' types are not allowed in a mapped type.": { - "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 + "code": 1330 }, "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.": { "category": "Error", - "code": 1336 + "code": 1331 }, "A variable whose type is a 'unique symbol' type must be 'const'.": { "category": "Error", - "code": 1337 + "code": 1332 }, "'unique symbol' types may not be used on a variable declaration with a binding name.": { "category": "Error", - "code": 1338 + "code": 1333 }, "'unique symbol' types are only allowed on variables in a variable statement.": { "category": "Error", - "code": 1339 + "code": 1334 }, "'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 a3a522cec2756..051bbe305c9fc 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 71d30a1ab9b9e..2ec5134d7e365 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 89f6c27614113..b1cc56ad8ce8c 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 30c5cfd0233c3..226b2acfd52e9 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 de4c8f981bd10..4f49e7b096c13 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 From 3febc802cf3703a205851af41c49330a175abbac Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 26 Oct 2017 14:50:41 -0700 Subject: [PATCH 31/43] More repetitive but less complex widening logic for literals/symbols --- src/compiler/checker.ts | 62 +++++-------------- src/compiler/types.ts | 3 - .../reference/api/tsserverlibrary.d.ts | 2 - tests/baselines/reference/api/typescript.d.ts | 2 - 4 files changed, 16 insertions(+), 53 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index adace49161843..47ebf0bd5b0d3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10647,61 +10647,31 @@ namespace ts { type; } - function getWidenedLiteralLikeMapper(wideningFlags: TypeFlags) { - return !(wideningFlags & TypeFlags.UniqueESSymbol) ? getWidenedLiteralType : - !(wideningFlags & TypeFlags.WidenableLiteral) ? getWidenedUniqueESSymbolType : - getWidenedLiteralLikeType; - } - - /** - * Widens string literal, number literal, boolean literal, enum literal, and unique symbol - * types, as well as unions of the same. - * - * We don't always want to widen literals in all of the same places we widen unique symbol - * types, and vice versa. However, there are some cases where we do widen both sets of - * types at the same time. - * - * In general, this function should not be called directly. Instead it should be called - * through either `getWidenedLiteralType` (which does not widen unique symbol types), - * `getWidenedUniqueESSymbolType` (which only widenes unique symbol types), or - * `getWidenedLiteralLikeType` (which widens both). - */ - function getWidenedLiteralLikeTypeWorker(type: Type, wideningFlags: TypeFlags): Type { - return type.flags & wideningFlags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : - type.flags & wideningFlags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : - type.flags & wideningFlags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : - type.flags & wideningFlags & TypeFlags.BooleanLiteral ? booleanType : - type.flags & wideningFlags & TypeFlags.UniqueESSymbol ? esSymbolType : - type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedLiteralLikeMapper(wideningFlags))) : - type; - } - - /** - * Widens string literal, number literal, boolean literal, enum literal, and unique symbol - * types, as well as unions of the same. - */ function getWidenedLiteralLikeType(type: Type): Type { - return getWidenedLiteralLikeTypeWorker(type, TypeFlags.WidenableLiteralLike); + return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : + type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : + type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : + type.flags & TypeFlags.BooleanLiteral ? booleanType : + type.flags & TypeFlags.UniqueESSymbol ? esSymbolType : + type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedLiteralLikeType)) : + type; } - /** - * Widens string literal, number literal, boolean literal, and enum literal types, as well - * as unions of the same. - */ function getWidenedLiteralType(type: Type): Type { - return getWidenedLiteralLikeTypeWorker(type, TypeFlags.WidenableLiteral); + return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : + type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : + type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : + type.flags & TypeFlags.BooleanLiteral ? booleanType : + type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedLiteralType)) : + type; } - /** - * Widens unique symbol types and unions of unique symbol types. - */ function getWidenedUniqueESSymbolType(type: Type): Type { - return getWidenedLiteralLikeTypeWorker(type, TypeFlags.UniqueESSymbol); + return type.flags & TypeFlags.UniqueESSymbol ? esSymbolType : + type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedUniqueESSymbolType)) : + type; } - /** - * Widens a literal-like type when the contextual type is not literal-like. - */ function getWidenedLiteralLikeTypeForContextualType(type: Type, contextualType: Type) { const widenLiterals = !isLiteralContextualType(contextualType); const widenSymbols = !isUniqueESSymbolContextualType(contextualType); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fa1127f8fd04c..21ee4af65ecf6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3306,9 +3306,6 @@ namespace ts { RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType, - - WidenableLiteral = Literal | EnumLiteral, - WidenableLiteralLike = WidenableLiteral | UniqueESSymbol, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 62fd09d44db5c..0b92c4c00a241 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2012,8 +2012,6 @@ 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 ed1f07fb0a104..0c5d2b56fc022 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2012,8 +2012,6 @@ declare namespace ts { TypeVariable = 1081344, Narrowable = 35620607, NotUnionOrUnit = 33620481, - WidenableLiteral = 480, - WidenableLiteralLike = 1504, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { From 170e6ec1305fae1e3b5115a9581b9c51cf98e020 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 26 Oct 2017 15:50:07 -0700 Subject: [PATCH 32/43] Ensure correct errors when emitting declarations --- src/compiler/checker.ts | 14 +- src/compiler/declarationEmitter.ts | 128 ++++++++++++++---- src/compiler/diagnosticMessages.json | 33 +++++ src/compiler/types.ts | 9 +- src/compiler/utilities.ts | 2 +- .../reference/dynamicNamesErrors.errors.txt | 89 +++++++++++- .../baselines/reference/dynamicNamesErrors.js | 55 +++++++- .../reference/dynamicNamesErrors.symbols | 86 +++++++++++- .../reference/dynamicNamesErrors.types | 98 +++++++++++++- tests/cases/compiler/dynamicNamesErrors.ts | 36 ++++- 10 files changed, 488 insertions(+), 62 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 47ebf0bd5b0d3..1a8c2a09f040a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24569,14 +24569,6 @@ namespace ts { return undefined; } - function isLiteralDynamicName(name: ComputedPropertyName) { - name = getParseTreeNode(name, isComputedPropertyName); - if (name) { - return isLateBindableName(name); - } - return false; - } - function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { if (isConst(node)) { const type = getTypeOfSymbol(getSymbolOfNode(node)); @@ -24650,7 +24642,11 @@ namespace ts { getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration, - isLiteralDynamicName, + isLateBound: (node: Declaration): node is LateBoundDeclaration => { + node = getParseTreeNode(node, isDeclaration); + const symbol = node && getSymbolOfNode(node); + return !!(symbol && symbol.flags & SymbolFlags.Late); + }, writeLiteralConstValue, getJsxFactoryEntity: () => _jsxFactoryEntity }; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index cf702d2407706..2efea500a9bd6 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -1227,7 +1227,7 @@ namespace ts { } function emitPropertyDeclaration(node: Declaration) { - if (hasDynamicName(node) && !resolver.isLiteralDynamicName(getNameOfDeclaration(node))) { + if (hasDynamicName(node) && !resolver.isLateBound(node)) { return; } @@ -1246,17 +1246,8 @@ namespace ts { emitBindingPattern(node.name); } else { - if (isDynamicName(node.name)) { - // If this node has a dynamic name, it can only be an identifier or property access because - // we've already skipped it otherwise. - emitDynamicName((node.name).expression); - } - else { - // If this node is a computed name, it can only be a symbol, because we've already skipped - // it if it's not a well known symbol. In that case, the text of the name will be exactly - // what we want, namely the name expression enclosed in brackets. - writeTextOfNode(currentText, node.name); - } + writeNameOfDeclaration(node, getVariableDeclarationTypeOrNameVisibilityError); + // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || @@ -1271,12 +1262,12 @@ namespace ts { resolver.writeLiteralConstValue(node, writer); } else if (!hasModifier(node, ModifierFlags.Private)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeOrNameVisibilityError); } } } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + function getVariableDeclarationTypeOrNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { if (node.kind === SyntaxKind.VariableDeclaration) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? @@ -1312,8 +1303,8 @@ namespace ts { } } - function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { - const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); + function getVariableDeclarationTypeOrNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + const diagnosticMessage = getVariableDeclarationTypeOrNameVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: node, @@ -1321,14 +1312,6 @@ namespace ts { } : undefined; } - function emitDynamicName(entityName: EntityNameExpression) { - writer.getSymbolAccessibilityDiagnostic = getVariableDeclarationTypeVisibilityError; - const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration); - handleSymbolAccessibilityError(visibilityResult); - recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); - writeTextOfNode(currentText, node.name); - } - function emitBindingPattern(bindingPattern: BindingPattern) { // Only select non-omitted expression from the bindingPattern's elements. // We have to do this to avoid emitting trailing commas. @@ -1346,7 +1329,7 @@ namespace ts { function emitBindingElement(bindingElement: BindingElement) { function getBindingElementTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { - const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); + const diagnosticMessage = getVariableDeclarationTypeOrNameVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: bindingElement, @@ -1402,7 +1385,7 @@ namespace ts { } function emitAccessorDeclaration(node: AccessorDeclaration) { - if (hasDynamicName(node)) { + if (hasDynamicName(node) && !resolver.isLateBound(node)) { return; } @@ -1413,7 +1396,7 @@ namespace ts { emitJsDocComments(accessors.getAccessor); emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(getModifierFlags(node) | (accessors.setAccessor ? 0 : ModifierFlags.Readonly)); - writeTextOfNode(currentText, node.name); + writeNameOfDeclaration(node, getAccessorNameVisibilityError); if (!hasModifier(node, ModifierFlags.Private)) { accessorWithTypeAnnotation = node; let type = getTypeAnnotationFromAccessor(node); @@ -1441,6 +1424,37 @@ namespace ts { } } + function getAccessorNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) { + const diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + + function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (hasModifier(node, ModifierFlags.Static)) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccessibilityResult.errorModuleName ? + Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; if (accessorWithTypeAnnotation.kind === SyntaxKind.SetAccessor) { @@ -1487,7 +1501,7 @@ namespace ts { } function writeFunctionDeclaration(node: FunctionLikeDeclaration) { - if (hasDynamicName(node)) { + if (hasDynamicName(node) && !resolver.isLateBound(node)) { return; } @@ -1509,13 +1523,69 @@ namespace ts { write("constructor"); } else { - writeTextOfNode(currentText, node.name); + writeNameOfDeclaration(node, getMethodNameVisibilityError); if (hasQuestionToken(node)) { write("?"); } } emitSignatureDeclaration(node); } + + function getMethodNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + const diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + + function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (hasModifier(node, ModifierFlags.Static)) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccessibilityResult.errorModuleName ? + Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + } + + function writeNameOfDeclaration(node: NamedDeclaration, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { + if (hasDynamicName(node)) { + // If this node has a dynamic name, it can only be an identifier or property access because + // we've already skipped it otherwise. + Debug.assert(resolver.isLateBound(node)); + + writeLateBoundNameOfDeclaration(node as LateBoundDeclaration, getSymbolAccessibilityDiagnostic); + } + else { + // If this node is a computed name, it can only be a symbol, because we've already skipped + // it if it's not a well known symbol. In that case, the text of the name will be exactly + // what we want, namely the name expression enclosed in brackets. + writeTextOfNode(currentText, node.name); + } + } + + function writeLateBoundNameOfDeclaration(node: LateBoundDeclaration, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + const entityName = node.name.expression; + const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration); + handleSymbolAccessibilityError(visibilityResult); + recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); + writeTextOfNode(currentText, node.name); } function emitSignatureDeclarationWithJsDocComments(node: SignatureDeclaration) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index dc8ef6cdac5fe..7734012c97d4a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2562,6 +2562,39 @@ "code": 4094 }, + "Public static method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 4095 + }, + "Public static method '{0}' of exported class has or is using name '{1}' from private module '{2}'.": { + "category": "Error", + "code": 4096 + }, + "Public static method '{0}' of exported class has or is using private name '{1}'.": { + "category": "Error", + "code": 4097 + }, + "Public method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 4098 + }, + "Public method '{0}' of exported class has or is using name '{1}' from private module '{2}'.": { + "category": "Error", + "code": 4099 + }, + "Public method '{0}' of exported class has or is using private name '{1}'.": { + "category": "Error", + "code": 4100 + }, + "Method '{0}' of exported interface has or is using name '{1}' from private module '{2}'.": { + "category": "Error", + "code": 4101 + }, + "Method '{0}' of exported interface has or is using private name '{1}'.": { + "category": "Error", + "code": 4102 + }, + "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 21ee4af65ecf6..f4cc88e9a316c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -662,9 +662,14 @@ namespace ts { name?: DeclarationName; } + /* @internal */ + export interface DynamicNamedDeclaration extends NamedDeclaration { + name: ComputedPropertyName; + } + /* @internal */ // A declaration that supports late-binding (used in checker) - export interface LateBoundDeclaration extends NamedDeclaration { + export interface LateBoundDeclaration extends DynamicNamedDeclaration { name: LateBoundName; } @@ -2945,7 +2950,7 @@ namespace ts { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; - isLiteralDynamicName(node: ComputedPropertyName): boolean; + isLateBound(node: Declaration): node is LateBoundDeclaration; collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined; isRequiredInitializedParameter(node: ParameterDeclaration): boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 82cad54bf6d95..b2ece2421abd5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2001,7 +2001,7 @@ namespace ts { * is a property of the Symbol constructor that denotes a built in * Symbol. */ - export function hasDynamicName(declaration: Declaration): boolean { + export function hasDynamicName(declaration: Declaration): declaration is DynamicNamedDeclaration { const name = getNameOfDeclaration(declaration); return name && isDynamicName(name); } diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index 2e7525e250843..15722ed1a4982 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -7,10 +7,25 @@ tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not assignable to type 'T2'. Types of property '[c0]' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/compiler/dynamicNamesErrors.ts(28,6): error TS4033: Property '[c0]' of exported interface has or is using private name 'c0'. +tests/cases/compiler/dynamicNamesErrors.ts(33,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(34,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(38,13): error TS4028: Public static property '[x]' of exported class has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(39,13): error TS4097: Public static method '[y]' of exported class has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(40,17): error TS4028: Public static property '[z]' of exported class has or is using private name 'z'. +tests/cases/compiler/dynamicNamesErrors.ts(41,17): error TS4028: Public static property '[w]' of exported class has or is using private name 'w'. +tests/cases/compiler/dynamicNamesErrors.ts(43,6): error TS4031: Public property '[x]' of exported class has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(44,6): error TS4100: Public method '[y]' of exported class has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(45,10): error TS4031: Public property '[z]' of exported class has or is using private name 'z'. +tests/cases/compiler/dynamicNamesErrors.ts(46,10): error TS4031: Public property '[w]' of exported class has or is using private name 'w'. +tests/cases/compiler/dynamicNamesErrors.ts(50,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(51,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'. -==== tests/cases/compiler/dynamicNamesErrors.ts (6 errors) ==== +==== tests/cases/compiler/dynamicNamesErrors.ts (21 errors) ==== const c0 = "1"; const c1 = 1; @@ -51,8 +66,68 @@ tests/cases/compiler/dynamicNamesErrors.ts(28,6): error TS4033: Property '[c0]' !!! error TS2322: Types of property '[c0]' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. - export interface T4 { - [c0]: number; - ~~ -!!! error TS4033: Property '[c0]' of exported interface has or is using private name 'c0'. - } \ No newline at end of file + const x = Symbol(); + const y = Symbol(); + const z = Symbol(); + const w = Symbol(); + + export interface InterfaceMemberVisibility { + [x]: number; + ~ +!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'. + [y](): number; + ~ +!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'. + } + + export class ClassMemberVisibility { + static [x]: number; + ~ +!!! error TS4028: Public static property '[x]' of exported class has or is using private name 'x'. + static [y](): number { return 0; } + ~ +!!! error TS4097: Public static method '[y]' of exported class has or is using private name 'y'. + static get [z](): number { return 0; } + ~ +!!! error TS4028: Public static property '[z]' of exported class has or is using private name 'z'. + static set [w](value: number) { } + ~ +!!! error TS4028: Public static property '[w]' of exported class has or is using private name 'w'. + + [x]: number; + ~ +!!! error TS4031: Public property '[x]' of exported class has or is using private name 'x'. + [y](): number { return 0; } + ~ +!!! error TS4100: Public method '[y]' of exported class has or is using private name 'y'. + get [z](): number { return 0; } + ~ +!!! error TS4031: Public property '[z]' of exported class has or is using private name 'z'. + set [w](value: number) { } + ~ +!!! error TS4031: Public property '[w]' of exported class has or is using private name 'w'. + } + + export type ObjectTypeVisibility = { + [x]: number; + ~ +!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'. + [y](): number; + ~ +!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'. + }; + + export const ObjectLiteralVisibility = { + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'. + [x]: 0, + [y](): number { return 0; }, + get [z](): number { return 0; }, + set [w](value: number) { }, + }; \ No newline at end of file diff --git a/tests/baselines/reference/dynamicNamesErrors.js b/tests/baselines/reference/dynamicNamesErrors.js index ec4fb8114cbf2..dbea91fcb0153 100644 --- a/tests/baselines/reference/dynamicNamesErrors.js +++ b/tests/baselines/reference/dynamicNamesErrors.js @@ -25,9 +25,39 @@ let t2: T2; t1 = t2; t2 = t1; -export interface T4 { - [c0]: number; -} +const x = Symbol(); +const y = Symbol(); +const z = Symbol(); +const w = Symbol(); + +export interface InterfaceMemberVisibility { + [x]: number; + [y](): number; +} + +export class ClassMemberVisibility { + static [x]: number; + static [y](): number { return 0; } + static get [z](): number { return 0; } + static set [w](value: number) { } + + [x]: number; + [y](): number { return 0; } + get [z](): number { return 0; } + set [w](value: number) { } +} + +export type ObjectTypeVisibility = { + [x]: number; + [y](): number; +}; + +export const ObjectLiteralVisibility = { + [x]: 0, + [y](): number { return 0; }, + get [z](): number { return 0; }, + set [w](value: number) { }, +}; //// [dynamicNamesErrors.js] "use strict"; @@ -38,3 +68,22 @@ let t1; let t2; t1 = t2; t2 = t1; +const x = Symbol(); +const y = Symbol(); +const z = Symbol(); +const w = Symbol(); +class ClassMemberVisibility { + static [y]() { return 0; } + static get [z]() { return 0; } + static set [w](value) { } + [y]() { return 0; } + get [z]() { return 0; } + set [w](value) { } +} +exports.ClassMemberVisibility = ClassMemberVisibility; +exports.ObjectLiteralVisibility = { + [x]: 0, + [y]() { return 0; }, + get [z]() { return 0; }, + set [w](value) { }, +}; diff --git a/tests/baselines/reference/dynamicNamesErrors.symbols b/tests/baselines/reference/dynamicNamesErrors.symbols index cc8c3a2e6cfc8..30ba78a99a311 100644 --- a/tests/baselines/reference/dynamicNamesErrors.symbols +++ b/tests/baselines/reference/dynamicNamesErrors.symbols @@ -54,9 +54,87 @@ t2 = t1; >t2 : Symbol(t2, Decl(dynamicNamesErrors.ts, 22, 3)) >t1 : Symbol(t1, Decl(dynamicNamesErrors.ts, 21, 3)) -export interface T4 { ->T4 : Symbol(T4, Decl(dynamicNamesErrors.ts, 24, 8)) +const x = Symbol(); +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) - [c0]: number; ->c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) +const y = Symbol(); +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +const z = Symbol(); +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +const w = Symbol(); +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +export interface InterfaceMemberVisibility { +>InterfaceMemberVisibility : Symbol(InterfaceMemberVisibility, Decl(dynamicNamesErrors.ts, 29, 19)) + + [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number; +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) } + +export class ClassMemberVisibility { +>ClassMemberVisibility : Symbol(ClassMemberVisibility, Decl(dynamicNamesErrors.ts, 34, 1)) + + static [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + static [y](): number { return 0; } +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + + static get [z](): number { return 0; } +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) + + static set [w](value: number) { } +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>value : Symbol(value, Decl(dynamicNamesErrors.ts, 40, 19)) + + [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number { return 0; } +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + + get [z](): number { return 0; } +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) + + set [w](value: number) { } +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>value : Symbol(value, Decl(dynamicNamesErrors.ts, 45, 12)) +} + +export type ObjectTypeVisibility = { +>ObjectTypeVisibility : Symbol(ObjectTypeVisibility, Decl(dynamicNamesErrors.ts, 46, 1)) + + [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number; +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + +}; + +export const ObjectLiteralVisibility = { +>ObjectLiteralVisibility : Symbol(ObjectLiteralVisibility, Decl(dynamicNamesErrors.ts, 53, 12)) + + [x]: 0, +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number { return 0; }, +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + + get [z](): number { return 0; }, +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) + + set [w](value: number) { }, +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>value : Symbol(value, Decl(dynamicNamesErrors.ts, 57, 12)) + +}; diff --git a/tests/baselines/reference/dynamicNamesErrors.types b/tests/baselines/reference/dynamicNamesErrors.types index afee89cf39791..3e3f71ec1410e 100644 --- a/tests/baselines/reference/dynamicNamesErrors.types +++ b/tests/baselines/reference/dynamicNamesErrors.types @@ -58,9 +58,99 @@ t2 = t1; >t2 : T2 >t1 : T1 -export interface T4 { ->T4 : T4 +const x = Symbol(); +>x : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const y = Symbol(); +>y : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const z = Symbol(); +>z : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const w = Symbol(); +>w : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +export interface InterfaceMemberVisibility { +>InterfaceMemberVisibility : InterfaceMemberVisibility + + [x]: number; +>x : unique symbol + + [y](): number; +>y : unique symbol +} - [c0]: number; ->c0 : "1" +export class ClassMemberVisibility { +>ClassMemberVisibility : ClassMemberVisibility + + static [x]: number; +>x : unique symbol + + static [y](): number { return 0; } +>y : unique symbol +>0 : 0 + + static get [z](): number { return 0; } +>z : unique symbol +>0 : 0 + + static set [w](value: number) { } +>w : unique symbol +>value : number + + [x]: number; +>x : unique symbol + + [y](): number { return 0; } +>y : unique symbol +>0 : 0 + + get [z](): number { return 0; } +>z : unique symbol +>0 : 0 + + set [w](value: number) { } +>w : unique symbol +>value : number } + +export type ObjectTypeVisibility = { +>ObjectTypeVisibility : ObjectTypeVisibility + + [x]: number; +>x : unique symbol + + [y](): number; +>y : unique symbol + +}; + +export const ObjectLiteralVisibility = { +>ObjectLiteralVisibility : { [x]: number; [y](): number; readonly [z]: number; [w]: number; } +>{ [x]: 0, [y](): number { return 0; }, get [z](): number { return 0; }, set [w](value: number) { },} : { [x]: number; [y](): number; readonly [z]: number; [w]: number; } + + [x]: 0, +>x : unique symbol +>0 : 0 + + [y](): number { return 0; }, +>y : unique symbol +>0 : 0 + + get [z](): number { return 0; }, +>z : unique symbol +>0 : 0 + + set [w](value: number) { }, +>w : unique symbol +>value : number + +}; diff --git a/tests/cases/compiler/dynamicNamesErrors.ts b/tests/cases/compiler/dynamicNamesErrors.ts index cb8377677327a..daeb5cb600b93 100644 --- a/tests/cases/compiler/dynamicNamesErrors.ts +++ b/tests/cases/compiler/dynamicNamesErrors.ts @@ -27,6 +27,36 @@ let t2: T2; t1 = t2; t2 = t1; -export interface T4 { - [c0]: number; -} \ No newline at end of file +const x = Symbol(); +const y = Symbol(); +const z = Symbol(); +const w = Symbol(); + +export interface InterfaceMemberVisibility { + [x]: number; + [y](): number; +} + +export class ClassMemberVisibility { + static [x]: number; + static [y](): number { return 0; } + static get [z](): number { return 0; } + static set [w](value: number) { } + + [x]: number; + [y](): number { return 0; } + get [z](): number { return 0; } + set [w](value: number) { } +} + +export type ObjectTypeVisibility = { + [x]: number; + [y](): number; +}; + +export const ObjectLiteralVisibility = { + [x]: 0, + [y](): number { return 0; }, + get [z](): number { return 0; }, + set [w](value: number) { }, +}; \ No newline at end of file From 44117e19eaee6790d5149c32d3aad9035a2d0e65 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 26 Oct 2017 17:57:54 -0700 Subject: [PATCH 33/43] Reduce noise in PR, minor cleanup --- src/compiler/checker.ts | 57 ++++--------------- src/compiler/declarationEmitter.ts | 38 ++++++------- src/compiler/parser.ts | 4 +- src/compiler/types.ts | 7 +-- src/compiler/utilities.ts | 17 +++--- .../reference/api/tsserverlibrary.d.ts | 1 - tests/baselines/reference/api/typescript.d.ts | 1 - 7 files changed, 42 insertions(+), 83 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1a8c2a09f040a..416d3296151da 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1910,13 +1910,13 @@ namespace ts { const links = getSymbolLinks(symbol); if (!links.resolvedExports) { const earlySymbols = symbol.flags & SymbolFlags.Module ? getExportsOfModuleWorker(symbol) : symbol.exports; - const lateSymbols = getLateBoundExportsOfSymbol(symbol); // In the event we recursively resolve the members of the symbol, we // should only see the early-bound members of the symbol here. links.resolvedExports = earlySymbols || emptySymbols; // fill in any as-yet-unresolved late-bound members. + const lateSymbols = createSymbolTable(); for (const decl of symbol.declarations) { const members = getMembersOfDeclaration(decl); if (members) { @@ -5561,26 +5561,6 @@ namespace ts { } } - /** - * Gets the symbol table used to store members added during late-binding. - * This table is filled in as the late-bound names for dynamic members are resolved. - */ - function getLateBoundMembersOfSymbol(symbol: Symbol): SymbolTable { - Debug.assert(!!(symbol.flags & SymbolFlags.LateBindableContainer), "Expected a container that supports late-binding."); - const links = getSymbolLinks(symbol); - return links.lateMembers || (links.lateMembers = createSymbolTable()); - } - - /** - * Gets the symbol table used to store exports added during late-binding. - * This table is filled in as the late-bound names for dynamic members are resolved. - */ - function getLateBoundExportsOfSymbol(symbol: Symbol): SymbolTable { - Debug.assert(!!(symbol.flags & SymbolFlags.Class), "Expected a container that supports late-binding of exports."); - const links = getSymbolLinks(symbol); - return links.lateExports || (links.lateExports = createSymbolTable()); - } - /** * Adds a declaration to a late-bound dynamic member. This performs the same function for * late-bound members that `addDeclarationToSymbol` in binder.ts performs for early-bound @@ -5675,13 +5655,9 @@ namespace ts { * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol: Symbol) { - if (symbol.flags & SymbolFlags.LateBindableContainer) { + if (symbol.flags & SymbolFlags.LateBindingContainer) { const links = getSymbolLinks(symbol); if (!links.resolvedMembers) { - // Get (or create) the SymbolTable from the parent used to store late- - // bound symbols. We get a shared table so that we can correctly merge - // late-bound symbols across accessor pairs. - const lateMembers = getLateBoundMembersOfSymbol(symbol); const earlyMembers = symbol.members; // In the event we recursively resolve the members of the symbol, we @@ -5690,6 +5666,7 @@ namespace ts { links.resolvedMembers = earlyMembers || emptySymbols; // fill in any as-yet-unresolved late-bound members. + const lateMembers = createSymbolTable(); for (const decl of symbol.declarations) { const members = getMembersOfDeclaration(decl); if (members) { @@ -5718,7 +5695,7 @@ namespace ts { const links = getSymbolLinks(symbol); if (!links.lateSymbol) { const parent = symbol.parent; - if (symbolHasLateBindableName(symbol) && parent && parent.flags & SymbolFlags.LateBindableContainer) { + if (symbolHasLateBindableName(symbol) && parent && parent.flags & SymbolFlags.LateBindingContainer) { // force late binding of members/exports. This will set the late-bound symbol if (some(symbol.declarations, hasStaticModifier)) { getExportsOfSymbol(parent); @@ -7979,7 +7956,9 @@ namespace ts { links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; case SyntaxKind.UniqueKeyword: - links.resolvedType = getUniqueType(node); + links.resolvedType = node.type.kind === SyntaxKind.SymbolKeyword + ? getUniqueESSymbolTypeForNode(walkUpParenthesizedTypes(node.parent)) + : unknownType break; } } @@ -8353,13 +8332,6 @@ 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; @@ -8367,21 +8339,16 @@ namespace ts { } function getUniqueESSymbolTypeForNode(node: Node) { - const parent = walkUpParentheses(node); - if (nodeCanHaveUniqueESSymbolType(parent)) { - const symbol = getSymbolOfNode(parent); + if (isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : + isPropertySignature(node) && hasReadonlyModifier(node)) { + const symbol = getSymbolOfNode(node); 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) { @@ -17271,7 +17238,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)) { - return getUniqueESSymbolTypeForNode(node.parent); + return getUniqueESSymbolTypeForNode(walkUpParenthesizedExpressions(node.parent)); } return returnType; } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 2efea500a9bd6..a671d107d0b0b 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -460,6 +460,19 @@ namespace ts { return emitTypePredicate(type); } + function writeEntityName(entityName: EntityName | Expression) { + if (entityName.kind === SyntaxKind.Identifier) { + writeTextOfNode(currentText, entityName); + } + else { + const left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; + const right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; + writeEntityName(left); + write("."); + writeTextOfNode(currentText, right); + } + } + function emitEntityName(entityName: EntityNameOrEntityNameExpression) { const visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration @@ -579,19 +592,6 @@ namespace ts { } } - function writeEntityName(entityName: EntityName | Expression) { - if (entityName.kind === SyntaxKind.Identifier) { - writeTextOfNode(currentText, entityName); - } - else { - const left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; - const right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; - writeEntityName(left); - write("."); - writeTextOfNode(currentText, right); - } - } - function emitSourceFile(node: SourceFile) { currentText = node.text; currentLineMap = getLineStarts(node); @@ -1246,7 +1246,7 @@ namespace ts { emitBindingPattern(node.name); } else { - writeNameOfDeclaration(node, getVariableDeclarationTypeOrNameVisibilityError); + writeNameOfDeclaration(node, getVariableDeclarationTypeVisibilityError); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" @@ -1262,12 +1262,12 @@ namespace ts { resolver.writeLiteralConstValue(node, writer); } else if (!hasModifier(node, ModifierFlags.Private)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeOrNameVisibilityError); + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } } - function getVariableDeclarationTypeOrNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { if (node.kind === SyntaxKind.VariableDeclaration) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? @@ -1303,8 +1303,8 @@ namespace ts { } } - function getVariableDeclarationTypeOrNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { - const diagnosticMessage = getVariableDeclarationTypeOrNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: node, @@ -1329,7 +1329,7 @@ namespace ts { function emitBindingElement(bindingElement: BindingElement) { function getBindingElementTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { - const diagnosticMessage = getVariableDeclarationTypeOrNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: bindingElement, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c79ff4c4287bc..7dd75bce71722 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2638,12 +2638,12 @@ namespace ts { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.NumberKeyword: + case SyntaxKind.SymbolKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.ObjectKeyword: - case SyntaxKind.SymbolKeyword: - // If these are followed by a dot, then parse these out as a dotted type reference instead. + // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); case SyntaxKind.AsteriskToken: return parseJSDocAllType(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f4cc88e9a316c..a311e8c4eb2be 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2784,7 +2784,6 @@ namespace ts { // State InObjectTypeLiteral = 1 << 20, InTypeAlias = 1 << 23, // Writing type in type alias declaration - IsDeclarationOfUniqueESSymbolType = 1 << 24, } /* @internal */ @@ -3057,7 +3056,7 @@ namespace ts { Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module, /* @internal */ - LateBindableContainer = Class | Interface | TypeLiteral | ObjectLiteral, + LateBindingContainer = Class | Interface | TypeLiteral | ObjectLiteral, } export interface Symbol { @@ -3099,13 +3098,11 @@ namespace ts { resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol exportsChecked?: boolean; // True if exports of external module have been checked typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked. - isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration + isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) enumKind?: EnumKind; // Enum declaration classification lateSymbol?: Symbol; // Late-bound symbol for a computed property - lateMembers?: SymbolTable; // Late-bound members resolved during check - lateExports?: SymbolTable; // Late-bound exports resolved during check } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b2ece2421abd5..9d22d45f98073 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1715,19 +1715,19 @@ namespace ts { return getAssignmentTargetKind(node) !== AssignmentKind.None; } - export function walkUpParentheses(node: Node) { - while (node && (node.kind === SyntaxKind.ParenthesizedType || - node.kind === SyntaxKind.ParenthesizedExpression)) { + function walkUp(node: Node, kind: SyntaxKind) { + while (node && node.kind === kind) { node = node.parent; } return node; } + export function walkUpParenthesizedTypes(node: Node) { + return walkUp(node, SyntaxKind.ParenthesizedType); + } + export function walkUpParenthesizedExpressions(node: Node) { - while (node && node.kind === SyntaxKind.ParenthesizedExpression) { - node = node.parent; - } - return node; + return walkUp(node, SyntaxKind.ParenthesizedExpression); } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped @@ -1736,9 +1736,6 @@ namespace ts { return false; } node = walkUpParenthesizedExpressions(node.parent); - while (node && node.kind === SyntaxKind.ParenthesizedExpression) { - node = node.parent; - } return node && node.kind === SyntaxKind.DeleteExpression; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 0b92c4c00a241..6d5ec9fbf00e8 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1781,7 +1781,6 @@ declare namespace ts { IgnoreErrors = 60416, InObjectTypeLiteral = 1048576, InTypeAlias = 8388608, - IsDeclarationOfUniqueESSymbolType = 16777216, } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0c5d2b56fc022..95fbed8c9c96d 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1781,7 +1781,6 @@ declare namespace ts { IgnoreErrors = 60416, InObjectTypeLiteral = 1048576, InTypeAlias = 8388608, - IsDeclarationOfUniqueESSymbolType = 16777216, } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; From ec90dbc1b90effa55c94b41d960c0597386dacf0 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 26 Oct 2017 18:26:37 -0700 Subject: [PATCH 34/43] Unify logic for getMembers/Exports of symbol --- src/compiler/checker.ts | 94 ++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 57 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 416d3296151da..2a85f2f3736ae 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1896,7 +1896,7 @@ namespace ts { } function getExportsOfSymbol(symbol: Symbol): SymbolTable { - return symbol.flags & SymbolFlags.Class ? getExportsOfClass(symbol) : + return symbol.flags & SymbolFlags.Class ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -1906,33 +1906,6 @@ namespace ts { return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol)); } - function getExportsOfClass(symbol: Symbol) { - const links = getSymbolLinks(symbol); - if (!links.resolvedExports) { - const earlySymbols = symbol.flags & SymbolFlags.Module ? getExportsOfModuleWorker(symbol) : symbol.exports; - - // In the event we recursively resolve the members of the symbol, we - // should only see the early-bound members of the symbol here. - links.resolvedExports = earlySymbols || emptySymbols; - - // fill in any as-yet-unresolved late-bound members. - const lateSymbols = createSymbolTable(); - for (const decl of symbol.declarations) { - const members = getMembersOfDeclaration(decl); - if (members) { - for (const member of members) { - if (hasModifier(member, ModifierFlags.Static) && hasLateBindableName(member)) { - lateBindMember(decl.symbol, earlySymbols, lateSymbols, member); - } - } - } - } - - links.resolvedExports = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; - } - return links.resolvedExports; - } - interface ExportCollisionTracker { specifierText: string; exportsWithDuplicate: ExportDeclaration[]; @@ -5649,40 +5622,47 @@ namespace ts { return links.resolvedSymbol; } + function getResolvedMembersOrExportsOfSymbol(symbol: Symbol, resolutionKind: "resolvedExports" | "resolvedMembers") { + const links = getSymbolLinks(symbol); + if (!links[resolutionKind]) { + const isStatic = resolutionKind === "resolvedExports"; + const earlySymbols = !isStatic ? symbol.members : + symbol.flags & SymbolFlags.Module ? getExportsOfModuleWorker(symbol) : + symbol.exports; + + // In the event we recursively resolve the members/exports of the symbol, we + // set the initial value of resolvedMembers/resolvedExports to the early-bound + // members/exports of the symbol. + links[resolutionKind] = earlySymbols || emptySymbols; + + // fill in any as-yet-unresolved late-bound members. + const lateSymbols = createSymbolTable(); + for (const decl of symbol.declarations) { + const members = getMembersOfDeclaration(decl); + if (members) { + for (const member of members) { + if (isStatic === hasStaticModifier(member) && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } + } + + links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; + } + + return links[resolutionKind]; + } + /** * Gets a SymbolTable containing both the early- and late-bound members of a symbol. * * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol: Symbol) { - if (symbol.flags & SymbolFlags.LateBindingContainer) { - const links = getSymbolLinks(symbol); - if (!links.resolvedMembers) { - const earlyMembers = symbol.members; - - // In the event we recursively resolve the members of the symbol, we - // set the initial value of resolvedMembers to the early-bound members - // of the symbol. - links.resolvedMembers = earlyMembers || emptySymbols; - - // fill in any as-yet-unresolved late-bound members. - const lateMembers = createSymbolTable(); - for (const decl of symbol.declarations) { - const members = getMembersOfDeclaration(decl); - if (members) { - for (const member of members) { - if (!hasModifier(member, ModifierFlags.Static) && hasLateBindableName(member)) { - lateBindMember(symbol, earlyMembers, lateMembers, member); - } - } - } - } - - links.resolvedMembers = combineSymbolTables(earlyMembers, lateMembers) || emptySymbols; - } - return links.resolvedMembers; - } - return symbol.members || emptySymbols; + return symbol.flags & SymbolFlags.LateBindingContainer + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers") + : symbol.members || emptySymbols; } /** @@ -7958,7 +7938,7 @@ namespace ts { case SyntaxKind.UniqueKeyword: links.resolvedType = node.type.kind === SyntaxKind.SymbolKeyword ? getUniqueESSymbolTypeForNode(walkUpParenthesizedTypes(node.parent)) - : unknownType + : unknownType; break; } } From 211b2f01c250a75c19b31aad587ba71a59907966 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 3 Nov 2017 22:11:25 -0700 Subject: [PATCH 35/43] Shave off ~100ms by extracting ExpandingFlags --- src/compiler/checker.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 35c400c4f74ae..b5cb1e925541c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -529,6 +529,13 @@ namespace ts { Strict, } + const enum ExpandingFlags { + None = 0, + Source = 1, + Target = 1 << 1, + Both = Source | Target, + } + const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); @@ -9229,12 +9236,6 @@ namespace ts { let targetStack: Type[]; let maybeCount = 0; let depth = 0; - const enum ExpandingFlags { - None = 0, - Source = 1, - Target = 1 << 1, - Both = Source | Target, - } let expandingFlags = ExpandingFlags.None; let overflow = false; let isIntersectionConstituent = false; From 8b717d34a1a401ed43717ecc0f9ed58a0d8ff8f7 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 6 Nov 2017 16:56:36 -0800 Subject: [PATCH 36/43] PR Feedback --- src/compiler/checker.ts | 89 +++++++++---------- src/compiler/types.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 1 - tests/baselines/reference/api/typescript.d.ts | 1 - 4 files changed, 42 insertions(+), 51 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a8830440012e3..627d5bf3c921a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -533,6 +533,11 @@ namespace ts { Both = Source | Target, } + const enum MembersOrExportsResolutionKind { + resolvedExports = "resolvedExports", + resolvedMembers = "resolvedMembers" + } + const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); @@ -572,10 +577,10 @@ namespace ts { diagnostics.add(diagnostic); } - function createSymbol(flags: SymbolFlags, name: __String) { + function createSymbol(flags: SymbolFlags, name: __String, checkFlags?: CheckFlags) { symbolCount++; const symbol = (new Symbol(flags | SymbolFlags.Transient, name)); - symbol.checkFlags = 0; + symbol.checkFlags = checkFlags || 0; return symbol; } @@ -1901,7 +1906,7 @@ namespace ts { } function getExportsOfSymbol(symbol: Symbol): SymbolTable { - return symbol.flags & SymbolFlags.Class ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : + return symbol.flags & SymbolFlags.Class ? getResolvedMembersOrExportsOfSymbol(symbol, MembersOrExportsResolutionKind.resolvedExports) : symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -3564,7 +3569,7 @@ namespace ts { writeKeyword(writer, SyntaxKind.ReadonlyKeyword); writeSpace(writer); } - if (prop.flags & SymbolFlags.Late) { + if (getCheckFlags(prop) & CheckFlags.Late) { const decl = firstOrUndefined(prop.declarations); const name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, SymbolFlags.Value); if (name) { @@ -5526,15 +5531,6 @@ namespace ts { return isDynamicName(node) && !isLateBindableName(node); } - /** - * Indicates whether a symbol has a late-bindable name. - */ - function symbolHasLateBindableName(symbol: Symbol) { - return symbol.flags & SymbolFlags.ClassMember - && symbol.escapedName === InternalSymbolName.Computed - && some(symbol.declarations, hasLateBindableName); - } - /** * Gets the symbolic name for a late-bound member from its type. */ @@ -5553,7 +5549,7 @@ namespace ts { * members. */ function addDeclarationToLateBoundSymbol(symbol: Symbol, member: LateBoundDeclaration, symbolFlags: SymbolFlags) { - Debug.assert(!!(symbol.flags & SymbolFlags.Late), "Expected a late-bound symbol."); + Debug.assert(!!(getCheckFlags(symbol) & CheckFlags.Late), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -5608,26 +5604,27 @@ namespace ts { const type = checkComputedPropertyName(decl.name); if (isTypeUsableAsLateBoundName(type)) { const memberName = getLateBoundNameFromType(type); + const symbolFlags = decl.symbol.flags; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. let lateSymbol = lateSymbols.get(memberName); - if (!lateSymbol) lateSymbols.set(memberName, lateSymbol = createSymbol(SymbolFlags.Late, memberName)); + if (!lateSymbol) lateSymbols.set(memberName, lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. const earlySymbol = earlySymbols && earlySymbols.get(memberName); - if (lateSymbol.flags & getExcludedSymbolFlags(decl.symbol.flags) || earlySymbol) { + if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) { // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; const name = declarationNameToString(decl.name); forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name)); error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name); - lateSymbol = createSymbol(SymbolFlags.Late, memberName); + lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late); } - addDeclarationToLateBoundSymbol(lateSymbol, decl, decl.symbol.flags); + addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); lateSymbol.parent = parent; return links.resolvedSymbol = lateSymbol; } @@ -5635,10 +5632,10 @@ namespace ts { return links.resolvedSymbol; } - function getResolvedMembersOrExportsOfSymbol(symbol: Symbol, resolutionKind: "resolvedExports" | "resolvedMembers") { + function getResolvedMembersOrExportsOfSymbol(symbol: Symbol, resolutionKind: MembersOrExportsResolutionKind) { const links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - const isStatic = resolutionKind === "resolvedExports"; + const isStatic = resolutionKind === MembersOrExportsResolutionKind.resolvedExports; const earlySymbols = !isStatic ? symbol.members : symbol.flags & SymbolFlags.Module ? getExportsOfModuleWorker(symbol) : symbol.exports; @@ -5674,7 +5671,7 @@ namespace ts { */ function getMembersOfSymbol(symbol: Symbol) { return symbol.flags & SymbolFlags.LateBindingContainer - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers") + ? getResolvedMembersOrExportsOfSymbol(symbol, MembersOrExportsResolutionKind.resolvedMembers) : symbol.members || emptySymbols; } @@ -5685,20 +5682,20 @@ namespace ts { * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol: Symbol): Symbol { - const links = getSymbolLinks(symbol); - if (!links.lateSymbol) { - const parent = symbol.parent; - if (symbolHasLateBindableName(symbol) && parent && parent.flags & SymbolFlags.LateBindingContainer) { + if (symbol.flags & SymbolFlags.ClassMember && symbol.escapedName === InternalSymbolName.Computed) { + const links = getSymbolLinks(symbol); + if (!links.lateSymbol && some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol if (some(symbol.declarations, hasStaticModifier)) { - getExportsOfSymbol(parent); + getExportsOfSymbol(symbol.parent); } else { - getMembersOfSymbol(parent); + getMembersOfSymbol(symbol.parent); } } + return links.lateSymbol || (links.lateSymbol = symbol); } - return links.lateSymbol || (links.lateSymbol = symbol); + return symbol; } function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { @@ -6083,8 +6080,8 @@ namespace ts { const propName = escapeLeadingUnderscores((t).value); const modifiersProp = getPropertyOfType(modifiersType, propName); const isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & SymbolFlags.Optional); - const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName); - prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? CheckFlags.Readonly : 0; + const checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? CheckFlags.Readonly : 0; + const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName, checkFlags); prop.type = propType; if (propertySymbol) { prop.syntheticOrigin = propertySymbol; @@ -6474,8 +6471,7 @@ namespace ts { } propTypes.push(type); } - const result = createSymbol(SymbolFlags.Property | commonFlags, name); - result.checkFlags = syntheticFlag | checkFlags; + const result = createSymbol(SymbolFlags.Property | commonFlags, name, syntheticFlag | checkFlags); result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -7974,7 +7970,7 @@ namespace ts { break; case SyntaxKind.UniqueKeyword: links.resolvedType = node.type.kind === SyntaxKind.SymbolKeyword - ? getUniqueESSymbolTypeForNode(walkUpParenthesizedTypes(node.parent)) + ? getESSymbolLikeTypeForNode(walkUpParenthesizedTypes(node.parent)) : unknownType; break; } @@ -8367,7 +8363,7 @@ namespace ts { return type; } - function getUniqueESSymbolTypeForNode(node: Node) { + function getESSymbolLikeTypeForNode(node: Node) { if (isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : isPropertySignature(node) && hasReadonlyModifier(node)) { @@ -8622,8 +8618,7 @@ namespace ts { } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - const result = createSymbol(symbol.flags, symbol.escapedName); - result.checkFlags = CheckFlags.Instantiated; + const result = createSymbol(symbol.flags, symbol.escapedName, CheckFlags.Instantiated); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -11129,8 +11124,8 @@ namespace ts { if (propType.flags & TypeFlags.ContainsAnyFunctionType) { return undefined; } - const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.escapedName); - inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0; + const checkFlags = readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0; + const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.type = inferTargetType(propType); members.set(prop.escapedName, inferredProp); @@ -11537,18 +11532,20 @@ namespace ts { inferredType = getDefaultTypeArgumentType(!!(context.flags & InferenceFlags.AnyDefault)); } } + + inferredType = getWidenedUniqueESSymbolType(inferredType); inference.inferredType = inferredType; const constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]); if (constraint) { const instantiatedConstraint = instantiateType(constraint, context); if (!context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { - inference.inferredType = inferredType = instantiatedConstraint; + inference.inferredType = inferredType = getWidenedUniqueESSymbolType(instantiatedConstraint); } } } - return getWidenedUniqueESSymbolType(inferredType); + return inferredType; } function getDefaultTypeArgumentType(isInJavaScriptFile: boolean): Type { @@ -14409,7 +14406,7 @@ namespace ts { const nameType = hasLateBindableName(memberDecl) ? checkComputedPropertyName(memberDecl.name) : undefined; const prop = nameType && isTypeUsableAsLateBoundName(nameType) - ? createSymbol(SymbolFlags.Property | SymbolFlags.Late | member.flags, getLateBoundNameFromType(nameType)) + ? createSymbol(SymbolFlags.Property | member.flags, getLateBoundNameFromType(nameType), CheckFlags.Late) : createSymbol(SymbolFlags.Property | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { @@ -17385,7 +17382,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)) { - return getUniqueESSymbolTypeForNode(walkUpParenthesizedExpressions(node.parent)); + return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent)); } return returnType; } @@ -24741,7 +24738,7 @@ namespace ts { isLateBound: (node: Declaration): node is LateBoundDeclaration => { node = getParseTreeNode(node, isDeclaration); const symbol = node && getSymbolOfNode(node); - return !!(symbol && symbol.flags & SymbolFlags.Late); + return !!(symbol && getCheckFlags(symbol) & CheckFlags.Late); }, writeLiteralConstValue, getJsxFactoryEntity: () => _jsxFactoryEntity @@ -25733,11 +25730,7 @@ namespace ts { return grammarErrorOnNode(node.type, Diagnostics._0_expected, tokenToString(SyntaxKind.SymbolKeyword)); } - let parent = node.parent; - while (parent.kind === SyntaxKind.ParenthesizedType) { - parent = parent.parent; - } - + const parent = walkUpParenthesizedTypes(node.parent); switch (parent.kind) { case SyntaxKind.VariableDeclaration: const decl = parent as VariableDeclaration; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 914c9ae45e33e..2e7739fcf8ae9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3031,7 +3031,6 @@ namespace ts { ExportStar = 1 << 23, // Export * declaration Optional = 1 << 24, // Optional property Transient = 1 << 25, // Transient symbol (created during type check) - Late = 1 << 26, // Late-bound symbol from computed property with a dynamic name (created during type check) Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, @@ -3152,6 +3151,7 @@ namespace ts { ContainsProtected = 1 << 7, // Synthetic property with protected constituent(s) ContainsPrivate = 1 << 8, // Synthetic property with private constituent(s) ContainsStatic = 1 << 9, // Synthetic property with static constituent(s) + Late = 1 << 10, // Late-bound symbol for a computed property with a dynamic name Synthetic = SyntheticProperty | SyntheticMethod } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 56830d0cca062..54dd35bf26ec8 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1895,7 +1895,6 @@ declare namespace ts { ExportStar = 8388608, Optional = 16777216, Transient = 33554432, - Late = 67108864, Enum = 384, Variable = 3, Value = 107455, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f6c760a9d8f0c..4b3af21543dce 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1895,7 +1895,6 @@ declare namespace ts { ExportStar = 8388608, Optional = 16777216, Transient = 33554432, - Late = 67108864, Enum = 384, Variable = 3, Value = 107455, From 444e282930b1408407f1e33f12403d77f40c82f1 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 6 Nov 2017 18:30:18 -0800 Subject: [PATCH 37/43] Update baselines after merge --- .../decoratorsOnComputedProperties.errors.txt | 160 +++++++++--------- .../decoratorsOnComputedProperties.symbols | 80 ++++----- 2 files changed, 120 insertions(+), 120 deletions(-) diff --git a/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt b/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt index 2aef827d4f514..42b678e088f7f 100644 --- a/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt +++ b/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt @@ -1,82 +1,82 @@ -tests/cases/compiler/decoratorsOnComputedProperties.ts(18,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(19,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(20,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(21,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(22,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(23,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(18,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(19,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(20,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(21,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(22,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(23,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(27,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(28,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(29,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(30,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(35,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(35,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(36,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(37,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(38,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(38,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(39,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(40,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(52,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(53,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(54,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(55,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(56,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(57,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(52,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(53,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(54,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(55,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(56,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(57,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(62,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(63,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(64,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(65,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(70,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(70,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(71,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(72,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(73,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(73,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(74,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(75,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(88,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(89,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(90,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(92,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(93,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(94,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(88,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(89,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(90,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(92,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(93,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(94,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(98,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(99,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(100,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(101,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(106,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(106,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(107,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(108,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(110,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(110,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(111,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(112,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(124,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(125,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(126,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(128,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(129,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(131,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(124,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(125,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(126,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(128,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(129,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(131,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(135,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(136,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(137,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(138,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(143,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(143,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(144,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(145,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(147,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(147,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(148,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(150,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(162,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(163,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(164,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(166,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(167,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(169,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(162,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(163,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(164,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(166,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(167,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(169,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(173,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(174,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(175,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(176,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(181,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(181,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(182,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(183,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(184,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(185,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(185,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(186,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid here. @@ -101,22 +101,22 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class B { @@ -138,7 +138,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -147,7 +147,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -167,22 +167,22 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method"]() {} } @@ -205,7 +205,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -214,7 +214,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -235,23 +235,23 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class F { @@ -273,7 +273,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -283,7 +283,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -303,24 +303,24 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method2"]() {} @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class H { @@ -342,7 +342,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -352,7 +352,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -373,24 +373,24 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method2"]() {} @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class J { @@ -412,7 +412,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -424,7 +424,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. diff --git a/tests/baselines/reference/decoratorsOnComputedProperties.symbols b/tests/baselines/reference/decoratorsOnComputedProperties.symbols index a9fb280f96ed1..f55f60b3f4eb7 100644 --- a/tests/baselines/reference/decoratorsOnComputedProperties.symbols +++ b/tests/baselines/reference/decoratorsOnComputedProperties.symbols @@ -26,7 +26,7 @@ class A { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(A[["property"]], Decl(decoratorsOnComputedProperties.ts, 8, 9)) +>"property" : Symbol(A["property"], Decl(decoratorsOnComputedProperties.ts, 8, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -36,7 +36,7 @@ class A { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(A[["property2"]], Decl(decoratorsOnComputedProperties.ts, 10, 33)) +>"property2" : Symbol(A["property2"], Decl(decoratorsOnComputedProperties.ts, 10, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -45,7 +45,7 @@ class A { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(A[["property3"]], Decl(decoratorsOnComputedProperties.ts, 12, 37)) +>"property3" : Symbol(A["property3"], Decl(decoratorsOnComputedProperties.ts, 12, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -53,7 +53,7 @@ class A { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(A[["property4"]], Decl(decoratorsOnComputedProperties.ts, 14, 37)) +>"property4" : Symbol(A["property4"], Decl(decoratorsOnComputedProperties.ts, 14, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -88,7 +88,7 @@ void class B { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(B[["property"]], Decl(decoratorsOnComputedProperties.ts, 25, 14)) +>"property" : Symbol(B["property"], Decl(decoratorsOnComputedProperties.ts, 25, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -98,7 +98,7 @@ void class B { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(B[["property2"]], Decl(decoratorsOnComputedProperties.ts, 27, 33)) +>"property2" : Symbol(B["property2"], Decl(decoratorsOnComputedProperties.ts, 27, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -107,7 +107,7 @@ void class B { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(B[["property3"]], Decl(decoratorsOnComputedProperties.ts, 29, 37)) +>"property3" : Symbol(B["property3"], Decl(decoratorsOnComputedProperties.ts, 29, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -115,7 +115,7 @@ void class B { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(B[["property4"]], Decl(decoratorsOnComputedProperties.ts, 31, 37)) +>"property4" : Symbol(B["property4"], Decl(decoratorsOnComputedProperties.ts, 31, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -151,7 +151,7 @@ class C { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(C[["property"]], Decl(decoratorsOnComputedProperties.ts, 42, 9)) +>"property" : Symbol(C["property"], Decl(decoratorsOnComputedProperties.ts, 42, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -161,7 +161,7 @@ class C { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(C[["property2"]], Decl(decoratorsOnComputedProperties.ts, 44, 33)) +>"property2" : Symbol(C["property2"], Decl(decoratorsOnComputedProperties.ts, 44, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -170,7 +170,7 @@ class C { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(C[["property3"]], Decl(decoratorsOnComputedProperties.ts, 46, 37)) +>"property3" : Symbol(C["property3"], Decl(decoratorsOnComputedProperties.ts, 46, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -178,7 +178,7 @@ class C { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(C[["property4"]], Decl(decoratorsOnComputedProperties.ts, 48, 37)) +>"property4" : Symbol(C["property4"], Decl(decoratorsOnComputedProperties.ts, 48, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -215,7 +215,7 @@ void class D { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(D[["property"]], Decl(decoratorsOnComputedProperties.ts, 60, 14)) +>"property" : Symbol(D["property"], Decl(decoratorsOnComputedProperties.ts, 60, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -225,7 +225,7 @@ void class D { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(D[["property2"]], Decl(decoratorsOnComputedProperties.ts, 62, 33)) +>"property2" : Symbol(D["property2"], Decl(decoratorsOnComputedProperties.ts, 62, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -234,7 +234,7 @@ void class D { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(D[["property3"]], Decl(decoratorsOnComputedProperties.ts, 64, 37)) +>"property3" : Symbol(D["property3"], Decl(decoratorsOnComputedProperties.ts, 64, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -242,7 +242,7 @@ void class D { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(D[["property4"]], Decl(decoratorsOnComputedProperties.ts, 66, 37)) +>"property4" : Symbol(D["property4"], Decl(decoratorsOnComputedProperties.ts, 66, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -279,7 +279,7 @@ class E { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(E[["property"]], Decl(decoratorsOnComputedProperties.ts, 78, 9)) +>"property" : Symbol(E["property"], Decl(decoratorsOnComputedProperties.ts, 78, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -289,7 +289,7 @@ class E { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(E[["property2"]], Decl(decoratorsOnComputedProperties.ts, 80, 33)) +>"property2" : Symbol(E["property2"], Decl(decoratorsOnComputedProperties.ts, 80, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -298,7 +298,7 @@ class E { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(E[["property3"]], Decl(decoratorsOnComputedProperties.ts, 82, 37)) +>"property3" : Symbol(E["property3"], Decl(decoratorsOnComputedProperties.ts, 82, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -306,7 +306,7 @@ class E { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(E[["property4"]], Decl(decoratorsOnComputedProperties.ts, 84, 37)) +>"property4" : Symbol(E["property4"], Decl(decoratorsOnComputedProperties.ts, 84, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -342,7 +342,7 @@ void class F { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(F[["property"]], Decl(decoratorsOnComputedProperties.ts, 96, 14)) +>"property" : Symbol(F["property"], Decl(decoratorsOnComputedProperties.ts, 96, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -352,7 +352,7 @@ void class F { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(F[["property2"]], Decl(decoratorsOnComputedProperties.ts, 98, 33)) +>"property2" : Symbol(F["property2"], Decl(decoratorsOnComputedProperties.ts, 98, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -361,7 +361,7 @@ void class F { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(F[["property3"]], Decl(decoratorsOnComputedProperties.ts, 100, 37)) +>"property3" : Symbol(F["property3"], Decl(decoratorsOnComputedProperties.ts, 100, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -369,7 +369,7 @@ void class F { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(F[["property4"]], Decl(decoratorsOnComputedProperties.ts, 102, 37)) +>"property4" : Symbol(F["property4"], Decl(decoratorsOnComputedProperties.ts, 102, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -406,7 +406,7 @@ class G { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(G[["property"]], Decl(decoratorsOnComputedProperties.ts, 114, 9)) +>"property" : Symbol(G["property"], Decl(decoratorsOnComputedProperties.ts, 114, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -416,7 +416,7 @@ class G { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(G[["property2"]], Decl(decoratorsOnComputedProperties.ts, 116, 33)) +>"property2" : Symbol(G["property2"], Decl(decoratorsOnComputedProperties.ts, 116, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -425,7 +425,7 @@ class G { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(G[["property3"]], Decl(decoratorsOnComputedProperties.ts, 118, 37)) +>"property3" : Symbol(G["property3"], Decl(decoratorsOnComputedProperties.ts, 118, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -433,7 +433,7 @@ class G { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(G[["property4"]], Decl(decoratorsOnComputedProperties.ts, 120, 37)) +>"property4" : Symbol(G["property4"], Decl(decoratorsOnComputedProperties.ts, 120, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -470,7 +470,7 @@ void class H { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(H[["property"]], Decl(decoratorsOnComputedProperties.ts, 133, 14)) +>"property" : Symbol(H["property"], Decl(decoratorsOnComputedProperties.ts, 133, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -480,7 +480,7 @@ void class H { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(H[["property2"]], Decl(decoratorsOnComputedProperties.ts, 135, 33)) +>"property2" : Symbol(H["property2"], Decl(decoratorsOnComputedProperties.ts, 135, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -489,7 +489,7 @@ void class H { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(H[["property3"]], Decl(decoratorsOnComputedProperties.ts, 137, 37)) +>"property3" : Symbol(H["property3"], Decl(decoratorsOnComputedProperties.ts, 137, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -497,7 +497,7 @@ void class H { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(H[["property4"]], Decl(decoratorsOnComputedProperties.ts, 139, 37)) +>"property4" : Symbol(H["property4"], Decl(decoratorsOnComputedProperties.ts, 139, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -535,7 +535,7 @@ class I { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(I[["property"]], Decl(decoratorsOnComputedProperties.ts, 152, 9)) +>"property" : Symbol(I["property"], Decl(decoratorsOnComputedProperties.ts, 152, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -545,7 +545,7 @@ class I { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(I[["property2"]], Decl(decoratorsOnComputedProperties.ts, 154, 33)) +>"property2" : Symbol(I["property2"], Decl(decoratorsOnComputedProperties.ts, 154, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -554,7 +554,7 @@ class I { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(I[["property3"]], Decl(decoratorsOnComputedProperties.ts, 156, 37)) +>"property3" : Symbol(I["property3"], Decl(decoratorsOnComputedProperties.ts, 156, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -562,7 +562,7 @@ class I { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(I[["property4"]], Decl(decoratorsOnComputedProperties.ts, 158, 37)) +>"property4" : Symbol(I["property4"], Decl(decoratorsOnComputedProperties.ts, 158, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -601,7 +601,7 @@ void class J { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(J[["property"]], Decl(decoratorsOnComputedProperties.ts, 171, 14)) +>"property" : Symbol(J["property"], Decl(decoratorsOnComputedProperties.ts, 171, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -611,7 +611,7 @@ void class J { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(J[["property2"]], Decl(decoratorsOnComputedProperties.ts, 173, 33)) +>"property2" : Symbol(J["property2"], Decl(decoratorsOnComputedProperties.ts, 173, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -620,7 +620,7 @@ void class J { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(J[["property3"]], Decl(decoratorsOnComputedProperties.ts, 175, 37)) +>"property3" : Symbol(J["property3"], Decl(decoratorsOnComputedProperties.ts, 175, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -628,7 +628,7 @@ void class J { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(J[["property4"]], Decl(decoratorsOnComputedProperties.ts, 177, 37)) +>"property4" : Symbol(J["property4"], Decl(decoratorsOnComputedProperties.ts, 177, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) From d0fb7e42eb8b0f351f148a1a8696fa43868e4f35 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 6 Nov 2017 18:41:09 -0800 Subject: [PATCH 38/43] PR Feedback --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 14dd2bb57c5a9..5ca986a2bf145 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7617,7 +7617,7 @@ namespace ts { containsString?: boolean; containsNumber?: boolean; containsESSymbol?: boolean; - containsStringOrNumberLiteralOrUniqueESSymbol?: boolean; + containsLiteralOrUniqueESSymbol?: boolean; containsObjectType?: boolean; containsEmptyObject?: boolean; unionIndex?: number; @@ -7684,7 +7684,7 @@ namespace ts { if (flags & TypeFlags.String) typeSet.containsString = true; if (flags & TypeFlags.Number) typeSet.containsNumber = true; if (flags & TypeFlags.ESSymbol) typeSet.containsESSymbol = true; - if (flags & TypeFlags.StringOrNumberLiteralOrUnique) typeSet.containsStringOrNumberLiteralOrUniqueESSymbol = true; + if (flags & TypeFlags.StringOrNumberLiteralOrUnique) typeSet.containsLiteralOrUniqueESSymbol = true; const len = typeSet.length; const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { @@ -7792,7 +7792,7 @@ namespace ts { if (subtypeReduction) { removeSubtypes(typeSet); } - else if (typeSet.containsStringOrNumberLiteralOrUniqueESSymbol) { + else if (typeSet.containsLiteralOrUniqueESSymbol) { removeRedundantLiteralTypes(typeSet); } if (typeSet.length === 0) { From b9dbf5d13b3bb7eff978dffc49198b6dc339c073 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 10 Nov 2017 14:42:24 -0800 Subject: [PATCH 39/43] Simplify literal/unique symbol widening --- src/compiler/checker.ts | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5ca986a2bf145..e15b57fbc2d38 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10666,16 +10666,6 @@ namespace ts { type; } - function getWidenedLiteralLikeType(type: Type): Type { - return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : - type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : - type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : - type.flags & TypeFlags.BooleanLiteral ? booleanType : - type.flags & TypeFlags.UniqueESSymbol ? esSymbolType : - type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedLiteralLikeType)) : - type; - } - function getWidenedLiteralType(type: Type): Type { return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : @@ -10692,12 +10682,13 @@ namespace ts { } function getWidenedLiteralLikeTypeForContextualType(type: Type, contextualType: Type) { - const widenLiterals = !isLiteralContextualType(contextualType); - const widenSymbols = !isUniqueESSymbolContextualType(contextualType); - return widenLiterals && widenSymbols ? getWidenedLiteralLikeType(type) : - widenLiterals ? getWidenedLiteralType(type) : - widenSymbols ? getWidenedUniqueESSymbolType(type) : - type; + if (!isLiteralContextualType(contextualType)) { + type = getWidenedLiteralType(type); + } + if (!isUniqueESSymbolContextualType(contextualType)) { + type = getWidenedUniqueESSymbolType(type); + } + return type; } /** From ae11ae55c5b6e3f0801f9a80e94474ae3baabdd3 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 13 Nov 2017 09:49:26 -0800 Subject: [PATCH 40/43] Fix getReturnTypeFromBody widening --- src/compiler/checker.ts | 73 +- src/compiler/declarationEmitter.ts | 15 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/types.ts | 2 + src/compiler/utilities.ts | 7 + src/services/codefixes/inferFromUsage.ts | 1 + src/services/utilities.ts | 1 + .../reference/YieldStarExpression4_es6.types | 2 +- .../reference/api/tsserverlibrary.d.ts | 2 + tests/baselines/reference/api/typescript.d.ts | 2 + .../reference/asyncImportNestedYield.types | 2 +- ....asyncGenerators.classMethods.es2015.types | 12 +- ...ter.asyncGenerators.classMethods.es5.types | 12 +- ....asyncGenerators.classMethods.esnext.types | 12 +- ...nerators.functionDeclarations.es2015.types | 12 +- ...cGenerators.functionDeclarations.es5.types | 12 +- ...nerators.functionDeclarations.esnext.types | 12 +- ...enerators.functionExpressions.es2015.types | 18 +- ...ncGenerators.functionExpressions.es5.types | 18 +- ...enerators.functionExpressions.esnext.types | 18 +- ...nerators.objectLiteralMethods.es2015.types | 24 +- ...cGenerators.objectLiteralMethods.es5.types | 24 +- ...nerators.objectLiteralMethods.esnext.types | 24 +- .../baselines/reference/generatorES6_2.types | 2 +- .../baselines/reference/generatorES6_3.types | 4 +- .../baselines/reference/generatorES6_4.types | 6 +- .../reference/generatorTypeCheck15.types | 2 +- .../reference/generatorTypeCheck33.types | 4 +- .../reference/generatorTypeCheck34.types | 4 +- .../reference/generatorTypeCheck35.types | 2 +- .../reference/generatorTypeCheck38.types | 2 +- .../reference/generatorTypeCheck41.types | 2 +- .../reference/generatorTypeCheck42.types | 2 +- .../reference/generatorTypeCheck43.types | 2 +- .../reference/generatorTypeCheck44.types | 2 +- .../reference/generatorTypeCheck49.types | 2 +- .../reference/generatorTypeCheck51.types | 2 +- .../reference/generatorTypeCheck63.errors.txt | 12 +- .../reference/generatorTypeCheck63.types | 2 +- ....asyncGenerators.classMethods.esnext.types | 4 +- ...nerators.functionDeclarations.esnext.types | 4 +- ...enerators.functionExpressions.esnext.types | 8 +- ...nerators.objectLiteralMethods.esnext.types | 12 +- ...ateStringWithEmbeddedYieldKeywordES6.types | 2 +- .../types.asyncGenerators.esnext.1.types | 58 +- .../types.asyncGenerators.esnext.2.errors.txt | 92 +- .../types.asyncGenerators.esnext.2.types | 48 +- tests/baselines/reference/uniqueSymbols.js | 232 +++-- .../baselines/reference/uniqueSymbols.symbols | 220 ++++- tests/baselines/reference/uniqueSymbols.types | 197 +++- .../reference/uniqueSymbolsDeclarations.js | 540 +++++++++++ .../uniqueSymbolsDeclarations.symbols | 788 ++++++++++++++++ .../reference/uniqueSymbolsDeclarations.types | 867 ++++++++++++++++++ ...uniqueSymbolsDeclarationsErrors.errors.txt | 110 +++ .../uniqueSymbolsDeclarationsErrors.js | 100 ++ .../uniqueSymbolsDeclarationsErrors.symbols | 135 +++ .../uniqueSymbolsDeclarationsErrors.types | 137 +++ .../types/uniqueSymbol/uniqueSymbols.ts | 73 +- .../uniqueSymbol/uniqueSymbolsDeclarations.ts | 242 +++++ .../uniqueSymbolsDeclarationsErrors.ts | 64 ++ 60 files changed, 3865 insertions(+), 427 deletions(-) create mode 100644 tests/baselines/reference/uniqueSymbolsDeclarations.js create mode 100644 tests/baselines/reference/uniqueSymbolsDeclarations.symbols create mode 100644 tests/baselines/reference/uniqueSymbolsDeclarations.types create mode 100644 tests/baselines/reference/uniqueSymbolsDeclarationsErrors.errors.txt create mode 100644 tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js create mode 100644 tests/baselines/reference/uniqueSymbolsDeclarationsErrors.symbols create mode 100644 tests/baselines/reference/uniqueSymbolsDeclarationsErrors.types create mode 100644 tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts create mode 100644 tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e15b57fbc2d38..ff8a80d370dd3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3360,8 +3360,13 @@ namespace ts { writeAnonymousType(type, nextFlags); } else if (type.flags & TypeFlags.UniqueESSymbol) { - writeKeyword(writer, SyntaxKind.UniqueKeyword); - writeSpace(writer); + if (flags & TypeFormatFlags.AllowUniqueESSymbolType) { + writeKeyword(writer, SyntaxKind.UniqueKeyword); + writeSpace(writer); + } + else { + writer.reportInaccessibleUniqueSymbolError(); + } writeKeyword(writer, SyntaxKind.SymbolKeyword); } else if (type.flags & TypeFlags.StringOrNumberLiteral) { @@ -8365,9 +8370,7 @@ namespace ts { } function getESSymbolLikeTypeForNode(node: Node) { - if (isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : - isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : - isPropertySignature(node) && hasReadonlyModifier(node)) { + if (isValidESSymbolDeclaration(node)) { const symbol = getSymbolOfNode(node); const links = getSymbolLinks(symbol); return links.type || (links.type = createUniqueESSymbolType(symbol)); @@ -17694,9 +17697,6 @@ namespace ts { // the native Promise type later in this function. type = checkAwaitedType(type, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - - // widen 'unique symbol' types when we infer the return type. - type = getWidenedUniqueESSymbolType(type); } else { let types: Type[]; @@ -17728,37 +17728,49 @@ namespace ts { : voidType; // Normal function } } + // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); - - // widen 'unique symbol' types when we infer the return type. - type = getWidenedUniqueESSymbolType(type); - - if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function - type = functionFlags & FunctionFlags.Async - ? createAsyncIterableIteratorType(type) // AsyncGenerator function - : createIterableIteratorType(type); // Generator function - } } if (!contextualSignature) { reportErrorsFromWidening(func, type); } - if (isUnitType(type) && - !(contextualSignature && - isLiteralContextualType( - contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { - type = getWidenedLiteralType(type); + if (isUnitType(type)) { + let contextualType = !contextualSignature ? undefined : + contextualSignature === getSignatureFromDeclaration(func) ? type : + getReturnTypeOfSignature(contextualSignature); + if (contextualType) { + switch (functionFlags & FunctionFlags.AsyncGenerator) { + case FunctionFlags.AsyncGenerator: + contextualType = getIteratedTypeOfGenerator(contextualType, /*isAsyncGenerator*/ true); + break; + case FunctionFlags.Generator: + contextualType = getIteratedTypeOfGenerator(contextualType, /*isAsyncGenerator*/ false); + break; + case FunctionFlags.Async: + contextualType = getPromisedTypeOfPromise(contextualType); + break; + } + } + type = getWidenedLiteralLikeTypeForContextualType(type, contextualType); } const widenedType = getWidenedType(type); - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body is awaited type of the body, wrapped in a native Promise type. - return (functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async - ? createPromiseReturnType(func, widenedType) // Async function - : widenedType; // Generator function, AsyncGenerator function, or normal function + switch (functionFlags & FunctionFlags.AsyncGenerator) { + case FunctionFlags.AsyncGenerator: + return createAsyncIterableIteratorType(widenedType); + case FunctionFlags.Generator: + return createIterableIteratorType(widenedType); + case FunctionFlags.Async: + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + return createPromiseType(widenedType); + default: + return widenedType; + } } function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, checkMode: CheckMode): Type[] { @@ -24627,9 +24639,14 @@ namespace ts { let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (type.flags & TypeFlags.UniqueESSymbol && + type.symbol === symbol) { + flags |= TypeFormatFlags.AllowUniqueESSymbolType; + } if (flags & TypeFormatFlags.AddUndefined) { type = getNullableType(type, TypeFlags.Undefined); } + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index a671d107d0b0b..7912d042c0f7a 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -190,6 +190,7 @@ namespace ts { const writer = createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportInaccessibleUniqueSymbolError = reportInaccessibleUniqueSymbolError; writer.reportPrivateInBaseOfClassExpression = reportPrivateInBaseOfClassExpression; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; @@ -322,11 +323,21 @@ namespace ts { } } + function reportInaccessibleUniqueSymbolError() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, + declarationNameToString(errorNameNode), + "unique symbol")); + } + } + function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; - emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, - declarationNameToString(errorNameNode))); + emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, + declarationNameToString(errorNameNode), + "this")); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6671c8f711981..c98fd856ebe5c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1804,7 +1804,7 @@ "category": "Error", "code": 2526 }, - "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary.": { + "The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary.": { "category": "Error", "code": 2527 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1e8d35059147f..bbb6da48d2370 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2857,6 +2857,7 @@ namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; reportPrivateInBaseOfClassExpression(propertyName: string): void; + reportInaccessibleUniqueSymbolError(): void; } export const enum TypeFormatFlags { @@ -2877,6 +2878,7 @@ namespace ts { InArrayType = 1 << 15, // Writing an array element type UseAliasDefinedOutsideCurrentScope = 1 << 16, // For a `type T = ... ` defined in a different file, write `T` instead of its value, // even though `T` can't be accessed in the current scope. + AllowUniqueESSymbolType = 1 << 17, } export const enum SymbolFormatFlags { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c3b208fde5305..4c94220e2f17a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -56,6 +56,7 @@ namespace ts { clear: () => str = "", trackSymbol: noop, reportInaccessibleThisError: noop, + reportInaccessibleUniqueSymbolError: noop, reportPrivateInBaseOfClassExpression: noop, }; } @@ -945,6 +946,12 @@ namespace ts { && node.parent.parent.kind === SyntaxKind.VariableStatement; } + export function isValidESSymbolDeclaration(node: Node) { + return isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : + isPropertySignature(node) && hasReadonlyModifier(node); + } + export function introducesArgumentsExoticObject(node: Node) { switch (node.kind) { case SyntaxKind.MethodDeclaration: diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 378c73f2f756e..3f03180360d2e 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -246,6 +246,7 @@ namespace ts.codefix { }, reportInaccessibleThisError: () => { typeIsAccessible = false; }, reportPrivateInBaseOfClassExpression: () => { typeIsAccessible = false; }, + reportInaccessibleUniqueSymbolError: () => { typeIsAccessible = false; } }; } writer.clear(); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 36089f94f73dd..33d35aea55784 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1130,6 +1130,7 @@ namespace ts { clear: resetWriter, trackSymbol: noop, reportInaccessibleThisError: noop, + reportInaccessibleUniqueSymbolError: noop, reportPrivateInBaseOfClassExpression: noop, }; diff --git a/tests/baselines/reference/YieldStarExpression4_es6.types b/tests/baselines/reference/YieldStarExpression4_es6.types index 1d72e6dc50651..86b727306d473 100644 --- a/tests/baselines/reference/YieldStarExpression4_es6.types +++ b/tests/baselines/reference/YieldStarExpression4_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts === function *g() { ->g : () => IterableIterator +>g : () => IterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 7ab0c59e3d463..7aba78318f4f1 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1826,6 +1826,7 @@ declare namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; reportPrivateInBaseOfClassExpression(propertyName: string): void; + reportInaccessibleUniqueSymbolError(): void; } enum TypeFormatFlags { None = 0, @@ -1844,6 +1845,7 @@ declare namespace ts { WriteClassExpressionAsTypeLiteral = 16384, InArrayType = 32768, UseAliasDefinedOutsideCurrentScope = 65536, + AllowUniqueESSymbolType = 131072, } enum SymbolFormatFlags { None = 0, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index fbc88ce624917..f18eb1277fc8e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1826,6 +1826,7 @@ declare namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; reportPrivateInBaseOfClassExpression(propertyName: string): void; + reportInaccessibleUniqueSymbolError(): void; } enum TypeFormatFlags { None = 0, @@ -1844,6 +1845,7 @@ declare namespace ts { WriteClassExpressionAsTypeLiteral = 16384, InArrayType = 32768, UseAliasDefinedOutsideCurrentScope = 65536, + AllowUniqueESSymbolType = 131072, } enum SymbolFormatFlags { None = 0, diff --git a/tests/baselines/reference/asyncImportNestedYield.types b/tests/baselines/reference/asyncImportNestedYield.types index 872e314150030..f7fbfa8f96200 100644 --- a/tests/baselines/reference/asyncImportNestedYield.types +++ b/tests/baselines/reference/asyncImportNestedYield.types @@ -1,6 +1,6 @@ === tests/cases/compiler/asyncImportNestedYield.ts === async function* foo() { ->foo : () => AsyncIterableIterator<"foo"> +>foo : () => AsyncIterableIterator import((await import(yield "foo")).default); >import((await import(yield "foo")).default) : Promise diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types index c375fb6f45522..c6d6fb6758d13 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types index e4be9f80d4ae6..5d636d2400c6f 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types index 1232130a389a3..f2f5f4d7503bd 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types index 0e43463990629..15ff1298b21ac 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator const x = yield 1; >x : any @@ -31,14 +31,14 @@ async function * f4() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === async function * f5() { ->f5 : () => AsyncIterableIterator<1> +>f5 : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator<1> +>f7 : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types index 9ebd2659ef4ab..6220f5efd1eca 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator const x = yield 1; >x : any @@ -31,14 +31,14 @@ async function * f4() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === async function * f5() { ->f5 : () => AsyncIterableIterator<1> +>f5 : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator<1> +>f7 : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types index 4e61c9032273c..c0d8011774655 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator const x = yield 1; >x : any @@ -31,14 +31,14 @@ async function * f4() { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts === async function * f5() { ->f5 : () => AsyncIterableIterator<1> +>f5 : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator<1> +>f7 : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types index 83d65ce524624..1db2126b7ed83 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types @@ -14,8 +14,8 @@ const f2 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === const f3 = async function * () { ->f3 : () => AsyncIterableIterator<1> ->async function * () { const x = yield 1;} : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator +>async function * () { const x = yield 1;} : () => AsyncIterableIterator const x = yield 1; >x : any @@ -35,15 +35,15 @@ const f4 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === const f5 = async function * () { ->f5 : () => AsyncIterableIterator<1> ->async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1> +>f5 : () => AsyncIterableIterator +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator<1> ->async function * () { return 1;} : () => AsyncIterableIterator<1> +>f7 : () => AsyncIterableIterator +>async function * () { return 1;} : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types index 7d736b2327c9a..e9da600bdbf1c 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types @@ -14,8 +14,8 @@ const f2 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === const f3 = async function * () { ->f3 : () => AsyncIterableIterator<1> ->async function * () { const x = yield 1;} : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator +>async function * () { const x = yield 1;} : () => AsyncIterableIterator const x = yield 1; >x : any @@ -35,15 +35,15 @@ const f4 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === const f5 = async function * () { ->f5 : () => AsyncIterableIterator<1> ->async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1> +>f5 : () => AsyncIterableIterator +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator<1> ->async function * () { return 1;} : () => AsyncIterableIterator<1> +>f7 : () => AsyncIterableIterator +>async function * () { return 1;} : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types index 6c40f9cebb169..5802bc10a2d9e 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types @@ -14,8 +14,8 @@ const f2 = async function * () { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts === const f3 = async function * () { ->f3 : () => AsyncIterableIterator<1> ->async function * () { const x = yield 1;} : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator +>async function * () { const x = yield 1;} : () => AsyncIterableIterator const x = yield 1; >x : any @@ -35,15 +35,15 @@ const f4 = async function * () { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts === const f5 = async function * () { ->f5 : () => AsyncIterableIterator<1> ->async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1> +>f5 : () => AsyncIterableIterator +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator<1> ->async function * () { return 1;} : () => AsyncIterableIterator<1> +>f7 : () => AsyncIterableIterator +>async function * () { return 1;} : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types index 59c5bcfa16716..9e47fc9d98932 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types @@ -22,11 +22,11 @@ const o2 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O3.ts === const o3 = { ->o3 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; } +>o3 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -51,18 +51,18 @@ const o4 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O5.ts === const o5 = { ->o5 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; } +>o5 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } +>o7 : { f(): AsyncIterableIterator; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types index 3e7ead2f73796..390007605083d 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types @@ -22,11 +22,11 @@ const o2 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O3.ts === const o3 = { ->o3 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; } +>o3 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -51,18 +51,18 @@ const o4 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O5.ts === const o5 = { ->o5 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; } +>o5 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } +>o7 : { f(): AsyncIterableIterator; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types index 9e5aad8af2367..a05b5326b2c8e 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types @@ -22,11 +22,11 @@ const o2 = { } === tests/cases/conformance/emitter/esnext/asyncGenerators/O3.ts === const o3 = { ->o3 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; } +>o3 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -51,18 +51,18 @@ const o4 = { } === tests/cases/conformance/emitter/esnext/asyncGenerators/O5.ts === const o5 = { ->o5 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; } +>o5 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield* (async function*() { yield 1; })(); >x : any >yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator<1> ->(async function*() { yield 1; }) : () => AsyncIterableIterator<1> ->async function*() { yield 1; } : () => AsyncIterableIterator<1> +>(async function*() { yield 1; })() : AsyncIterableIterator +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/esnext/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } +>o7 : { f(): AsyncIterableIterator; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/generatorES6_2.types b/tests/baselines/reference/generatorES6_2.types index 61a2adbc697fa..a95a0008d4fe4 100644 --- a/tests/baselines/reference/generatorES6_2.types +++ b/tests/baselines/reference/generatorES6_2.types @@ -3,7 +3,7 @@ class C { >C : C public * foo() { ->foo : () => IterableIterator<1> +>foo : () => IterableIterator yield 1 >yield 1 : any diff --git a/tests/baselines/reference/generatorES6_3.types b/tests/baselines/reference/generatorES6_3.types index 9ecd01d6e23bb..e237cbd3510a2 100644 --- a/tests/baselines/reference/generatorES6_3.types +++ b/tests/baselines/reference/generatorES6_3.types @@ -1,7 +1,7 @@ === tests/cases/compiler/generatorES6_3.ts === var v = function*() { ->v : () => IterableIterator<0> ->function*() { yield 0} : () => IterableIterator<0> +>v : () => IterableIterator +>function*() { yield 0} : () => IterableIterator yield 0 >yield 0 : any diff --git a/tests/baselines/reference/generatorES6_4.types b/tests/baselines/reference/generatorES6_4.types index 786e7b64020fd..fa19d8f3ae2d5 100644 --- a/tests/baselines/reference/generatorES6_4.types +++ b/tests/baselines/reference/generatorES6_4.types @@ -1,10 +1,10 @@ === tests/cases/compiler/generatorES6_4.ts === var v = { ->v : { foo(): IterableIterator<0>; } ->{ *foo() { yield 0 }} : { foo(): IterableIterator<0>; } +>v : { foo(): IterableIterator; } +>{ *foo() { yield 0 }} : { foo(): IterableIterator; } *foo() { ->foo : () => IterableIterator<0> +>foo : () => IterableIterator yield 0 >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck15.types b/tests/baselines/reference/generatorTypeCheck15.types index 3851d8e56a416..33537836c120f 100644 --- a/tests/baselines/reference/generatorTypeCheck15.types +++ b/tests/baselines/reference/generatorTypeCheck15.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts === function* g() { ->g : () => IterableIterator<""> +>g : () => IterableIterator return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck33.types b/tests/baselines/reference/generatorTypeCheck33.types index 707bf7beccda2..d6b29936530d6 100644 --- a/tests/baselines/reference/generatorTypeCheck33.types +++ b/tests/baselines/reference/generatorTypeCheck33.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any >0 : 0 function* g2() { ->g2 : () => IterableIterator<""> +>g2 : () => IterableIterator yield ""; >yield "" : any diff --git a/tests/baselines/reference/generatorTypeCheck34.types b/tests/baselines/reference/generatorTypeCheck34.types index 239c5ff14936d..f25eefb72f7be 100644 --- a/tests/baselines/reference/generatorTypeCheck34.types +++ b/tests/baselines/reference/generatorTypeCheck34.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any >0 : 0 function* g2() { ->g2 : () => IterableIterator<""> +>g2 : () => IterableIterator return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck35.types b/tests/baselines/reference/generatorTypeCheck35.types index dcd5ab4be84bf..333b653a50148 100644 --- a/tests/baselines/reference/generatorTypeCheck35.types +++ b/tests/baselines/reference/generatorTypeCheck35.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck38.types b/tests/baselines/reference/generatorTypeCheck38.types index 31fe452e65639..15b8528b345a6 100644 --- a/tests/baselines/reference/generatorTypeCheck38.types +++ b/tests/baselines/reference/generatorTypeCheck38.types @@ -3,7 +3,7 @@ var yield; >yield : any function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck41.types b/tests/baselines/reference/generatorTypeCheck41.types index 1a9ea21f9786b..8e59ce188602e 100644 --- a/tests/baselines/reference/generatorTypeCheck41.types +++ b/tests/baselines/reference/generatorTypeCheck41.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: number; } diff --git a/tests/baselines/reference/generatorTypeCheck42.types b/tests/baselines/reference/generatorTypeCheck42.types index 79b2516051e79..f7281d60afe1b 100644 --- a/tests/baselines/reference/generatorTypeCheck42.types +++ b/tests/baselines/reference/generatorTypeCheck42.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: () => void; } diff --git a/tests/baselines/reference/generatorTypeCheck43.types b/tests/baselines/reference/generatorTypeCheck43.types index 754d3fee814c8..3e8ec02672a2f 100644 --- a/tests/baselines/reference/generatorTypeCheck43.types +++ b/tests/baselines/reference/generatorTypeCheck43.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: () => IterableIterator; } diff --git a/tests/baselines/reference/generatorTypeCheck44.types b/tests/baselines/reference/generatorTypeCheck44.types index e06b8961ca07a..381feb30f3c67 100644 --- a/tests/baselines/reference/generatorTypeCheck44.types +++ b/tests/baselines/reference/generatorTypeCheck44.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: number; } diff --git a/tests/baselines/reference/generatorTypeCheck49.types b/tests/baselines/reference/generatorTypeCheck49.types index 6ac2b6acce861..f73978d1a095a 100644 --- a/tests/baselines/reference/generatorTypeCheck49.types +++ b/tests/baselines/reference/generatorTypeCheck49.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck51.types b/tests/baselines/reference/generatorTypeCheck51.types index ca50f640301d4..1563ee5e7d317 100644 --- a/tests/baselines/reference/generatorTypeCheck51.types +++ b/tests/baselines/reference/generatorTypeCheck51.types @@ -3,7 +3,7 @@ function* g() { >g : () => IterableIterator function* h() { ->h : () => IterableIterator<0> +>h : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck63.errors.txt b/tests/baselines/reference/generatorTypeCheck63.errors.txt index 1466530dd0c65..2a1935fd90633 100644 --- a/tests/baselines/reference/generatorTypeCheck63.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck63.errors.txt @@ -3,9 +3,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): err Type 'State | 1' is not assignable to type 'StrategicState'. Type '1' has no properties in common with type 'StrategicState'. tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(29,70): error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,62): error TS2345: Argument of type '(state: State) => IterableIterator<1>' is not assignable to parameter of type '(a: State) => IterableIterator'. - Type 'IterableIterator<1>' is not assignable to type 'IterableIterator'. - Type '1' is not assignable to type 'State'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,62): error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: State) => IterableIterator'. + Type 'IterableIterator' is not assignable to type 'IterableIterator'. + Type 'number' is not assignable to type 'State'. tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: StrategicState) => IterableIterator'. Type 'IterableIterator' is not assignable to type 'IterableIterator'. @@ -51,9 +51,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): err export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { ~~~~~~~~ -!!! error TS2345: Argument of type '(state: State) => IterableIterator<1>' is not assignable to parameter of type '(a: State) => IterableIterator'. -!!! error TS2345: Type 'IterableIterator<1>' is not assignable to type 'IterableIterator'. -!!! error TS2345: Type '1' is not assignable to type 'State'. +!!! error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: State) => IterableIterator'. +!!! error TS2345: Type 'IterableIterator' is not assignable to type 'IterableIterator'. +!!! error TS2345: Type 'number' is not assignable to type 'State'. return 1; }); diff --git a/tests/baselines/reference/generatorTypeCheck63.types b/tests/baselines/reference/generatorTypeCheck63.types index cd41a1776b865..8fc2054bd6e74 100644 --- a/tests/baselines/reference/generatorTypeCheck63.types +++ b/tests/baselines/reference/generatorTypeCheck63.types @@ -107,7 +107,7 @@ export const Nothing2: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) { return 1;}) : any >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { return 1;} : (state: State) => IterableIterator<1> +>function* (state: State) { return 1;} : (state: State) => IterableIterator >state : State >State : State diff --git a/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types b/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types index ad6d810b0cb11..254d983caaa80 100644 --- a/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types @@ -151,7 +151,7 @@ class C14 { >C14 : C14 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -175,7 +175,7 @@ class C16 { >C16 : C16 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types index 772de158358ea..c27e9209611f2 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types @@ -95,7 +95,7 @@ async function * f13() { } === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts === async function * f14() { ->f14 : () => AsyncIterableIterator<1> +>f14 : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -111,7 +111,7 @@ async function * f15() { } === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts === async function * f16() { ->f16 : () => AsyncIterableIterator +>f16 : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types index 557956a3344cb..09b5797969968 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types @@ -122,8 +122,8 @@ const f13 = async function * () { }; === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts === const f14 = async function * () { ->f14 : () => AsyncIterableIterator<1> ->async function * () { yield 1;} : () => AsyncIterableIterator<1> +>f14 : () => AsyncIterableIterator +>async function * () { yield 1;} : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -142,8 +142,8 @@ const f15 = async function * () { }; === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts === const f16 = async function * () { ->f16 : () => AsyncIterableIterator ->async function * () { yield * [];} : () => AsyncIterableIterator +>f16 : () => AsyncIterableIterator +>async function * () { yield * [];} : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types index d352b54158549..59ed6e16745a5 100644 --- a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types @@ -163,11 +163,11 @@ const o13 = { }; === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts === const o14 = { ->o14 : { f(): AsyncIterableIterator<1>; } ->{ async * f() { yield 1; }} : { f(): AsyncIterableIterator<1>; } +>o14 : { f(): AsyncIterableIterator; } +>{ async * f() { yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -189,11 +189,11 @@ const o15 = { }; === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts === const o16 = { ->o16 : { f(): AsyncIterableIterator; } ->{ async * f() { yield * []; }} : { f(): AsyncIterableIterator; } +>o16 : { f(): AsyncIterableIterator; } +>{ async * f() { yield * []; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types index e4496aa4e8ba8..dfd4e522def17 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === function* gen() { ->gen : () => IterableIterator<10> +>gen : () => IterableIterator // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; diff --git a/tests/baselines/reference/types.asyncGenerators.esnext.1.types b/tests/baselines/reference/types.asyncGenerators.esnext.1.types index 1a72da228e762..6e29e9cc95cab 100644 --- a/tests/baselines/reference/types.asyncGenerators.esnext.1.types +++ b/tests/baselines/reference/types.asyncGenerators.esnext.1.types @@ -9,7 +9,7 @@ async function * inferReturnType2() { >yield : any } async function * inferReturnType3() { ->inferReturnType3 : () => AsyncIterableIterator<1> +>inferReturnType3 : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -63,20 +63,20 @@ async function * inferReturnType7() { >1 : 1 } async function * inferReturnType8() { ->inferReturnType8 : () => AsyncIterableIterator<1> +>inferReturnType8 : () => AsyncIterableIterator yield* (async function * () { yield 1; })(); >yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator<1> ->(async function * () { yield 1; }) : () => AsyncIterableIterator<1> ->async function * () { yield 1; } : () => AsyncIterableIterator<1> +>(async function * () { yield 1; })() : AsyncIterableIterator +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield 1;} : () => AsyncIterableIterator<1> +>async function * () { yield 1;} : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -127,13 +127,13 @@ const assignability4: () => AsyncIterableIterator = async function * () const assignability5: () => AsyncIterableIterator = async function * () { >assignability5 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1> +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator yield* (async function * () { yield 1; })(); >yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator<1> ->(async function * () { yield 1; }) : () => AsyncIterableIterator<1> ->async function * () { yield 1; } : () => AsyncIterableIterator<1> +>(async function * () { yield 1; })() : AsyncIterableIterator +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 @@ -141,7 +141,7 @@ const assignability5: () => AsyncIterableIterator = async function * () const assignability6: () => AsyncIterable = async function * () { >assignability6 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield 1;} : () => AsyncIterableIterator<1> +>async function * () { yield 1;} : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -192,13 +192,13 @@ const assignability9: () => AsyncIterable = async function * () { const assignability10: () => AsyncIterable = async function * () { >assignability10 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1> +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator yield* (async function * () { yield 1; })(); >yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator<1> ->(async function * () { yield 1; }) : () => AsyncIterableIterator<1> ->async function * () { yield 1; } : () => AsyncIterableIterator<1> +>(async function * () { yield 1; })() : AsyncIterableIterator +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 @@ -206,7 +206,7 @@ const assignability10: () => AsyncIterable = async function * () { const assignability11: () => AsyncIterator = async function * () { >assignability11 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield 1;} : () => AsyncIterableIterator<1> +>async function * () { yield 1;} : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -257,13 +257,13 @@ const assignability14: () => AsyncIterator = async function * () { const assignability15: () => AsyncIterator = async function * () { >assignability15 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1> +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator yield* (async function * () { yield 1; })(); >yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator<1> ->(async function * () { yield 1; }) : () => AsyncIterableIterator<1> ->async function * () { yield 1; } : () => AsyncIterableIterator<1> +>(async function * () { yield 1; })() : AsyncIterableIterator +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 @@ -317,9 +317,9 @@ async function * explicitReturnType5(): AsyncIterableIterator { yield* (async function * () { yield 1; })(); >yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator<1> ->(async function * () { yield 1; }) : () => AsyncIterableIterator<1> ->async function * () { yield 1; } : () => AsyncIterableIterator<1> +>(async function * () { yield 1; })() : AsyncIterableIterator +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -372,9 +372,9 @@ async function * explicitReturnType10(): AsyncIterable { yield* (async function * () { yield 1; })(); >yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator<1> ->(async function * () { yield 1; }) : () => AsyncIterableIterator<1> ->async function * () { yield 1; } : () => AsyncIterableIterator<1> +>(async function * () { yield 1; })() : AsyncIterableIterator +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -427,9 +427,9 @@ async function * explicitReturnType15(): AsyncIterator { yield* (async function * () { yield 1; })(); >yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator<1> ->(async function * () { yield 1; }) : () => AsyncIterableIterator<1> ->async function * () { yield 1; } : () => AsyncIterableIterator<1> +>(async function * () { yield 1; })() : AsyncIterableIterator +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } diff --git a/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt b/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt index 64d7980578c28..a6a0243ded606 100644 --- a/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt +++ b/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt @@ -1,24 +1,13 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(2,12): error TS2504: Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(8,12): error TS2504: Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(10,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. - Type '"a"' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(10,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(16,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(19,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. - Types of property '[Symbol.asyncIterator]' are incompatible. - Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. - Types of property 'next' are incompatible. - Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => Promise>'. - Type 'Promise>' is not assignable to type 'Promise>'. - Type 'IteratorResult<"a">' is not assignable to type 'IteratorResult'. - Type '"a"' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(22,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(16,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(19,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. Types of property '[Symbol.asyncIterator]' are incompatible. Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. @@ -28,23 +17,25 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( Type 'Promise>' is not assignable to type 'Promise>'. Type 'IteratorResult' is not assignable to type 'IteratorResult'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(25,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(28,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(22,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(25,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(28,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(31,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(34,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(34,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(38,11): error TS2322: Type '"a"' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(41,12): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(44,12): error TS2322: Type '"a"' is not assignable to type 'number'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(44,12): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(47,11): error TS2322: Type '"a"' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(50,12): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(53,12): error TS2322: Type '"a"' is not assignable to type 'number'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(53,12): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(56,11): error TS2322: Type '"a"' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(59,12): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(62,12): error TS2322: Type '"a"' is not assignable to type 'number'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(62,12): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(64,42): error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'IterableIterator'. Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(67,42): error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'Iterable'. @@ -73,40 +64,25 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( } const assignability1: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. -!!! error TS2322: Type '"a"' is not assignable to type 'number'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. yield "a"; }; const assignability2: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. !!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. yield* ["a", "b"]; }; const assignability3: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. yield* (async function * () { yield "a"; })(); }; const assignability4: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. -!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => Promise>'. -!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. -!!! error TS2322: Type 'IteratorResult<"a">' is not assignable to type 'IteratorResult'. -!!! error TS2322: Type '"a"' is not assignable to type 'number'. - yield "a"; - }; - const assignability5: () => AsyncIterable = async function * () { - ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. !!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. !!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. @@ -117,18 +93,24 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( !!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. !!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. !!! error TS2322: Type 'string' is not assignable to type 'number'. + yield "a"; + }; + const assignability5: () => AsyncIterable = async function * () { + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. yield* ["a", "b"]; }; const assignability6: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. yield* (async function * () { yield "a"; })(); }; const assignability7: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. yield "a"; }; const assignability8: () => AsyncIterator = async function * () { @@ -139,8 +121,8 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( }; const assignability9: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. yield* (async function * () { yield "a"; })(); }; async function * explicitReturnType1(): AsyncIterableIterator { @@ -156,7 +138,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( async function * explicitReturnType3(): AsyncIterableIterator { yield* (async function * () { yield "a"; })(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '"a"' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. } async function * explicitReturnType4(): AsyncIterable { yield "a"; @@ -171,7 +153,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( async function * explicitReturnType6(): AsyncIterable { yield* (async function * () { yield "a"; })(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '"a"' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. } async function * explicitReturnType7(): AsyncIterator { yield "a"; @@ -186,7 +168,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( async function * explicitReturnType9(): AsyncIterator { yield* (async function * () { yield "a"; })(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '"a"' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. } async function * explicitReturnType10(): IterableIterator { ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/types.asyncGenerators.esnext.2.types b/tests/baselines/reference/types.asyncGenerators.esnext.2.types index 2d29f5a7e1d97..c9f8e9216c4a8 100644 --- a/tests/baselines/reference/types.asyncGenerators.esnext.2.types +++ b/tests/baselines/reference/types.asyncGenerators.esnext.2.types @@ -30,7 +30,7 @@ async function * inferReturnType3() { const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield "a";} : () => AsyncIterableIterator<"a"> +>async function * () { yield "a";} : () => AsyncIterableIterator yield "a"; >yield "a" : any @@ -52,13 +52,13 @@ const assignability2: () => AsyncIterableIterator = async function * () const assignability3: () => AsyncIterableIterator = async function * () { >assignability3 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a"> +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator yield* (async function * () { yield "a"; })(); >yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator<"a"> ->(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a"> ->async function * () { yield "a"; } : () => AsyncIterableIterator<"a"> +>(async function * () { yield "a"; })() : AsyncIterableIterator +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" @@ -66,7 +66,7 @@ const assignability3: () => AsyncIterableIterator = async function * () const assignability4: () => AsyncIterable = async function * () { >assignability4 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield "a";} : () => AsyncIterableIterator<"a"> +>async function * () { yield "a";} : () => AsyncIterableIterator yield "a"; >yield "a" : any @@ -88,13 +88,13 @@ const assignability5: () => AsyncIterable = async function * () { const assignability6: () => AsyncIterable = async function * () { >assignability6 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a"> +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator yield* (async function * () { yield "a"; })(); >yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator<"a"> ->(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a"> ->async function * () { yield "a"; } : () => AsyncIterableIterator<"a"> +>(async function * () { yield "a"; })() : AsyncIterableIterator +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" @@ -102,7 +102,7 @@ const assignability6: () => AsyncIterable = async function * () { const assignability7: () => AsyncIterator = async function * () { >assignability7 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield "a";} : () => AsyncIterableIterator<"a"> +>async function * () { yield "a";} : () => AsyncIterableIterator yield "a"; >yield "a" : any @@ -124,13 +124,13 @@ const assignability8: () => AsyncIterator = async function * () { const assignability9: () => AsyncIterator = async function * () { >assignability9 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a"> +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator yield* (async function * () { yield "a"; })(); >yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator<"a"> ->(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a"> ->async function * () { yield "a"; } : () => AsyncIterableIterator<"a"> +>(async function * () { yield "a"; })() : AsyncIterableIterator +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" @@ -159,9 +159,9 @@ async function * explicitReturnType3(): AsyncIterableIterator { yield* (async function * () { yield "a"; })(); >yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator<"a"> ->(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a"> ->async function * () { yield "a"; } : () => AsyncIterableIterator<"a"> +>(async function * () { yield "a"; })() : AsyncIterableIterator +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" } @@ -189,9 +189,9 @@ async function * explicitReturnType6(): AsyncIterable { yield* (async function * () { yield "a"; })(); >yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator<"a"> ->(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a"> ->async function * () { yield "a"; } : () => AsyncIterableIterator<"a"> +>(async function * () { yield "a"; })() : AsyncIterableIterator +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" } @@ -219,9 +219,9 @@ async function * explicitReturnType9(): AsyncIterator { yield* (async function * () { yield "a"; })(); >yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator<"a"> ->(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a"> ->async function * () { yield "a"; } : () => AsyncIterableIterator<"a"> +>(async function * () { yield "a"; })() : AsyncIterableIterator +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" } diff --git a/tests/baselines/reference/uniqueSymbols.js b/tests/baselines/reference/uniqueSymbols.js index 4de307ee197a7..6c723c8dec17d 100644 --- a/tests/baselines/reference/uniqueSymbols.js +++ b/tests/baselines/reference/uniqueSymbols.js @@ -122,6 +122,7 @@ declare function g(x: typeof s): void; declare function g(x: typeof N.s): void; // widening positions + // argument inference f(s); f(N.s); @@ -132,11 +133,17 @@ f(N["s"]); [N.s]; [N["s"]]; -// property assignments +// property assignments/methods const o2 = { a: s, b: N.s, - c: N["s"] + c: N["s"], + + method1() { return s; }, + async method2() { return s; }, + async * method3() { yield s; }, + * method4() { yield s; }, + method5(p = s) { return p; }, }; // property initializers @@ -156,6 +163,12 @@ class C0 { d = s; e = N.s; f = N["s"]; + + method1() { return s; } + async method2() { return s; } + async * method3() { yield s; } + * method4() { yield s; } + method5(p = s) { return p; } } // non-widening positions @@ -195,7 +208,60 @@ class C1 { [s]: "a"; [N.s]: "b"; -} +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: typeof s): typeof s; +} + +const o3: Context = { + method1() { + return s; // return type should not widen due to contextual type + }, + async method2() { + return s; // return type should not widen due to contextual type + }, + async * method3() { + yield s; // yield type should not widen due to contextual type + }, + * method4() { + yield s; // yield type should not widen due to contextual type + }, + method5(p = s) { // parameter should not widen due to contextual type + return p; + }, +}; + +// allowed when not emitting declarations + +const o4 = { + method1(p: typeof s): typeof s { + return p; + }, + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +const ce0 = class { + method1(p: typeof s): typeof s { + return p; + } + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +function funcInferredReturnType(obj: { method(p: typeof s): void }) { + return obj; +} + //// [uniqueSymbols.js] // declarations with call initializer @@ -285,11 +351,16 @@ f(N["s"]); [s]; [N.s]; [N["s"]]; -// property assignments +// property assignments/methods const o2 = { a: s, b: N.s, - c: N["s"] + c: N["s"], + method1() { return s; }, + async method2() { return s; }, + async *method3() { yield s; }, + *method4() { yield s; }, + method5(p = s) { return p; }, }; // property initializers class C0 { @@ -301,6 +372,11 @@ class C0 { this.e = N.s; this.f = N["s"]; } + method1() { return s; } + async method2() { return s; } + async *method3() { yield s; } + *method4() { yield s; } + method5(p = s) { return p; } } C0.a = s; C0.b = N.s; @@ -335,120 +411,40 @@ Math.random() * 2 ? N["s"] : "a"; }); class C1 { } - - -//// [uniqueSymbols.d.ts] -declare const constCall: unique symbol; -declare let letCall: symbol; -declare var varCall: symbol; -declare const constType: unique symbol; -declare const constTypeAndCall: unique symbol; -declare const constInitToConstCall: symbol; -declare const constInitToLetCall: symbol; -declare const constInitToVarCall: symbol; -declare const constInitToConstDeclAmbient: symbol; -declare let letInitToConstCall: symbol; -declare let letInitToLetCall: symbol; -declare let letInitToVarCall: symbol; -declare let letInitToConstDeclAmbient: symbol; -declare var varInitToConstCall: symbol; -declare var varInitToLetCall: symbol; -declare var varInitToVarCall: symbol; -declare var varInitToConstDeclAmbient: symbol; -declare const constInitToConstCallWithTypeQuery: typeof constCall; -declare const constInitToConstDeclAmbientWithTypeQuery: typeof constType; -declare function funcReturnConstCall(): symbol; -declare function funcReturnLetCall(): symbol; -declare function funcReturnVarCall(): symbol; -declare function funcReturnConstCallWithTypeQuery(): typeof constCall; -declare function genFuncYieldConstCall(): IterableIterator; -declare function genFuncYieldLetCall(): IterableIterator; -declare function genFuncYieldVarCall(): IterableIterator; -declare function genFuncYieldConstCallWithTypeQuery(): IterableIterator; -declare function asyncFuncReturnConstCall(): Promise; -declare function asyncFuncReturnLetCall(): Promise; -declare function asyncFuncReturnVarCall(): Promise; -declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator; -declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator; -declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator; -declare class C { - static readonly readonlyStaticCall: unique symbol; - static readonly readonlyStaticType: unique symbol; - static readonly readonlyStaticTypeAndCall: unique symbol; - static readwriteStaticCall: symbol; - readonly readonlyCall: symbol; - readwriteCall: symbol; -} -declare const c: C; -declare const constInitToCReadonlyStaticCall: symbol; -declare const constInitToCReadonlyStaticType: symbol; -declare const constInitToCReadonlyStaticTypeAndCall: symbol; -declare const constInitToCReadwriteStaticCall: symbol; -declare const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall; -declare const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType; -declare const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall; -declare const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall; -declare const constInitToCReadonlyCall: symbol; -declare const constInitToCReadwriteCall: symbol; -declare const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall; -declare const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall; -declare const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"]; -declare const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"]; -interface I { - readonly readonlyType: unique symbol; -} -declare const i: I; -declare const constInitToIReadonlyType: symbol; -declare const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType; -declare const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"]; -declare type L = { - readonly readonlyType: unique symbol; - nested: { - readonly readonlyNestedType: unique symbol; - }; +const o3 = { + method1() { + return s; // return type should not widen due to contextual type + }, + async method2() { + return s; // return type should not widen due to contextual type + }, + async *method3() { + yield s; // yield type should not widen due to contextual type + }, + *method4() { + yield s; // yield type should not widen due to contextual type + }, + method5(p = s) { + return p; + }, }; -declare const l: L; -declare const constInitToLReadonlyType: symbol; -declare const constInitToLReadonlyNestedType: symbol; -declare const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType; -declare const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType; -declare const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"]; -declare const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"]; -declare const promiseForConstCall: Promise; -declare const arrayOfConstCall: symbol[]; -declare const s: unique symbol; -declare namespace N { - const s: unique symbol; -} -declare const o: { - [s]: "a"; - [N.s]: "b"; +// allowed when not emitting declarations +const o4 = { + method1(p) { + return p; + }, + method2(p) { + return p; + } }; -declare function f(x: T): T; -declare function g(x: typeof s): void; -declare function g(x: typeof N.s): void; -declare const o2: { - a: symbol; - b: symbol; - c: symbol; +const ce0 = class { + method1(p) { + return p; + } + method2(p) { + return p; + } }; -declare class C0 { - static readonly a: symbol; - static readonly b: symbol; - static readonly c: symbol; - static d: symbol; - static e: symbol; - static f: symbol; - readonly a: symbol; - readonly b: symbol; - readonly c: symbol; - d: symbol; - e: symbol; - f: symbol; -} -declare class C1 { - static [s]: "a"; - static [N.s]: "b"; - [s]: "a"; - [N.s]: "b"; +function funcInferredReturnType(obj) { + return obj; } diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols index 80c0611ce74b4..e798011683ae2 100644 --- a/tests/baselines/reference/uniqueSymbols.symbols +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -431,6 +431,7 @@ declare function g(x: typeof N.s): void; >s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) // widening positions + // argument inference f(s); >f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) @@ -460,90 +461,134 @@ f(N["s"]); >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) -// property assignments +// property assignments/methods const o2 = { ->o2 : Symbol(o2, Decl(uniqueSymbols.ts, 134, 5)) +>o2 : Symbol(o2, Decl(uniqueSymbols.ts, 135, 5)) a: s, ->a : Symbol(a, Decl(uniqueSymbols.ts, 134, 12)) +>a : Symbol(a, Decl(uniqueSymbols.ts, 135, 12)) >s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) b: N.s, ->b : Symbol(b, Decl(uniqueSymbols.ts, 135, 9)) +>b : Symbol(b, Decl(uniqueSymbols.ts, 136, 9)) >N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) - c: N["s"] ->c : Symbol(c, Decl(uniqueSymbols.ts, 136, 11)) + c: N["s"], +>c : Symbol(c, Decl(uniqueSymbols.ts, 137, 11)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + method1() { return s; }, +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 138, 14)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + async method2() { return s; }, +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 140, 28)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + async * method3() { yield s; }, +>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 141, 34)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + * method4() { yield s; }, +>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 142, 35)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + method5(p = s) { return p; }, +>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 143, 29)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12)) + }; // property initializers class C0 { ->C0 : Symbol(C0, Decl(uniqueSymbols.ts, 138, 2)) +>C0 : Symbol(C0, Decl(uniqueSymbols.ts, 145, 2)) static readonly a = s; ->a : Symbol(C0.a, Decl(uniqueSymbols.ts, 141, 10)) +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 148, 10)) >s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) static readonly b = N.s; ->b : Symbol(C0.b, Decl(uniqueSymbols.ts, 142, 26)) +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 149, 26)) >N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) static readonly c = N["s"]; ->c : Symbol(C0.c, Decl(uniqueSymbols.ts, 143, 28)) +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 150, 28)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) static d = s; ->d : Symbol(C0.d, Decl(uniqueSymbols.ts, 144, 31)) +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 151, 31)) >s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) static e = N.s; ->e : Symbol(C0.e, Decl(uniqueSymbols.ts, 146, 17)) +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 153, 17)) >N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) static f = N["s"]; ->f : Symbol(C0.f, Decl(uniqueSymbols.ts, 147, 19)) +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 154, 19)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) readonly a = s; ->a : Symbol(C0.a, Decl(uniqueSymbols.ts, 148, 22)) +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 155, 22)) >s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) readonly b = N.s; ->b : Symbol(C0.b, Decl(uniqueSymbols.ts, 150, 19)) +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 157, 19)) >N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) readonly c = N["s"]; ->c : Symbol(C0.c, Decl(uniqueSymbols.ts, 151, 21)) +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 158, 21)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) d = s; ->d : Symbol(C0.d, Decl(uniqueSymbols.ts, 152, 24)) +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 159, 24)) >s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) e = N.s; ->e : Symbol(C0.e, Decl(uniqueSymbols.ts, 154, 10)) +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 161, 10)) >N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) f = N["s"]; ->f : Symbol(C0.f, Decl(uniqueSymbols.ts, 155, 12)) +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 162, 12)) >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + + method1() { return s; } +>method1 : Symbol(C0.method1, Decl(uniqueSymbols.ts, 163, 15)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + async method2() { return s; } +>method2 : Symbol(C0.method2, Decl(uniqueSymbols.ts, 165, 27)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + async * method3() { yield s; } +>method3 : Symbol(C0.method3, Decl(uniqueSymbols.ts, 166, 33)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + * method4() { yield s; } +>method4 : Symbol(C0.method4, Decl(uniqueSymbols.ts, 167, 34)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + method5(p = s) { return p; } +>method5 : Symbol(C0.method5, Decl(uniqueSymbols.ts, 168, 28)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12)) } // non-widening positions @@ -650,7 +695,7 @@ Math.random() * 2 ? N["s"] : "a"; }); class C1 { ->C1 : Symbol(C1, Decl(uniqueSymbols.ts, 188, 3)) +>C1 : Symbol(C1, Decl(uniqueSymbols.ts, 201, 3)) static [s]: "a"; >s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) @@ -668,3 +713,138 @@ class C1 { >N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) >s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) } + +// contextual types + +interface Context { +>Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1)) + + method1(): typeof s; +>method1 : Symbol(Context.method1, Decl(uniqueSymbols.ts, 213, 19)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + method2(): Promise; +>method2 : Symbol(Context.method2, Decl(uniqueSymbols.ts, 214, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + method3(): AsyncIterableIterator; +>method3 : Symbol(Context.method3, Decl(uniqueSymbols.ts, 215, 33)) +>AsyncIterableIterator : Symbol(AsyncIterableIterator, Decl(lib.esnext.asynciterable.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + method4(): IterableIterator; +>method4 : Symbol(Context.method4, Decl(uniqueSymbols.ts, 216, 47)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + method5(p?: typeof s): typeof s; +>method5 : Symbol(Context.method5, Decl(uniqueSymbols.ts, 217, 42)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 218, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +} + +const o3: Context = { +>o3 : Symbol(o3, Decl(uniqueSymbols.ts, 221, 5)) +>Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1)) + + method1() { +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 221, 21)) + + return s; // return type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + }, + async method2() { +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 224, 6)) + + return s; // return type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + }, + async * method3() { +>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 227, 6)) + + yield s; // yield type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + }, + * method4() { +>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 230, 6)) + + yield s; // yield type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + }, + method5(p = s) { // parameter should not widen due to contextual type +>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 233, 6)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + return p; +>p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12)) + + }, +}; + +// allowed when not emitting declarations + +const o4 = { +>o4 : Symbol(o4, Decl(uniqueSymbols.ts, 241, 5)) + + method1(p: typeof s): typeof s { +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 241, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + return p; +>p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12)) + + }, + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 244, 6)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) + + return p; +>p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12)) + } +}; + +const ce0 = class { +>ce0 : Symbol(ce0, Decl(uniqueSymbols.ts, 250, 5)) + + method1(p: typeof s): typeof s { +>method1 : Symbol(ce0.method1, Decl(uniqueSymbols.ts, 250, 19)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + return p; +>p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12)) + } + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : Symbol(ce0.method2, Decl(uniqueSymbols.ts, 253, 5)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) + + return p; +>p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12)) + } +}; + +function funcInferredReturnType(obj: { method(p: typeof s): void }) { +>funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbols.ts, 257, 2)) +>obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32)) +>method : Symbol(method, Decl(uniqueSymbols.ts, 259, 38)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 259, 46)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + return obj; +>obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32)) +} + diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index 3deaf4572f4be..6516ee25dd06b 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -449,6 +449,7 @@ declare function g(x: typeof N.s): void; >s : unique symbol // widening positions + // argument inference f(s); >f(s) : symbol @@ -486,10 +487,10 @@ f(N["s"]); >N : typeof N >"s" : "s" -// property assignments +// property assignments/methods const o2 = { ->o2 : { a: symbol; b: symbol; c: symbol; } ->{ a: s, b: N.s, c: N["s"]} : { a: symbol; b: symbol; c: symbol; } +>o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } +>{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; },} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } a: s, >a : symbol @@ -501,12 +502,36 @@ const o2 = { >N : typeof N >s : unique symbol - c: N["s"] + c: N["s"], >c : symbol >N["s"] : unique symbol >N : typeof N >"s" : "s" + method1() { return s; }, +>method1 : () => symbol +>s : unique symbol + + async method2() { return s; }, +>method2 : () => Promise +>s : unique symbol + + async * method3() { yield s; }, +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; }, +>method4 : () => IterableIterator +>yield s : any +>s : unique symbol + + method5(p = s) { return p; }, +>method5 : (p?: symbol) => symbol +>p : symbol +>s : unique symbol +>p : symbol + }; // property initializers @@ -576,6 +601,30 @@ class C0 { >N["s"] : unique symbol >N : typeof N >"s" : "s" + + method1() { return s; } +>method1 : () => symbol +>s : unique symbol + + async method2() { return s; } +>method2 : () => Promise +>s : unique symbol + + async * method3() { yield s; } +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; } +>method4 : () => IterableIterator +>yield s : any +>s : unique symbol + + method5(p = s) { return p; } +>method5 : (p?: symbol) => symbol +>p : symbol +>s : unique symbol +>p : symbol } // non-widening positions @@ -740,3 +789,143 @@ class C1 { >N : typeof N >s : unique symbol } + +// contextual types + +interface Context { +>Context : Context + + method1(): typeof s; +>method1 : () => unique symbol +>s : unique symbol + + method2(): Promise; +>method2 : () => Promise +>Promise : Promise +>s : unique symbol + + method3(): AsyncIterableIterator; +>method3 : () => AsyncIterableIterator +>AsyncIterableIterator : AsyncIterableIterator +>s : unique symbol + + method4(): IterableIterator; +>method4 : () => IterableIterator +>IterableIterator : IterableIterator +>s : unique symbol + + method5(p?: typeof s): typeof s; +>method5 : (p?: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol +>s : unique symbol +} + +const o3: Context = { +>o3 : Context +>Context : Context +>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: unique symbol): unique symbol; } + + method1() { +>method1 : () => unique symbol + + return s; // return type should not widen due to contextual type +>s : unique symbol + + }, + async method2() { +>method2 : () => Promise + + return s; // return type should not widen due to contextual type +>s : unique symbol + + }, + async * method3() { +>method3 : () => AsyncIterableIterator + + yield s; // yield type should not widen due to contextual type +>yield s : any +>s : unique symbol + + }, + * method4() { +>method4 : () => IterableIterator + + yield s; // yield type should not widen due to contextual type +>yield s : any +>s : unique symbol + + }, + method5(p = s) { // parameter should not widen due to contextual type +>method5 : (p?: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol + + return p; +>p : unique symbol + + }, +}; + +// allowed when not emitting declarations + +const o4 = { +>o4 : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; } +>{ method1(p: typeof s): typeof s { return p; }, method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; } + + method1(p: typeof s): typeof s { +>method1 : (p: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol +>s : unique symbol + + return p; +>p : unique symbol + + }, + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : (p: unique symbol) => unique symbol +>p : unique symbol +>I : I +>I : I + + return p; +>p : unique symbol + } +}; + +const ce0 = class { +>ce0 : typeof ce0 +>class { method1(p: typeof s): typeof s { return p; } method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : typeof ce0 + + method1(p: typeof s): typeof s { +>method1 : (p: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol +>s : unique symbol + + return p; +>p : unique symbol + } + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : (p: unique symbol) => unique symbol +>p : unique symbol +>I : I +>I : I + + return p; +>p : unique symbol + } +}; + +function funcInferredReturnType(obj: { method(p: typeof s): void }) { +>funcInferredReturnType : (obj: { method(p: unique symbol): void; }) => { method(p: unique symbol): void; } +>obj : { method(p: unique symbol): void; } +>method : (p: unique symbol) => void +>p : unique symbol +>s : unique symbol + + return obj; +>obj : { method(p: unique symbol): void; } +} + diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.js b/tests/baselines/reference/uniqueSymbolsDeclarations.js new file mode 100644 index 0000000000000..6b52b2109772f --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.js @@ -0,0 +1,540 @@ +//// [uniqueSymbolsDeclarations.ts] +// declarations with call initializer +const constCall = Symbol(); +let letCall = Symbol(); +var varCall = Symbol(); + +// ambient declaration with type +declare const constType: unique symbol; + +// declaration with type and call initializer +const constTypeAndCall: unique symbol = Symbol(); + +// declaration from initializer +const constInitToConstCall = constCall; +const constInitToLetCall = letCall; +const constInitToVarCall = varCall; +const constInitToConstDeclAmbient = constType; +let letInitToConstCall = constCall; +let letInitToLetCall = letCall; +let letInitToVarCall = varCall; +let letInitToConstDeclAmbient = constType; +var varInitToConstCall = constCall; +var varInitToLetCall = letCall; +var varInitToVarCall = varCall; +var varInitToConstDeclAmbient = constType; + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; + +// function return inference +function funcReturnConstCall() { return constCall; } +function funcReturnLetCall() { return letCall; } +function funcReturnVarCall() { return varCall; } + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +function* genFuncYieldLetCall() { yield letCall; } +function* genFuncYieldVarCall() { yield varCall; } + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +async function asyncFuncReturnLetCall() { return letCall; } +async function asyncFuncReturnVarCall() { return varCall; } + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +async function* asyncGenFuncYieldLetCall() { yield letCall; } +async function* asyncGenFuncYieldVarCall() { yield varCall; } + +// classes +class C { + static readonly readonlyStaticCall = Symbol(); + static readonly readonlyStaticType: unique symbol; + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); + static readwriteStaticCall = Symbol(); + + readonly readonlyCall = Symbol(); + readwriteCall = Symbol(); +} +declare const c: C; + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyCall = c.readonlyCall; +const constInitToCReadwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; + +// interfaces +interface I { + readonly readonlyType: unique symbol; +} +declare const i: I; + +const constInitToIReadonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; + +// type literals +type L = { + readonly readonlyType: unique symbol; + nested: { + readonly readonlyNestedType: unique symbol; + } +}; +declare const l: L; + +const constInitToLReadonlyType = l.readonlyType; +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +const arrayOfConstCall = [constCall]; + +// unique symbol widening in expressions +declare const s: unique symbol; +declare namespace N { const s: unique symbol; } +declare const o: { [s]: "a", [N.s]: "b" }; +declare function f(x: T): T; +declare function g(x: typeof s): void; +declare function g(x: typeof N.s): void; + +// widening positions + +// argument inference +f(s); +f(N.s); +f(N["s"]); + +// array literal elements +[s]; +[N.s]; +[N["s"]]; + +// property assignments/methods +const o2 = { + a: s, + b: N.s, + c: N["s"], + + method1() { return s; }, + async method2() { return s; }, + async * method3() { yield s; }, + * method4() { yield s; }, + method5(p = s) { return p; } +}; + +// property initializers +class C0 { + static readonly a = s; + static readonly b = N.s; + static readonly c = N["s"]; + + static d = s; + static e = N.s; + static f = N["s"]; + + readonly a = s; + readonly b = N.s; + readonly c = N["s"]; + + d = s; + e = N.s; + f = N["s"]; + + method1() { return s; } + async method2() { return s; } + async * method3() { yield s; } + * method4() { yield s; } + method5(p = s) { return p; } +} + +// non-widening positions + +// element access +o[s]; +o[N.s]; +o[N["s"]]; + +// arguments (no-inference) +f(s); +f(N.s); +f(N["s"]); +g(s); +g(N.s); +g(N["s"]); + +// falsy expressions +s || ""; +N.s || ""; +N["s"] || ""; + +// conditionals +Math.random() * 2 ? s : "a"; +Math.random() * 2 ? N.s : "a"; +Math.random() * 2 ? N["s"] : "a"; + +// computed property names +({ + [s]: "a", + [N.s]: "b", +}); + +class C1 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: typeof s): typeof s; +} + +const o4: Context = { + method1() { + return s; // return type should not widen due to contextual type + }, + async method2() { + return s; // return type should not widen due to contextual type + }, + async * method3() { + yield s; // yield type should not widen due to contextual type + }, + * method4() { + yield s; // yield type should not widen due to contextual type + }, + method5(p = s) { // parameter should not widen due to contextual type + return p; + } +}; + +//// [uniqueSymbolsDeclarations.js] +// declarations with call initializer +const constCall = Symbol(); +let letCall = Symbol(); +var varCall = Symbol(); +// declaration with type and call initializer +const constTypeAndCall = Symbol(); +// declaration from initializer +const constInitToConstCall = constCall; +const constInitToLetCall = letCall; +const constInitToVarCall = varCall; +const constInitToConstDeclAmbient = constType; +let letInitToConstCall = constCall; +let letInitToLetCall = letCall; +let letInitToVarCall = varCall; +let letInitToConstDeclAmbient = constType; +var varInitToConstCall = constCall; +var varInitToLetCall = letCall; +var varInitToVarCall = varCall; +var varInitToConstDeclAmbient = constType; +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery = constCall; +const constInitToConstDeclAmbientWithTypeQuery = constType; +// function return inference +function funcReturnConstCall() { return constCall; } +function funcReturnLetCall() { return letCall; } +function funcReturnVarCall() { return varCall; } +// function return value with type query +function funcReturnConstCallWithTypeQuery() { return constCall; } +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +function* genFuncYieldLetCall() { yield letCall; } +function* genFuncYieldVarCall() { yield varCall; } +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery() { yield constCall; } +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +async function asyncFuncReturnLetCall() { return letCall; } +async function asyncFuncReturnVarCall() { return varCall; } +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +async function* asyncGenFuncYieldLetCall() { yield letCall; } +async function* asyncGenFuncYieldVarCall() { yield varCall; } +// classes +class C { + constructor() { + this.readonlyCall = Symbol(); + this.readwriteCall = Symbol(); + } +} +C.readonlyStaticCall = Symbol(); +C.readonlyStaticTypeAndCall = Symbol(); +C.readwriteStaticCall = Symbol(); +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; +const constInitToCReadonlyStaticCallWithTypeQuery = C.readonlyStaticCall; +const constInitToCReadonlyStaticTypeWithTypeQuery = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCallWithTypeQuery = C.readwriteStaticCall; +const constInitToCReadonlyCall = c.readonlyCall; +const constInitToCReadwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithTypeQuery = c.readonlyCall; +const constInitToCReadwriteCallWithTypeQuery = c.readwriteCall; +const constInitToCReadonlyCallWithIndexedAccess = c.readonlyCall; +const constInitToCReadwriteCallWithIndexedAccess = c.readwriteCall; +const constInitToIReadonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithTypeQuery = i.readonlyType; +const constInitToIReadonlyTypeWithIndexedAccess = i.readonlyType; +const constInitToLReadonlyType = l.readonlyType; +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithTypeQuery = l.readonlyType; +const constInitToLReadonlyNestedTypeWithTypeQuery = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithIndexedAccess = l.readonlyType; +const constInitToLReadonlyNestedTypeWithIndexedAccess = l.nested.readonlyNestedType; +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +const arrayOfConstCall = [constCall]; +// widening positions +// argument inference +f(s); +f(N.s); +f(N["s"]); +// array literal elements +[s]; +[N.s]; +[N["s"]]; +// property assignments/methods +const o2 = { + a: s, + b: N.s, + c: N["s"], + method1() { return s; }, + async method2() { return s; }, + async *method3() { yield s; }, + *method4() { yield s; }, + method5(p = s) { return p; } +}; +// property initializers +class C0 { + constructor() { + this.a = s; + this.b = N.s; + this.c = N["s"]; + this.d = s; + this.e = N.s; + this.f = N["s"]; + } + method1() { return s; } + async method2() { return s; } + async *method3() { yield s; } + *method4() { yield s; } + method5(p = s) { return p; } +} +C0.a = s; +C0.b = N.s; +C0.c = N["s"]; +C0.d = s; +C0.e = N.s; +C0.f = N["s"]; +// non-widening positions +// element access +o[s]; +o[N.s]; +o[N["s"]]; +// arguments (no-inference) +f(s); +f(N.s); +f(N["s"]); +g(s); +g(N.s); +g(N["s"]); +// falsy expressions +s || ""; +N.s || ""; +N["s"] || ""; +// conditionals +Math.random() * 2 ? s : "a"; +Math.random() * 2 ? N.s : "a"; +Math.random() * 2 ? N["s"] : "a"; +// computed property names +({ + [s]: "a", + [N.s]: "b", +}); +class C1 { +} +const o4 = { + method1() { + return s; // return type should not widen due to contextual type + }, + async method2() { + return s; // return type should not widen due to contextual type + }, + async *method3() { + yield s; // yield type should not widen due to contextual type + }, + *method4() { + yield s; // yield type should not widen due to contextual type + }, + method5(p = s) { + return p; + } +}; + + +//// [uniqueSymbolsDeclarations.d.ts] +declare const constCall: unique symbol; +declare let letCall: symbol; +declare var varCall: symbol; +declare const constType: unique symbol; +declare const constTypeAndCall: unique symbol; +declare const constInitToConstCall: symbol; +declare const constInitToLetCall: symbol; +declare const constInitToVarCall: symbol; +declare const constInitToConstDeclAmbient: symbol; +declare let letInitToConstCall: symbol; +declare let letInitToLetCall: symbol; +declare let letInitToVarCall: symbol; +declare let letInitToConstDeclAmbient: symbol; +declare var varInitToConstCall: symbol; +declare var varInitToLetCall: symbol; +declare var varInitToVarCall: symbol; +declare var varInitToConstDeclAmbient: symbol; +declare const constInitToConstCallWithTypeQuery: typeof constCall; +declare const constInitToConstDeclAmbientWithTypeQuery: typeof constType; +declare function funcReturnConstCall(): symbol; +declare function funcReturnLetCall(): symbol; +declare function funcReturnVarCall(): symbol; +declare function funcReturnConstCallWithTypeQuery(): typeof constCall; +declare function genFuncYieldConstCall(): IterableIterator; +declare function genFuncYieldLetCall(): IterableIterator; +declare function genFuncYieldVarCall(): IterableIterator; +declare function genFuncYieldConstCallWithTypeQuery(): IterableIterator; +declare function asyncFuncReturnConstCall(): Promise; +declare function asyncFuncReturnLetCall(): Promise; +declare function asyncFuncReturnVarCall(): Promise; +declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator; +declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator; +declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator; +declare class C { + static readonly readonlyStaticCall: unique symbol; + static readonly readonlyStaticType: unique symbol; + static readonly readonlyStaticTypeAndCall: unique symbol; + static readwriteStaticCall: symbol; + readonly readonlyCall: symbol; + readwriteCall: symbol; +} +declare const c: C; +declare const constInitToCReadonlyStaticCall: symbol; +declare const constInitToCReadonlyStaticType: symbol; +declare const constInitToCReadonlyStaticTypeAndCall: symbol; +declare const constInitToCReadwriteStaticCall: symbol; +declare const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall; +declare const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType; +declare const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall; +declare const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall; +declare const constInitToCReadonlyCall: symbol; +declare const constInitToCReadwriteCall: symbol; +declare const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall; +declare const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall; +declare const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"]; +declare const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"]; +interface I { + readonly readonlyType: unique symbol; +} +declare const i: I; +declare const constInitToIReadonlyType: symbol; +declare const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType; +declare const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"]; +declare type L = { + readonly readonlyType: unique symbol; + nested: { + readonly readonlyNestedType: unique symbol; + }; +}; +declare const l: L; +declare const constInitToLReadonlyType: symbol; +declare const constInitToLReadonlyNestedType: symbol; +declare const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType; +declare const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType; +declare const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"]; +declare const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"]; +declare const promiseForConstCall: Promise; +declare const arrayOfConstCall: symbol[]; +declare const s: unique symbol; +declare namespace N { + const s: unique symbol; +} +declare const o: { + [s]: "a"; + [N.s]: "b"; +}; +declare function f(x: T): T; +declare function g(x: typeof s): void; +declare function g(x: typeof N.s): void; +declare const o2: { + a: symbol; + b: symbol; + c: symbol; + method1(): symbol; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: symbol): symbol; +}; +declare class C0 { + static readonly a: symbol; + static readonly b: symbol; + static readonly c: symbol; + static d: symbol; + static e: symbol; + static f: symbol; + readonly a: symbol; + readonly b: symbol; + readonly c: symbol; + d: symbol; + e: symbol; + f: symbol; + method1(): symbol; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: symbol): symbol; +} +declare class C1 { + static [s]: "a"; + static [N.s]: "b"; + [s]: "a"; + [N.s]: "b"; +} +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: typeof s): typeof s; +} +declare const o4: Context; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.symbols b/tests/baselines/reference/uniqueSymbolsDeclarations.symbols new file mode 100644 index 0000000000000..ff433aa19d071 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.symbols @@ -0,0 +1,788 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts === +// declarations with call initializer +const constCall = Symbol(); +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +let letCall = Symbol(); +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +var varCall = Symbol(); +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +// ambient declaration with type +declare const constType: unique symbol; +>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13)) + +// declaration with type and call initializer +const constTypeAndCall: unique symbol = Symbol(); +>constTypeAndCall : Symbol(constTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 9, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +// declaration from initializer +const constInitToConstCall = constCall; +>constInitToConstCall : Symbol(constInitToConstCall, Decl(uniqueSymbolsDeclarations.ts, 12, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +const constInitToLetCall = letCall; +>constInitToLetCall : Symbol(constInitToLetCall, Decl(uniqueSymbolsDeclarations.ts, 13, 5)) +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) + +const constInitToVarCall = varCall; +>constInitToVarCall : Symbol(constInitToVarCall, Decl(uniqueSymbolsDeclarations.ts, 14, 5)) +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) + +const constInitToConstDeclAmbient = constType; +>constInitToConstDeclAmbient : Symbol(constInitToConstDeclAmbient, Decl(uniqueSymbolsDeclarations.ts, 15, 5)) +>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13)) + +let letInitToConstCall = constCall; +>letInitToConstCall : Symbol(letInitToConstCall, Decl(uniqueSymbolsDeclarations.ts, 16, 3)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +let letInitToLetCall = letCall; +>letInitToLetCall : Symbol(letInitToLetCall, Decl(uniqueSymbolsDeclarations.ts, 17, 3)) +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) + +let letInitToVarCall = varCall; +>letInitToVarCall : Symbol(letInitToVarCall, Decl(uniqueSymbolsDeclarations.ts, 18, 3)) +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) + +let letInitToConstDeclAmbient = constType; +>letInitToConstDeclAmbient : Symbol(letInitToConstDeclAmbient, Decl(uniqueSymbolsDeclarations.ts, 19, 3)) +>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13)) + +var varInitToConstCall = constCall; +>varInitToConstCall : Symbol(varInitToConstCall, Decl(uniqueSymbolsDeclarations.ts, 20, 3)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +var varInitToLetCall = letCall; +>varInitToLetCall : Symbol(varInitToLetCall, Decl(uniqueSymbolsDeclarations.ts, 21, 3)) +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) + +var varInitToVarCall = varCall; +>varInitToVarCall : Symbol(varInitToVarCall, Decl(uniqueSymbolsDeclarations.ts, 22, 3)) +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) + +var varInitToConstDeclAmbient = constType; +>varInitToConstDeclAmbient : Symbol(varInitToConstDeclAmbient, Decl(uniqueSymbolsDeclarations.ts, 23, 3)) +>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13)) + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +>constInitToConstCallWithTypeQuery : Symbol(constInitToConstCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 26, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +>constInitToConstDeclAmbientWithTypeQuery : Symbol(constInitToConstDeclAmbientWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 27, 5)) +>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13)) +>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13)) + +// function return inference +function funcReturnConstCall() { return constCall; } +>funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbolsDeclarations.ts, 27, 77)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +function funcReturnLetCall() { return letCall; } +>funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbolsDeclarations.ts, 30, 52)) +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) + +function funcReturnVarCall() { return varCall; } +>funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbolsDeclarations.ts, 31, 48)) +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } +>funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 32, 48)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +>genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbolsDeclarations.ts, 35, 83)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +function* genFuncYieldLetCall() { yield letCall; } +>genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbolsDeclarations.ts, 38, 54)) +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) + +function* genFuncYieldVarCall() { yield varCall; } +>genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbolsDeclarations.ts, 39, 50)) +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } +>genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 40, 50)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +>asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbolsDeclarations.ts, 43, 103)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +async function asyncFuncReturnLetCall() { return letCall; } +>asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbolsDeclarations.ts, 46, 63)) +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) + +async function asyncFuncReturnVarCall() { return varCall; } +>asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbolsDeclarations.ts, 47, 59)) +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +>asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbolsDeclarations.ts, 48, 59)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +async function* asyncGenFuncYieldLetCall() { yield letCall; } +>asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbolsDeclarations.ts, 51, 65)) +>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) + +async function* asyncGenFuncYieldVarCall() { yield varCall; } +>asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbolsDeclarations.ts, 52, 61)) +>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) + +// classes +class C { +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) + + static readonly readonlyStaticCall = Symbol(); +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + static readonly readonlyStaticType: unique symbol; +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) + + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + static readwriteStaticCall = Symbol(); +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + readonly readonlyCall = Symbol(); +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + + readwriteCall = Symbol(); +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) +} +declare const c: C; +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 67, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) + +const constInitToCReadonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 68, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) + +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 69, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) + +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 70, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 72, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) + +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 73, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) + +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 74, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) + +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 75, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) + +const constInitToCReadonlyCall = c.readonlyCall; +>constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbolsDeclarations.ts, 77, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) + +const constInitToCReadwriteCall = c.readwriteCall; +>constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbolsDeclarations.ts, 78, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) + +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +>constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 79, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) + +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +>constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 80, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) + +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +>constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 81, 5)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) + +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; +>constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 82, 5)) +>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) + +// interfaces +interface I { +>I : Symbol(I, Decl(uniqueSymbolsDeclarations.ts, 82, 87)) + + readonly readonlyType: unique symbol; +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) +} +declare const i: I; +>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13)) +>I : Symbol(I, Decl(uniqueSymbolsDeclarations.ts, 82, 87)) + +const constInitToIReadonlyType = i.readonlyType; +>constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbolsDeclarations.ts, 90, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) + +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +>constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 91, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) + +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; +>constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 92, 5)) +>I : Symbol(I, Decl(uniqueSymbolsDeclarations.ts, 82, 87)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13)) + +// type literals +type L = { +>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84)) + + readonly readonlyType: unique symbol; +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) + + nested: { +>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) + + readonly readonlyNestedType: unique symbol; +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) + } +}; +declare const l: L; +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84)) + +const constInitToLReadonlyType = l.readonlyType; +>constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbolsDeclarations.ts, 103, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) + +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 104, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) + +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +>constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 105, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) + +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 106, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) + +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +>constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 107, 5)) +>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10)) + +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 108, 5)) +>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13)) + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +>promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbolsDeclarations.ts, 111, 5)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +const arrayOfConstCall = [constCall]; +>arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbolsDeclarations.ts, 112, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) + +// unique symbol widening in expressions +declare const s: unique symbol; +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +declare namespace N { const s: unique symbol; } +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +declare const o: { [s]: "a", [N.s]: "b" }; +>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +declare function f(x: T): T; +>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42)) +>T : Symbol(T, Decl(uniqueSymbolsDeclarations.ts, 118, 19)) +>x : Symbol(x, Decl(uniqueSymbolsDeclarations.ts, 118, 22)) +>T : Symbol(T, Decl(uniqueSymbolsDeclarations.ts, 118, 19)) +>T : Symbol(T, Decl(uniqueSymbolsDeclarations.ts, 118, 19)) + +declare function g(x: typeof s): void; +>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38)) +>x : Symbol(x, Decl(uniqueSymbolsDeclarations.ts, 119, 19)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +declare function g(x: typeof N.s): void; +>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38)) +>x : Symbol(x, Decl(uniqueSymbolsDeclarations.ts, 120, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +// widening positions + +// argument inference +f(s); +>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +f(N.s); +>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +f(N["s"]); +>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +// array literal elements +[s]; +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +[N.s]; +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +[N["s"]]; +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +// property assignments/methods +const o2 = { +>o2 : Symbol(o2, Decl(uniqueSymbolsDeclarations.ts, 135, 5)) + + a: s, +>a : Symbol(a, Decl(uniqueSymbolsDeclarations.ts, 135, 12)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + b: N.s, +>b : Symbol(b, Decl(uniqueSymbolsDeclarations.ts, 136, 9)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + c: N["s"], +>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 137, 11)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + method1() { return s; }, +>method1 : Symbol(method1, Decl(uniqueSymbolsDeclarations.ts, 138, 14)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + async method2() { return s; }, +>method2 : Symbol(method2, Decl(uniqueSymbolsDeclarations.ts, 140, 28)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + async * method3() { yield s; }, +>method3 : Symbol(method3, Decl(uniqueSymbolsDeclarations.ts, 141, 34)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + * method4() { yield s; }, +>method4 : Symbol(method4, Decl(uniqueSymbolsDeclarations.ts, 142, 35)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + method5(p = s) { return p; } +>method5 : Symbol(method5, Decl(uniqueSymbolsDeclarations.ts, 143, 29)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 144, 12)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 144, 12)) + +}; + +// property initializers +class C0 { +>C0 : Symbol(C0, Decl(uniqueSymbolsDeclarations.ts, 145, 2)) + + static readonly a = s; +>a : Symbol(C0.a, Decl(uniqueSymbolsDeclarations.ts, 148, 10)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + static readonly b = N.s; +>b : Symbol(C0.b, Decl(uniqueSymbolsDeclarations.ts, 149, 26)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + static readonly c = N["s"]; +>c : Symbol(C0.c, Decl(uniqueSymbolsDeclarations.ts, 150, 28)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + static d = s; +>d : Symbol(C0.d, Decl(uniqueSymbolsDeclarations.ts, 151, 31)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + static e = N.s; +>e : Symbol(C0.e, Decl(uniqueSymbolsDeclarations.ts, 153, 17)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + static f = N["s"]; +>f : Symbol(C0.f, Decl(uniqueSymbolsDeclarations.ts, 154, 19)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + readonly a = s; +>a : Symbol(C0.a, Decl(uniqueSymbolsDeclarations.ts, 155, 22)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + readonly b = N.s; +>b : Symbol(C0.b, Decl(uniqueSymbolsDeclarations.ts, 157, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + readonly c = N["s"]; +>c : Symbol(C0.c, Decl(uniqueSymbolsDeclarations.ts, 158, 21)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + d = s; +>d : Symbol(C0.d, Decl(uniqueSymbolsDeclarations.ts, 159, 24)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + e = N.s; +>e : Symbol(C0.e, Decl(uniqueSymbolsDeclarations.ts, 161, 10)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + f = N["s"]; +>f : Symbol(C0.f, Decl(uniqueSymbolsDeclarations.ts, 162, 12)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + method1() { return s; } +>method1 : Symbol(C0.method1, Decl(uniqueSymbolsDeclarations.ts, 163, 15)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + async method2() { return s; } +>method2 : Symbol(C0.method2, Decl(uniqueSymbolsDeclarations.ts, 165, 27)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + async * method3() { yield s; } +>method3 : Symbol(C0.method3, Decl(uniqueSymbolsDeclarations.ts, 166, 33)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + * method4() { yield s; } +>method4 : Symbol(C0.method4, Decl(uniqueSymbolsDeclarations.ts, 167, 34)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + method5(p = s) { return p; } +>method5 : Symbol(C0.method5, Decl(uniqueSymbolsDeclarations.ts, 168, 28)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 169, 12)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 169, 12)) +} + +// non-widening positions + +// element access +o[s]; +>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +o[N.s]; +>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +o[N["s"]]; +>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +// arguments (no-inference) +f(s); +>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +f(N.s); +>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +f(N["s"]); +>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +g(s); +>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +g(N.s); +>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +g(N["s"]); +>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +// falsy expressions +s || ""; +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +N.s || ""; +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +N["s"] || ""; +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +// conditionals +Math.random() * 2 ? s : "a"; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + +Math.random() * 2 ? N.s : "a"; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +Math.random() * 2 ? N["s"] : "a"; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +// computed property names +({ + [s]: "a", +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + [N.s]: "b", +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + +}); + +class C1 { +>C1 : Symbol(C1, Decl(uniqueSymbolsDeclarations.ts, 201, 3)) + + static [s]: "a"; +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + static [N.s]: "b"; +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) + + [s]: "a"; +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + [N.s]: "b"; +>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27)) +} + +// contextual types + +interface Context { +>Context : Symbol(Context, Decl(uniqueSymbolsDeclarations.ts, 209, 1)) + + method1(): typeof s; +>method1 : Symbol(Context.method1, Decl(uniqueSymbolsDeclarations.ts, 213, 19)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + method2(): Promise; +>method2 : Symbol(Context.method2, Decl(uniqueSymbolsDeclarations.ts, 214, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + method3(): AsyncIterableIterator; +>method3 : Symbol(Context.method3, Decl(uniqueSymbolsDeclarations.ts, 215, 33)) +>AsyncIterableIterator : Symbol(AsyncIterableIterator, Decl(lib.esnext.asynciterable.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + method4(): IterableIterator; +>method4 : Symbol(Context.method4, Decl(uniqueSymbolsDeclarations.ts, 216, 47)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + method5(p?: typeof s): typeof s; +>method5 : Symbol(Context.method5, Decl(uniqueSymbolsDeclarations.ts, 217, 42)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 218, 12)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) +} + +const o4: Context = { +>o4 : Symbol(o4, Decl(uniqueSymbolsDeclarations.ts, 221, 5)) +>Context : Symbol(Context, Decl(uniqueSymbolsDeclarations.ts, 209, 1)) + + method1() { +>method1 : Symbol(method1, Decl(uniqueSymbolsDeclarations.ts, 221, 21)) + + return s; // return type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + }, + async method2() { +>method2 : Symbol(method2, Decl(uniqueSymbolsDeclarations.ts, 224, 6)) + + return s; // return type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + }, + async * method3() { +>method3 : Symbol(method3, Decl(uniqueSymbolsDeclarations.ts, 227, 6)) + + yield s; // yield type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + }, + * method4() { +>method4 : Symbol(method4, Decl(uniqueSymbolsDeclarations.ts, 230, 6)) + + yield s; // yield type should not widen due to contextual type +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + }, + method5(p = s) { // parameter should not widen due to contextual type +>method5 : Symbol(method5, Decl(uniqueSymbolsDeclarations.ts, 233, 6)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 234, 12)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13)) + + return p; +>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 234, 12)) + } +}; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.types b/tests/baselines/reference/uniqueSymbolsDeclarations.types new file mode 100644 index 0000000000000..c4975d497cc11 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.types @@ -0,0 +1,867 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts === +// declarations with call initializer +const constCall = Symbol(); +>constCall : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +let letCall = Symbol(); +>letCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + +var varCall = Symbol(); +>varCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + +// ambient declaration with type +declare const constType: unique symbol; +>constType : unique symbol + +// declaration with type and call initializer +const constTypeAndCall: unique symbol = Symbol(); +>constTypeAndCall : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +// declaration from initializer +const constInitToConstCall = constCall; +>constInitToConstCall : symbol +>constCall : unique symbol + +const constInitToLetCall = letCall; +>constInitToLetCall : symbol +>letCall : symbol + +const constInitToVarCall = varCall; +>constInitToVarCall : symbol +>varCall : symbol + +const constInitToConstDeclAmbient = constType; +>constInitToConstDeclAmbient : symbol +>constType : unique symbol + +let letInitToConstCall = constCall; +>letInitToConstCall : symbol +>constCall : unique symbol + +let letInitToLetCall = letCall; +>letInitToLetCall : symbol +>letCall : symbol + +let letInitToVarCall = varCall; +>letInitToVarCall : symbol +>varCall : symbol + +let letInitToConstDeclAmbient = constType; +>letInitToConstDeclAmbient : symbol +>constType : unique symbol + +var varInitToConstCall = constCall; +>varInitToConstCall : symbol +>constCall : unique symbol + +var varInitToLetCall = letCall; +>varInitToLetCall : symbol +>letCall : symbol + +var varInitToVarCall = varCall; +>varInitToVarCall : symbol +>varCall : symbol + +var varInitToConstDeclAmbient = constType; +>varInitToConstDeclAmbient : symbol +>constType : unique symbol + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +>constInitToConstCallWithTypeQuery : unique symbol +>constCall : unique symbol +>constCall : unique symbol + +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +>constInitToConstDeclAmbientWithTypeQuery : unique symbol +>constType : unique symbol +>constType : unique symbol + +// function return inference +function funcReturnConstCall() { return constCall; } +>funcReturnConstCall : () => symbol +>constCall : unique symbol + +function funcReturnLetCall() { return letCall; } +>funcReturnLetCall : () => symbol +>letCall : symbol + +function funcReturnVarCall() { return varCall; } +>funcReturnVarCall : () => symbol +>varCall : symbol + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } +>funcReturnConstCallWithTypeQuery : () => unique symbol +>constCall : unique symbol +>constCall : unique symbol + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +>genFuncYieldConstCall : () => IterableIterator +>yield constCall : any +>constCall : unique symbol + +function* genFuncYieldLetCall() { yield letCall; } +>genFuncYieldLetCall : () => IterableIterator +>yield letCall : any +>letCall : symbol + +function* genFuncYieldVarCall() { yield varCall; } +>genFuncYieldVarCall : () => IterableIterator +>yield varCall : any +>varCall : symbol + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } +>genFuncYieldConstCallWithTypeQuery : () => IterableIterator +>IterableIterator : IterableIterator +>constCall : unique symbol +>yield constCall : any +>constCall : unique symbol + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +>asyncFuncReturnConstCall : () => Promise +>constCall : unique symbol + +async function asyncFuncReturnLetCall() { return letCall; } +>asyncFuncReturnLetCall : () => Promise +>letCall : symbol + +async function asyncFuncReturnVarCall() { return varCall; } +>asyncFuncReturnVarCall : () => Promise +>varCall : symbol + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +>asyncGenFuncYieldConstCall : () => AsyncIterableIterator +>yield constCall : any +>constCall : unique symbol + +async function* asyncGenFuncYieldLetCall() { yield letCall; } +>asyncGenFuncYieldLetCall : () => AsyncIterableIterator +>yield letCall : any +>letCall : symbol + +async function* asyncGenFuncYieldVarCall() { yield varCall; } +>asyncGenFuncYieldVarCall : () => AsyncIterableIterator +>yield varCall : any +>varCall : symbol + +// classes +class C { +>C : C + + static readonly readonlyStaticCall = Symbol(); +>readonlyStaticCall : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + + static readonly readonlyStaticType: unique symbol; +>readonlyStaticType : unique symbol + + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); +>readonlyStaticTypeAndCall : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + + static readwriteStaticCall = Symbol(); +>readwriteStaticCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + + readonly readonlyCall = Symbol(); +>readonlyCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor + + readwriteCall = Symbol(); +>readwriteCall : symbol +>Symbol() : symbol +>Symbol : SymbolConstructor +} +declare const c: C; +>c : C +>C : C + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCall : symbol +>C.readonlyStaticCall : unique symbol +>C : typeof C +>readonlyStaticCall : unique symbol + +const constInitToCReadonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticType : symbol +>C.readonlyStaticType : unique symbol +>C : typeof C +>readonlyStaticType : unique symbol + +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCall : symbol +>C.readonlyStaticTypeAndCall : unique symbol +>C : typeof C +>readonlyStaticTypeAndCall : unique symbol + +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCall : symbol +>C.readwriteStaticCall : symbol +>C : typeof C +>readwriteStaticCall : symbol + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCallWithTypeQuery : unique symbol +>C.readonlyStaticCall : unique symbol +>C : typeof C +>readonlyStaticCall : unique symbol +>C.readonlyStaticCall : unique symbol +>C : typeof C +>readonlyStaticCall : unique symbol + +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticTypeWithTypeQuery : unique symbol +>C.readonlyStaticType : unique symbol +>C : typeof C +>readonlyStaticType : unique symbol +>C.readonlyStaticType : unique symbol +>C : typeof C +>readonlyStaticType : unique symbol + +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : unique symbol +>C.readonlyStaticTypeAndCall : unique symbol +>C : typeof C +>readonlyStaticTypeAndCall : unique symbol +>C.readonlyStaticTypeAndCall : unique symbol +>C : typeof C +>readonlyStaticTypeAndCall : unique symbol + +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCallWithTypeQuery : symbol +>C.readwriteStaticCall : symbol +>C : typeof C +>readwriteStaticCall : symbol +>C.readwriteStaticCall : symbol +>C : typeof C +>readwriteStaticCall : symbol + +const constInitToCReadonlyCall = c.readonlyCall; +>constInitToCReadonlyCall : symbol +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol + +const constInitToCReadwriteCall = c.readwriteCall; +>constInitToCReadwriteCall : symbol +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol + +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +>constInitToCReadonlyCallWithTypeQuery : symbol +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol + +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +>constInitToCReadwriteCallWithTypeQuery : symbol +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol + +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +>constInitToCReadonlyCallWithIndexedAccess : symbol +>C : C +>c.readonlyCall : symbol +>c : C +>readonlyCall : symbol + +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; +>constInitToCReadwriteCallWithIndexedAccess : symbol +>C : C +>c.readwriteCall : symbol +>c : C +>readwriteCall : symbol + +// interfaces +interface I { +>I : I + + readonly readonlyType: unique symbol; +>readonlyType : unique symbol +} +declare const i: I; +>i : I +>I : I + +const constInitToIReadonlyType = i.readonlyType; +>constInitToIReadonlyType : symbol +>i.readonlyType : unique symbol +>i : I +>readonlyType : unique symbol + +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +>constInitToIReadonlyTypeWithTypeQuery : unique symbol +>i.readonlyType : unique symbol +>i : I +>readonlyType : unique symbol +>i.readonlyType : unique symbol +>i : I +>readonlyType : unique symbol + +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; +>constInitToIReadonlyTypeWithIndexedAccess : unique symbol +>I : I +>i.readonlyType : unique symbol +>i : I +>readonlyType : unique symbol + +// type literals +type L = { +>L : L + + readonly readonlyType: unique symbol; +>readonlyType : unique symbol + + nested: { +>nested : { readonly readonlyNestedType: unique symbol; } + + readonly readonlyNestedType: unique symbol; +>readonlyNestedType : unique symbol + } +}; +declare const l: L; +>l : L +>L : L + +const constInitToLReadonlyType = l.readonlyType; +>constInitToLReadonlyType : symbol +>l.readonlyType : unique symbol +>l : L +>readonlyType : unique symbol + +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedType : symbol +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } +>l : L +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol + +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +>constInitToLReadonlyTypeWithTypeQuery : unique symbol +>l.readonlyType : unique symbol +>l : L +>readonlyType : unique symbol +>l.readonlyType : unique symbol +>l : L +>readonlyType : unique symbol + +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithTypeQuery : unique symbol +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } +>l : L +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } +>l : L +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol + +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +>constInitToLReadonlyTypeWithIndexedAccess : unique symbol +>L : L +>l.readonlyType : unique symbol +>l : L +>readonlyType : unique symbol + +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithIndexedAccess : unique symbol +>L : L +>l.nested.readonlyNestedType : unique symbol +>l.nested : { readonly readonlyNestedType: unique symbol; } +>l : L +>nested : { readonly readonlyNestedType: unique symbol; } +>readonlyNestedType : unique symbol + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +>promiseForConstCall : Promise +>Promise.resolve(constCall) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>constCall : unique symbol + +const arrayOfConstCall = [constCall]; +>arrayOfConstCall : symbol[] +>[constCall] : symbol[] +>constCall : unique symbol + +// unique symbol widening in expressions +declare const s: unique symbol; +>s : unique symbol + +declare namespace N { const s: unique symbol; } +>N : typeof N +>s : unique symbol + +declare const o: { [s]: "a", [N.s]: "b" }; +>o : { [s]: "a"; [N.s]: "b"; } +>s : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +declare function f(x: T): T; +>f : (x: T) => T +>T : T +>x : T +>T : T +>T : T + +declare function g(x: typeof s): void; +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>x : unique symbol +>s : unique symbol + +declare function g(x: typeof N.s): void; +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>x : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +// widening positions + +// argument inference +f(s); +>f(s) : symbol +>f : (x: T) => T +>s : unique symbol + +f(N.s); +>f(N.s) : symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : symbol +>f : (x: T) => T +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// array literal elements +[s]; +>[s] : symbol[] +>s : unique symbol + +[N.s]; +>[N.s] : symbol[] +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +[N["s"]]; +>[N["s"]] : symbol[] +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// property assignments/methods +const o2 = { +>o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } +>{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; }} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } + + a: s, +>a : symbol +>s : unique symbol + + b: N.s, +>b : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + c: N["s"], +>c : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + method1() { return s; }, +>method1 : () => symbol +>s : unique symbol + + async method2() { return s; }, +>method2 : () => Promise +>s : unique symbol + + async * method3() { yield s; }, +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; }, +>method4 : () => IterableIterator +>yield s : any +>s : unique symbol + + method5(p = s) { return p; } +>method5 : (p?: symbol) => symbol +>p : symbol +>s : unique symbol +>p : symbol + +}; + +// property initializers +class C0 { +>C0 : C0 + + static readonly a = s; +>a : symbol +>s : unique symbol + + static readonly b = N.s; +>b : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + static readonly c = N["s"]; +>c : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + static d = s; +>d : symbol +>s : unique symbol + + static e = N.s; +>e : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + static f = N["s"]; +>f : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + readonly a = s; +>a : symbol +>s : unique symbol + + readonly b = N.s; +>b : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + readonly c = N["s"]; +>c : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + d = s; +>d : symbol +>s : unique symbol + + e = N.s; +>e : symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + f = N["s"]; +>f : symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + + method1() { return s; } +>method1 : () => symbol +>s : unique symbol + + async method2() { return s; } +>method2 : () => Promise +>s : unique symbol + + async * method3() { yield s; } +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; } +>method4 : () => IterableIterator +>yield s : any +>s : unique symbol + + method5(p = s) { return p; } +>method5 : (p?: symbol) => symbol +>p : symbol +>s : unique symbol +>p : symbol +} + +// non-widening positions + +// element access +o[s]; +>o[s] : "a" +>o : { [s]: "a"; [N.s]: "b"; } +>s : unique symbol + +o[N.s]; +>o[N.s] : "b" +>o : { [s]: "a"; [N.s]: "b"; } +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +o[N["s"]]; +>o[N["s"]] : "b" +>o : { [s]: "a"; [N.s]: "b"; } +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// arguments (no-inference) +f(s); +>f(s) : unique symbol +>f : (x: T) => T +>s : unique symbol +>s : unique symbol + +f(N.s); +>f(N.s) : unique symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : unique symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +g(s); +>g(s) : void +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>s : unique symbol + +g(N.s); +>g(N.s) : void +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +g(N["s"]); +>g(N["s"]) : void +>g : { (x: unique symbol): void; (x: unique symbol): void; } +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" + +// falsy expressions +s || ""; +>s || "" : unique symbol | "" +>s : unique symbol +>"" : "" + +N.s || ""; +>N.s || "" : unique symbol | "" +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>"" : "" + +N["s"] || ""; +>N["s"] || "" : unique symbol | "" +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" +>"" : "" + +// conditionals +Math.random() * 2 ? s : "a"; +>Math.random() * 2 ? s : "a" : unique symbol | "a" +>Math.random() * 2 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>2 : 2 +>s : unique symbol +>"a" : "a" + +Math.random() * 2 ? N.s : "a"; +>Math.random() * 2 ? N.s : "a" : unique symbol | "a" +>Math.random() * 2 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>2 : 2 +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>"a" : "a" + +Math.random() * 2 ? N["s"] : "a"; +>Math.random() * 2 ? N["s"] : "a" : unique symbol | "a" +>Math.random() * 2 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>2 : 2 +>N["s"] : unique symbol +>N : typeof N +>"s" : "s" +>"a" : "a" + +// computed property names +({ +>({ [s]: "a", [N.s]: "b",}) : { [s]: string; [N.s]: string; } +>{ [s]: "a", [N.s]: "b",} : { [s]: string; [N.s]: string; } + + [s]: "a", +>s : unique symbol +>"a" : "a" + + [N.s]: "b", +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>"b" : "b" + +}); + +class C1 { +>C1 : C1 + + static [s]: "a"; +>s : unique symbol + + static [N.s]: "b"; +>N.s : unique symbol +>N : typeof N +>s : unique symbol + + [s]: "a"; +>s : unique symbol + + [N.s]: "b"; +>N.s : unique symbol +>N : typeof N +>s : unique symbol +} + +// contextual types + +interface Context { +>Context : Context + + method1(): typeof s; +>method1 : () => unique symbol +>s : unique symbol + + method2(): Promise; +>method2 : () => Promise +>Promise : Promise +>s : unique symbol + + method3(): AsyncIterableIterator; +>method3 : () => AsyncIterableIterator +>AsyncIterableIterator : AsyncIterableIterator +>s : unique symbol + + method4(): IterableIterator; +>method4 : () => IterableIterator +>IterableIterator : IterableIterator +>s : unique symbol + + method5(p?: typeof s): typeof s; +>method5 : (p?: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol +>s : unique symbol +} + +const o4: Context = { +>o4 : Context +>Context : Context +>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: unique symbol): unique symbol; } + + method1() { +>method1 : () => unique symbol + + return s; // return type should not widen due to contextual type +>s : unique symbol + + }, + async method2() { +>method2 : () => Promise + + return s; // return type should not widen due to contextual type +>s : unique symbol + + }, + async * method3() { +>method3 : () => AsyncIterableIterator + + yield s; // yield type should not widen due to contextual type +>yield s : any +>s : unique symbol + + }, + * method4() { +>method4 : () => IterableIterator + + yield s; // yield type should not widen due to contextual type +>yield s : any +>s : unique symbol + + }, + method5(p = s) { // parameter should not widen due to contextual type +>method5 : (p?: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol + + return p; +>p : unique symbol + } +}; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.errors.txt b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.errors.txt new file mode 100644 index 0000000000000..f7769db1077a6 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.errors.txt @@ -0,0 +1,110 @@ +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(6,14): error TS2527: The inferred type of 'obj' references an inaccessible 'unique symbol' type. A type annotation is necessary. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(15,14): error TS2527: The inferred type of 'classExpression' references an inaccessible 'unique symbol' type. A type annotation is necessary. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(24,17): error TS2527: The inferred type of 'funcInferredReturnType' references an inaccessible 'unique symbol' type. A type annotation is necessary. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(24,64): error TS4078: Parameter 'obj' of exported function has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(29,6): error TS4033: Property '[s]' of exported interface has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(33,6): error TS4102: Method '[s]' of exported interface has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(37,6): error TS4033: Property '[s]' of exported interface has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(41,6): error TS4102: Method '[s]' of exported interface has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(45,6): error TS4031: Public property '[s]' of exported class has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(46,13): error TS4028: Public static property '[s]' of exported class has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(50,6): error TS4100: Public method '[s]' of exported class has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(51,13): error TS4097: Public static method '[s]' of exported class has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(55,10): error TS4031: Public property '[s]' of exported class has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(56,10): error TS4031: Public property '[s]' of exported class has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(57,17): error TS4028: Public static property '[s]' of exported class has or is using private name 's'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(58,17): error TS4028: Public static property '[s]' of exported class has or is using private name 's'. + + +==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts (16 errors) ==== + declare const s: unique symbol; + interface I { readonly readonlyType: unique symbol; } + + // not allowed when emitting declarations + + export const obj = { + ~~~ +!!! error TS2527: The inferred type of 'obj' references an inaccessible 'unique symbol' type. A type annotation is necessary. + method1(p: typeof s): typeof s { + return p; + }, + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } + }; + + export const classExpression = class { + ~~~~~~~~~~~~~~~ +!!! error TS2527: The inferred type of 'classExpression' references an inaccessible 'unique symbol' type. A type annotation is necessary. + method1(p: typeof s): typeof s { + return p; + } + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } + }; + + export function funcInferredReturnType(obj: { method(p: typeof s): void }) { + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2527: The inferred type of 'funcInferredReturnType' references an inaccessible 'unique symbol' type. A type annotation is necessary. + ~ +!!! error TS4078: Parameter 'obj' of exported function has or is using private name 's'. + return obj; + } + + export interface InterfaceWithPrivateNamedProperties { + [s]: any; + ~ +!!! error TS4033: Property '[s]' of exported interface has or is using private name 's'. + } + + export interface InterfaceWithPrivateNamedMethods { + [s](): any; + ~ +!!! error TS4102: Method '[s]' of exported interface has or is using private name 's'. + } + + export type TypeLiteralWithPrivateNamedProperties = { + [s]: any; + ~ +!!! error TS4033: Property '[s]' of exported interface has or is using private name 's'. + } + + export type TypeLiteralWithPrivateNamedMethods = { + [s](): any; + ~ +!!! error TS4102: Method '[s]' of exported interface has or is using private name 's'. + } + + export class ClassWithPrivateNamedProperties { + [s]: any; + ~ +!!! error TS4031: Public property '[s]' of exported class has or is using private name 's'. + static [s]: any; + ~ +!!! error TS4028: Public static property '[s]' of exported class has or is using private name 's'. + } + + export class ClassWithPrivateNamedMethods { + [s]() {} + ~ +!!! error TS4100: Public method '[s]' of exported class has or is using private name 's'. + static [s]() {} + ~ +!!! error TS4097: Public static method '[s]' of exported class has or is using private name 's'. + } + + export class ClassWithPrivateNamedAccessors { + get [s](): any { return undefined; } + ~ +!!! error TS4031: Public property '[s]' of exported class has or is using private name 's'. + set [s](v: any) { } + ~ +!!! error TS4031: Public property '[s]' of exported class has or is using private name 's'. + static get [s](): any { return undefined; } + ~ +!!! error TS4028: Public static property '[s]' of exported class has or is using private name 's'. + static set [s](v: any) { } + ~ +!!! error TS4028: Public static property '[s]' of exported class has or is using private name 's'. + } \ No newline at end of file diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js new file mode 100644 index 0000000000000..a446a6712a4d0 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js @@ -0,0 +1,100 @@ +//// [uniqueSymbolsDeclarationsErrors.ts] +declare const s: unique symbol; +interface I { readonly readonlyType: unique symbol; } + +// not allowed when emitting declarations + +export const obj = { + method1(p: typeof s): typeof s { + return p; + }, + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +export const classExpression = class { + method1(p: typeof s): typeof s { + return p; + } + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +export function funcInferredReturnType(obj: { method(p: typeof s): void }) { + return obj; +} + +export interface InterfaceWithPrivateNamedProperties { + [s]: any; +} + +export interface InterfaceWithPrivateNamedMethods { + [s](): any; +} + +export type TypeLiteralWithPrivateNamedProperties = { + [s]: any; +} + +export type TypeLiteralWithPrivateNamedMethods = { + [s](): any; +} + +export class ClassWithPrivateNamedProperties { + [s]: any; + static [s]: any; +} + +export class ClassWithPrivateNamedMethods { + [s]() {} + static [s]() {} +} + +export class ClassWithPrivateNamedAccessors { + get [s](): any { return undefined; } + set [s](v: any) { } + static get [s](): any { return undefined; } + static set [s](v: any) { } +} + +//// [uniqueSymbolsDeclarationsErrors.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// not allowed when emitting declarations +exports.obj = { + method1(p) { + return p; + }, + method2(p) { + return p; + } +}; +exports.classExpression = class { + method1(p) { + return p; + } + method2(p) { + return p; + } +}; +function funcInferredReturnType(obj) { + return obj; +} +exports.funcInferredReturnType = funcInferredReturnType; +class ClassWithPrivateNamedProperties { +} +exports.ClassWithPrivateNamedProperties = ClassWithPrivateNamedProperties; +class ClassWithPrivateNamedMethods { + [s]() { } + static [s]() { } +} +exports.ClassWithPrivateNamedMethods = ClassWithPrivateNamedMethods; +class ClassWithPrivateNamedAccessors { + get [s]() { return undefined; } + set [s](v) { } + static get [s]() { return undefined; } + static set [s](v) { } +} +exports.ClassWithPrivateNamedAccessors = ClassWithPrivateNamedAccessors; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.symbols b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.symbols new file mode 100644 index 0000000000000..45275c60a1712 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.symbols @@ -0,0 +1,135 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts === +declare const s: unique symbol; +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) + +interface I { readonly readonlyType: unique symbol; } +>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarationsErrors.ts, 1, 13)) + +// not allowed when emitting declarations + +export const obj = { +>obj : Symbol(obj, Decl(uniqueSymbolsDeclarationsErrors.ts, 5, 12)) + + method1(p: typeof s): typeof s { +>method1 : Symbol(method1, Decl(uniqueSymbolsDeclarationsErrors.ts, 5, 20)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 6, 12)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) + + return p; +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 6, 12)) + + }, + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : Symbol(method2, Decl(uniqueSymbolsDeclarationsErrors.ts, 8, 6)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 9, 12)) +>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31)) +>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31)) + + return p; +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 9, 12)) + } +}; + +export const classExpression = class { +>classExpression : Symbol(classExpression, Decl(uniqueSymbolsDeclarationsErrors.ts, 14, 12)) + + method1(p: typeof s): typeof s { +>method1 : Symbol(classExpression.method1, Decl(uniqueSymbolsDeclarationsErrors.ts, 14, 38)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 15, 12)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) + + return p; +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 15, 12)) + } + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : Symbol(classExpression.method2, Decl(uniqueSymbolsDeclarationsErrors.ts, 17, 5)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 18, 12)) +>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31)) +>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31)) + + return p; +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 18, 12)) + } +}; + +export function funcInferredReturnType(obj: { method(p: typeof s): void }) { +>funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbolsDeclarationsErrors.ts, 21, 2)) +>obj : Symbol(obj, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 39)) +>method : Symbol(method, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 45)) +>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 53)) +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) + + return obj; +>obj : Symbol(obj, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 39)) +} + +export interface InterfaceWithPrivateNamedProperties { +>InterfaceWithPrivateNamedProperties : Symbol(InterfaceWithPrivateNamedProperties, Decl(uniqueSymbolsDeclarationsErrors.ts, 25, 1)) + + [s]: any; +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +} + +export interface InterfaceWithPrivateNamedMethods { +>InterfaceWithPrivateNamedMethods : Symbol(InterfaceWithPrivateNamedMethods, Decl(uniqueSymbolsDeclarationsErrors.ts, 29, 1)) + + [s](): any; +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +} + +export type TypeLiteralWithPrivateNamedProperties = { +>TypeLiteralWithPrivateNamedProperties : Symbol(TypeLiteralWithPrivateNamedProperties, Decl(uniqueSymbolsDeclarationsErrors.ts, 33, 1)) + + [s]: any; +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +} + +export type TypeLiteralWithPrivateNamedMethods = { +>TypeLiteralWithPrivateNamedMethods : Symbol(TypeLiteralWithPrivateNamedMethods, Decl(uniqueSymbolsDeclarationsErrors.ts, 37, 1)) + + [s](): any; +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +} + +export class ClassWithPrivateNamedProperties { +>ClassWithPrivateNamedProperties : Symbol(ClassWithPrivateNamedProperties, Decl(uniqueSymbolsDeclarationsErrors.ts, 41, 1)) + + [s]: any; +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) + + static [s]: any; +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +} + +export class ClassWithPrivateNamedMethods { +>ClassWithPrivateNamedMethods : Symbol(ClassWithPrivateNamedMethods, Decl(uniqueSymbolsDeclarationsErrors.ts, 46, 1)) + + [s]() {} +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) + + static [s]() {} +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +} + +export class ClassWithPrivateNamedAccessors { +>ClassWithPrivateNamedAccessors : Symbol(ClassWithPrivateNamedAccessors, Decl(uniqueSymbolsDeclarationsErrors.ts, 51, 1)) + + get [s](): any { return undefined; } +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +>undefined : Symbol(undefined) + + set [s](v: any) { } +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +>v : Symbol(v, Decl(uniqueSymbolsDeclarationsErrors.ts, 55, 12)) + + static get [s](): any { return undefined; } +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +>undefined : Symbol(undefined) + + static set [s](v: any) { } +>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13)) +>v : Symbol(v, Decl(uniqueSymbolsDeclarationsErrors.ts, 57, 19)) +} diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.types b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.types new file mode 100644 index 0000000000000..ff3101193b4f3 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.types @@ -0,0 +1,137 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts === +declare const s: unique symbol; +>s : unique symbol + +interface I { readonly readonlyType: unique symbol; } +>I : I +>readonlyType : unique symbol + +// not allowed when emitting declarations + +export const obj = { +>obj : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; } +>{ method1(p: typeof s): typeof s { return p; }, method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; } + + method1(p: typeof s): typeof s { +>method1 : (p: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol +>s : unique symbol + + return p; +>p : unique symbol + + }, + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : (p: unique symbol) => unique symbol +>p : unique symbol +>I : I +>I : I + + return p; +>p : unique symbol + } +}; + +export const classExpression = class { +>classExpression : typeof classExpression +>class { method1(p: typeof s): typeof s { return p; } method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : typeof classExpression + + method1(p: typeof s): typeof s { +>method1 : (p: unique symbol) => unique symbol +>p : unique symbol +>s : unique symbol +>s : unique symbol + + return p; +>p : unique symbol + } + method2(p: I["readonlyType"]): I["readonlyType"] { +>method2 : (p: unique symbol) => unique symbol +>p : unique symbol +>I : I +>I : I + + return p; +>p : unique symbol + } +}; + +export function funcInferredReturnType(obj: { method(p: typeof s): void }) { +>funcInferredReturnType : (obj: { method(p: unique symbol): void; }) => { method(p: unique symbol): void; } +>obj : { method(p: unique symbol): void; } +>method : (p: unique symbol) => void +>p : unique symbol +>s : unique symbol + + return obj; +>obj : { method(p: unique symbol): void; } +} + +export interface InterfaceWithPrivateNamedProperties { +>InterfaceWithPrivateNamedProperties : InterfaceWithPrivateNamedProperties + + [s]: any; +>s : unique symbol +} + +export interface InterfaceWithPrivateNamedMethods { +>InterfaceWithPrivateNamedMethods : InterfaceWithPrivateNamedMethods + + [s](): any; +>s : unique symbol +} + +export type TypeLiteralWithPrivateNamedProperties = { +>TypeLiteralWithPrivateNamedProperties : TypeLiteralWithPrivateNamedProperties + + [s]: any; +>s : unique symbol +} + +export type TypeLiteralWithPrivateNamedMethods = { +>TypeLiteralWithPrivateNamedMethods : TypeLiteralWithPrivateNamedMethods + + [s](): any; +>s : unique symbol +} + +export class ClassWithPrivateNamedProperties { +>ClassWithPrivateNamedProperties : ClassWithPrivateNamedProperties + + [s]: any; +>s : unique symbol + + static [s]: any; +>s : unique symbol +} + +export class ClassWithPrivateNamedMethods { +>ClassWithPrivateNamedMethods : ClassWithPrivateNamedMethods + + [s]() {} +>s : unique symbol + + static [s]() {} +>s : unique symbol +} + +export class ClassWithPrivateNamedAccessors { +>ClassWithPrivateNamedAccessors : ClassWithPrivateNamedAccessors + + get [s](): any { return undefined; } +>s : unique symbol +>undefined : undefined + + set [s](v: any) { } +>s : unique symbol +>v : any + + static get [s](): any { return undefined; } +>s : unique symbol +>undefined : undefined + + static set [s](v: any) { } +>s : unique symbol +>v : any +} diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts index a804ed8d20a44..498a1c2904d2c 100644 --- a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts @@ -1,6 +1,6 @@ // @target: esnext // @lib: esnext -// @declaration: true +// @declaration: false // declarations with call initializer const constCall = Symbol(); @@ -125,6 +125,7 @@ declare function g(x: typeof s): void; declare function g(x: typeof N.s): void; // widening positions + // argument inference f(s); f(N.s); @@ -135,11 +136,17 @@ f(N["s"]); [N.s]; [N["s"]]; -// property assignments +// property assignments/methods const o2 = { a: s, b: N.s, - c: N["s"] + c: N["s"], + + method1() { return s; }, + async method2() { return s; }, + async * method3() { yield s; }, + * method4() { yield s; }, + method5(p = s) { return p; }, }; // property initializers @@ -159,6 +166,12 @@ class C0 { d = s; e = N.s; f = N["s"]; + + method1() { return s; } + async method2() { return s; } + async * method3() { yield s; } + * method4() { yield s; } + method5(p = s) { return p; } } // non-widening positions @@ -198,4 +211,56 @@ class C1 { [s]: "a"; [N.s]: "b"; -} \ No newline at end of file +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: typeof s): typeof s; +} + +const o3: Context = { + method1() { + return s; // return type should not widen due to contextual type + }, + async method2() { + return s; // return type should not widen due to contextual type + }, + async * method3() { + yield s; // yield type should not widen due to contextual type + }, + * method4() { + yield s; // yield type should not widen due to contextual type + }, + method5(p = s) { // parameter should not widen due to contextual type + return p; + }, +}; + +// allowed when not emitting declarations + +const o4 = { + method1(p: typeof s): typeof s { + return p; + }, + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +const ce0 = class { + method1(p: typeof s): typeof s { + return p; + } + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +function funcInferredReturnType(obj: { method(p: typeof s): void }) { + return obj; +} diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts new file mode 100644 index 0000000000000..b097e290e8fbf --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts @@ -0,0 +1,242 @@ +// @target: esnext +// @lib: esnext +// @declaration: true + +// declarations with call initializer +const constCall = Symbol(); +let letCall = Symbol(); +var varCall = Symbol(); + +// ambient declaration with type +declare const constType: unique symbol; + +// declaration with type and call initializer +const constTypeAndCall: unique symbol = Symbol(); + +// declaration from initializer +const constInitToConstCall = constCall; +const constInitToLetCall = letCall; +const constInitToVarCall = varCall; +const constInitToConstDeclAmbient = constType; +let letInitToConstCall = constCall; +let letInitToLetCall = letCall; +let letInitToVarCall = varCall; +let letInitToConstDeclAmbient = constType; +var varInitToConstCall = constCall; +var varInitToLetCall = letCall; +var varInitToVarCall = varCall; +var varInitToConstDeclAmbient = constType; + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; + +// function return inference +function funcReturnConstCall() { return constCall; } +function funcReturnLetCall() { return letCall; } +function funcReturnVarCall() { return varCall; } + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +function* genFuncYieldLetCall() { yield letCall; } +function* genFuncYieldVarCall() { yield varCall; } + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +async function asyncFuncReturnLetCall() { return letCall; } +async function asyncFuncReturnVarCall() { return varCall; } + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +async function* asyncGenFuncYieldLetCall() { yield letCall; } +async function* asyncGenFuncYieldVarCall() { yield varCall; } + +// classes +class C { + static readonly readonlyStaticCall = Symbol(); + static readonly readonlyStaticType: unique symbol; + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); + static readwriteStaticCall = Symbol(); + + readonly readonlyCall = Symbol(); + readwriteCall = Symbol(); +} +declare const c: C; + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; + +const constInitToCReadonlyCall = c.readonlyCall; +const constInitToCReadwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; + +// interfaces +interface I { + readonly readonlyType: unique symbol; +} +declare const i: I; + +const constInitToIReadonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; + +// type literals +type L = { + readonly readonlyType: unique symbol; + nested: { + readonly readonlyNestedType: unique symbol; + } +}; +declare const l: L; + +const constInitToLReadonlyType = l.readonlyType; +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +const arrayOfConstCall = [constCall]; + +// unique symbol widening in expressions +declare const s: unique symbol; +declare namespace N { const s: unique symbol; } +declare const o: { [s]: "a", [N.s]: "b" }; +declare function f(x: T): T; +declare function g(x: typeof s): void; +declare function g(x: typeof N.s): void; + +// widening positions + +// argument inference +f(s); +f(N.s); +f(N["s"]); + +// array literal elements +[s]; +[N.s]; +[N["s"]]; + +// property assignments/methods +const o2 = { + a: s, + b: N.s, + c: N["s"], + + method1() { return s; }, + async method2() { return s; }, + async * method3() { yield s; }, + * method4() { yield s; }, + method5(p = s) { return p; } +}; + +// property initializers +class C0 { + static readonly a = s; + static readonly b = N.s; + static readonly c = N["s"]; + + static d = s; + static e = N.s; + static f = N["s"]; + + readonly a = s; + readonly b = N.s; + readonly c = N["s"]; + + d = s; + e = N.s; + f = N["s"]; + + method1() { return s; } + async method2() { return s; } + async * method3() { yield s; } + * method4() { yield s; } + method5(p = s) { return p; } +} + +// non-widening positions + +// element access +o[s]; +o[N.s]; +o[N["s"]]; + +// arguments (no-inference) +f(s); +f(N.s); +f(N["s"]); +g(s); +g(N.s); +g(N["s"]); + +// falsy expressions +s || ""; +N.s || ""; +N["s"] || ""; + +// conditionals +Math.random() * 2 ? s : "a"; +Math.random() * 2 ? N.s : "a"; +Math.random() * 2 ? N["s"] : "a"; + +// computed property names +({ + [s]: "a", + [N.s]: "b", +}); + +class C1 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: typeof s): typeof s; +} + +const o4: Context = { + method1() { + return s; // return type should not widen due to contextual type + }, + async method2() { + return s; // return type should not widen due to contextual type + }, + async * method3() { + yield s; // yield type should not widen due to contextual type + }, + * method4() { + yield s; // yield type should not widen due to contextual type + }, + method5(p = s) { // parameter should not widen due to contextual type + return p; + } +}; \ No newline at end of file diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts new file mode 100644 index 0000000000000..227dbd9c90d0e --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts @@ -0,0 +1,64 @@ +// @target: esnext +// @lib: esnext +// @module: commonjs +// @declaration: true + +declare const s: unique symbol; +interface I { readonly readonlyType: unique symbol; } + +// not allowed when emitting declarations + +export const obj = { + method1(p: typeof s): typeof s { + return p; + }, + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +export const classExpression = class { + method1(p: typeof s): typeof s { + return p; + } + method2(p: I["readonlyType"]): I["readonlyType"] { + return p; + } +}; + +export function funcInferredReturnType(obj: { method(p: typeof s): void }) { + return obj; +} + +export interface InterfaceWithPrivateNamedProperties { + [s]: any; +} + +export interface InterfaceWithPrivateNamedMethods { + [s](): any; +} + +export type TypeLiteralWithPrivateNamedProperties = { + [s]: any; +} + +export type TypeLiteralWithPrivateNamedMethods = { + [s](): any; +} + +export class ClassWithPrivateNamedProperties { + [s]: any; + static [s]: any; +} + +export class ClassWithPrivateNamedMethods { + [s]() {} + static [s]() {} +} + +export class ClassWithPrivateNamedAccessors { + get [s](): any { return undefined; } + set [s](v: any) { } + static get [s](): any { return undefined; } + static set [s](v: any) { } +} \ No newline at end of file From 86b0759b0963dd105df7b7717c28d044ef7f3fbc Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 15 Nov 2017 16:47:01 -0800 Subject: [PATCH 41/43] PR feedback --- src/compiler/checker.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5393e0a6cdb9b..8801502e09139 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10649,11 +10649,8 @@ namespace ts { } function getWidenedLiteralLikeTypeForContextualType(type: Type, contextualType: Type) { - if (!isLiteralContextualType(contextualType)) { - type = getWidenedLiteralType(type); - } - if (!isUniqueESSymbolContextualType(contextualType)) { - type = getWidenedUniqueESSymbolType(type); + if (!isLiteralLikeContextualType(contextualType)) { + type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type)); } return type; } @@ -18838,27 +18835,23 @@ namespace ts { isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); } - function isLiteralContextualType(contextualType: Type) { + function isLiteralLikeContextualType(contextualType: Type) { if (contextualType) { if (contextualType.flags & TypeFlags.TypeVariable) { const constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { + if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum | TypeFlags.UniqueESSymbol)) { return true; } contextualType = constraint; } - return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index)); + return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index | TypeFlags.UniqueESSymbol)); } return false; } - function isUniqueESSymbolContextualType(contextualType: Type) { - return contextualType ? maybeTypeOfKind(contextualType, TypeFlags.UniqueESSymbol) : false; - } - function checkExpressionForMutableLocation(node: Expression, checkMode: CheckMode, contextualType?: Type): Type { if (arguments.length === 2) { contextualType = getContextualType(node); From 0b24f02aae96a77cd9dbf40360dcd78b136a3005 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 15 Nov 2017 17:12:05 -0800 Subject: [PATCH 42/43] Use correct base primitive type --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8801502e09139..227ff6f7d0503 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18842,7 +18842,7 @@ namespace ts { // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum | TypeFlags.UniqueESSymbol)) { + if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum | TypeFlags.Symbol)) { return true; } contextualType = constraint; From ccba1280dc51d6044f8c6190ae36309902de1988 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 15 Nov 2017 17:31:52 -0800 Subject: [PATCH 43/43] Use correct base primitive type --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 227ff6f7d0503..a33c958ad6768 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18842,7 +18842,7 @@ namespace ts { // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum | TypeFlags.Symbol)) { + if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum | TypeFlags.ESSymbol)) { return true; } contextualType = constraint;