From caf1aee269d1660b4d2a8b555c2d602c97cb28d7 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 24 Jan 2025 11:44:54 -0800 Subject: [PATCH] Computed names in declarations files are resolved even when non-literal, preserve computed names when expressions are entity names (#60052) --- src/compiler/checker.ts | 112 ++++++++-- src/compiler/types.ts | 5 +- .../reference/ES5SymbolProperty1.types | 12 +- tests/baselines/reference/api/typescript.d.ts | 4 + .../capturedParametersInInitializers1.types | 12 +- ...pturedParametersInInitializers2.errors.txt | 5 +- .../checkJsObjectLiteralIndexSignatures.types | 24 +-- ...ssNonUniqueSymbolMethodHasSymbolIndexer.js | 6 +- ...commaOperatorInConditionalExpression.types | 20 +- .../reference/complicatedPrivacy.errors.txt | 5 +- .../computedPropertiesInDestructuring1.types | 12 +- ...mputedPropertiesInDestructuring1_ES6.types | 12 +- .../computedPropertiesNarrowed.errors.txt | 6 +- .../computedPropertiesNarrowed.types | 8 +- .../computedPropertyNames12_ES5.errors.txt | 11 +- .../computedPropertyNames12_ES6.errors.txt | 11 +- .../computedPropertyNames48_ES5.types | 4 +- .../computedPropertyNames48_ES6.types | 4 +- .../computedPropertyNames6_ES5.types | 8 +- .../computedPropertyNames6_ES6.types | 8 +- ...tedPropertyNamesOnOverloads_ES5.errors.txt | 16 -- ...tedPropertyNamesOnOverloads_ES6.errors.txt | 16 -- ...clarationEmitAnyComputedPropertyInClass.js | 3 +- ...EmitClassMemberWithComputedPropertyName.js | 4 +- ...rationEmitComputedNameWithQuestionToken.js | 37 ++++ ...nEmitComputedNameWithQuestionToken.symbols | 26 +++ ...ionEmitComputedNameWithQuestionToken.types | 51 +++++ ...eclarationEmitComputedNamesInaccessible.js | 64 ++++++ ...ationEmitComputedNamesInaccessible.symbols | 53 +++++ ...arationEmitComputedNamesInaccessible.types | 123 +++++++++++ ...onEmitComputedPropertyNameEnum2.errors.txt | 5 +- ...onEmitComputedPropertyNameEnum3.errors.txt | 5 +- ...tionEmitMultipleComputedNamesSameDomain.js | 35 ++++ ...mitMultipleComputedNamesSameDomain.symbols | 20 ++ ...nEmitMultipleComputedNamesSameDomain.types | 31 +++ .../declarationEmitSimpleComputedNames1.js | 102 ++++++++++ ...eclarationEmitSimpleComputedNames1.symbols | 78 +++++++ .../declarationEmitSimpleComputedNames1.types | 192 ++++++++++++++++++ .../decoratorsOnComputedProperties.errors.txt | 62 +----- ...ingPatternAndAssignment8(target=es5).types | 16 +- ...PatternAndAssignment8(target=esnext).types | 16 +- ...iteralProperty_computedNameNegative1.types | 8 +- .../es5-asyncFunctionObjectLiterals.types | 24 +-- ...pers-staticComputedAutoAccessor.errors.txt | 5 +- ...EmitHelpers-staticComputedField.errors.txt | 5 +- ...ngEmitHelpers-classDecorator.16.errors.txt | 5 +- ...SignatureMustHaveTypeAnnotation.errors.txt | 8 +- .../reference/indexSignatures1.types | 4 +- .../indexWithoutParamType2.errors.txt | 5 +- ...solatedDeclarationErrorsClasses.errors.txt | 14 +- .../overloadsWithComputedNames.errors.txt | 14 +- ...eDynamicName1(noimplicitoverride=false).js | 10 +- ...deDynamicName1(noimplicitoverride=true).js | 10 +- ...dexSignature1(noimplicitoverride=false).js | 10 +- ...ndexSignature1(noimplicitoverride=true).js | 10 +- .../parserComputedPropertyName10.errors.txt | 5 +- .../parserComputedPropertyName11.errors.txt | 5 +- .../parserComputedPropertyName13.errors.txt | 5 +- .../parserComputedPropertyName14.errors.txt | 5 +- .../parserComputedPropertyName15.errors.txt | 5 +- .../parserComputedPropertyName18.errors.txt | 5 +- .../parserComputedPropertyName19.errors.txt | 5 +- .../parserComputedPropertyName20.errors.txt | 5 +- .../parserComputedPropertyName21.errors.txt | 5 +- .../parserComputedPropertyName22.errors.txt | 5 +- .../parserComputedPropertyName25.errors.txt | 5 +- .../parserComputedPropertyName28.errors.txt | 8 +- .../parserComputedPropertyName29.errors.txt | 8 +- .../parserComputedPropertyName31.errors.txt | 8 +- .../parserComputedPropertyName32.errors.txt | 5 +- .../parserComputedPropertyName36.errors.txt | 5 +- .../parserComputedPropertyName7.errors.txt | 5 +- .../parserComputedPropertyName8.errors.txt | 5 +- .../parserComputedPropertyName9.errors.txt | 5 +- .../parserES5ComputedPropertyName1.errors.txt | 5 +- ...parserES5ComputedPropertyName10.errors.txt | 5 +- ...parserES5ComputedPropertyName11.errors.txt | 5 +- .../parserES5ComputedPropertyName5.errors.txt | 5 +- .../parserES5ComputedPropertyName7.errors.txt | 5 +- .../parserES5ComputedPropertyName8.errors.txt | 5 +- .../parserES5ComputedPropertyName9.errors.txt | 5 +- .../parserES5SymbolProperty1.errors.txt | 5 +- .../parserES5SymbolProperty2.errors.txt | 5 +- .../parserES5SymbolProperty3.errors.txt | 5 +- .../parserES5SymbolProperty4.errors.txt | 5 +- .../parserES5SymbolProperty5.errors.txt | 5 +- .../parserES5SymbolProperty6.errors.txt | 5 +- .../parserES5SymbolProperty8.errors.txt | 5 +- .../parserES5SymbolProperty9.errors.txt | 5 +- .../parserIndexSignature11.errors.txt | 5 +- .../parserIndexSignature5.errors.txt | 5 +- .../baselines/reference/privateIndexer2.types | 4 +- ...pertiesOfGenericConstructorFunctions.types | 8 +- .../reference/propertyAssignment.errors.txt | 5 +- .../reference/spreadInvalidArgumentType.types | 2 +- .../baselines/reference/symbolProperty1.types | 8 +- .../baselines/reference/symbolProperty2.types | 8 +- .../reference/symbolProperty52.types | 16 +- .../reference/symbolProperty58.types | 8 +- .../reference/symbolProperty59.errors.txt | 5 +- ...arenthesizesConditionalSubexpression.types | 28 +-- ...sxEmitSpreadAttribute(target=es2015).types | 4 +- ...sxEmitSpreadAttribute(target=es2018).types | 4 +- ...sxEmitSpreadAttribute(target=esnext).types | 4 +- ...ctEmitSpreadAttribute(target=es2015).types | 4 +- ...ctEmitSpreadAttribute(target=es2018).types | 4 +- ...ctEmitSpreadAttribute(target=esnext).types | 4 +- .../typeUsedAsTypeLiteralIndex.errors.txt | 14 +- ...BeforeDeclaration_propertyAssignment.types | 4 +- ...rationEmitComputedNameWithQuestionToken.ts | 12 ++ ...eclarationEmitComputedNamesInaccessible.ts | 20 ++ ...tionEmitMultipleComputedNamesSameDomain.ts | 8 + .../declarationEmitSimpleComputedNames1.ts | 32 +++ 113 files changed, 1235 insertions(+), 536 deletions(-) delete mode 100644 tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt delete mode 100644 tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt create mode 100644 tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.js create mode 100644 tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.symbols create mode 100644 tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.types create mode 100644 tests/baselines/reference/declarationEmitComputedNamesInaccessible.js create mode 100644 tests/baselines/reference/declarationEmitComputedNamesInaccessible.symbols create mode 100644 tests/baselines/reference/declarationEmitComputedNamesInaccessible.types create mode 100644 tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.js create mode 100644 tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.symbols create mode 100644 tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.types create mode 100644 tests/baselines/reference/declarationEmitSimpleComputedNames1.js create mode 100644 tests/baselines/reference/declarationEmitSimpleComputedNames1.symbols create mode 100644 tests/baselines/reference/declarationEmitSimpleComputedNames1.types create mode 100644 tests/cases/compiler/declarationEmitComputedNameWithQuestionToken.ts create mode 100644 tests/cases/compiler/declarationEmitComputedNamesInaccessible.ts create mode 100644 tests/cases/compiler/declarationEmitMultipleComputedNamesSameDomain.ts create mode 100644 tests/cases/compiler/declarationEmitSimpleComputedNames1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e925f7fed9505..ded639b7a09cf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -157,6 +157,7 @@ import { ElementAccessChain, ElementAccessExpression, ElementFlags, + ElementWithComputedPropertyName, EmitFlags, EmitHint, emitModuleKindIsNonNodeESM, @@ -6935,7 +6936,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function shouldWriteTypeOfFunctionSymbol() { const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method) && // typeof static method - some(symbol.declarations, declaration => isStatic(declaration)); + some(symbol.declarations, declaration => isStatic(declaration) && !isLateBindableIndexSignature(getNameOfDeclaration(declaration)!)); const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && (symbol.parent || // is exported function symbol forEach(symbol.declarations, declaration => declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); @@ -7292,6 +7293,37 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return ids; } + function indexInfoToObjectComputedNamesOrSignatureDeclaration(indexInfo: IndexInfo, context: NodeBuilderContext, typeNode: TypeNode | undefined): [IndexSignatureDeclaration] | PropertySignature[] { + if (indexInfo.components) { + // Index info is derived from object or class computed property names (plus explicit named members) - we can clone those instead of writing out the result computed index signature + const allComponentComputedNamesSerializable = every(indexInfo.components, e => { + return !!(e.name && isComputedPropertyName(e.name) && isEntityNameExpression(e.name.expression) && context.enclosingDeclaration && isEntityNameVisible(e.name.expression, context.enclosingDeclaration, /*shouldComputeAliasToMakeVisible*/ false)?.accessibility === SymbolAccessibility.Accessible); + }); + if (allComponentComputedNamesSerializable) { + // Only use computed name serialization form if all components are visible and take the `a.b.c` form + const newComponents = filter(indexInfo.components, e => { + // skip late bound props that contribute to the index signature - they'll be created by property creation anyway + return !hasLateBindableName(e); + }); + return map(newComponents, e => { + // Still need to track visibility even if we've already checked it to paint references as used + trackComputedName(e.name.expression as EntityNameExpression, context.enclosingDeclaration, context); + return setTextRange( + context, + factory.createPropertySignature( + indexInfo.isReadonly ? [factory.createModifier(SyntaxKind.ReadonlyKeyword)] : undefined, + e.name, + (isPropertySignature(e) || isPropertyDeclaration(e) || isMethodSignature(e) || isMethodDeclaration(e) || isGetAccessor(e) || isSetAccessor(e)) && e.questionToken ? factory.createToken(SyntaxKind.QuestionToken) : undefined, + typeNode || typeToTypeNodeHelper(getTypeOfSymbol(e.symbol), context), + ), + e, + ); + }); + } + } + return [indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, typeNode)]; + } + function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] | undefined { if (checkTruncationLength(context)) { if (context.flags & NodeBuilderFlags.NoTruncation) { @@ -7308,7 +7340,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature, context) as ConstructSignatureDeclaration); } for (const info of resolvedType.indexInfos) { - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & ObjectFlags.ReverseMapped ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(...indexInfoToObjectComputedNamesOrSignatureDeclaration(info, context, resolvedType.objectFlags & ObjectFlags.ReverseMapped ? createElidedInformationPlaceholder(context) : undefined)); } const properties = resolvedType.properties; @@ -8049,10 +8081,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!context.tracker.canTrackSymbol) return; // get symbol of the first identifier of the entityName const firstIdentifier = getFirstIdentifier(accessExpression); - const name = resolveName(firstIdentifier, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*isUse*/ true); + const name = resolveName(enclosingDeclaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*isUse*/ true); if (name) { context.tracker.trackSymbol(name, enclosingDeclaration, SymbolFlags.Value); } + else { + // Name does not resolve at target location, track symbol at dest location (should be inaccessible) + const fallback = resolveName(firstIdentifier, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*isUse*/ true); + if (fallback) { + context.tracker.trackSymbol(fallback, enclosingDeclaration, SymbolFlags.Value); + } + } } function lookupSymbolChain(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, yieldModuleSymbol?: boolean) { @@ -16040,8 +16079,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return symbolTable.get(InternalSymbolName.Index); } - function createIndexInfo(keyType: Type, type: Type, isReadonly: boolean, declaration?: IndexSignatureDeclaration): IndexInfo { - return { keyType, type, isReadonly, declaration }; + function createIndexInfo(keyType: Type, type: Type, isReadonly: boolean, declaration?: IndexSignatureDeclaration, components?: ElementWithComputedPropertyName[]): IndexInfo { + return { keyType, type, isReadonly, declaration, components }; } function getIndexInfosOfSymbol(symbol: Symbol): IndexInfo[] { @@ -19658,7 +19697,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getIndexInfoWithReadonly(info: IndexInfo, readonly: boolean) { - return info.isReadonly !== readonly ? createIndexInfo(info.keyType, info.type, readonly, info.declaration) : info; + return info.isReadonly !== readonly ? createIndexInfo(info.keyType, info.type, readonly, info.declaration, info.components) : info; } function createLiteralType(flags: TypeFlags, value: string | number | PseudoBigInt, symbol?: Symbol, regularType?: LiteralType) { @@ -20566,7 +20605,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function instantiateIndexInfo(info: IndexInfo, mapper: TypeMapper) { - return createIndexInfo(info.keyType, instantiateType(info.type, mapper), info.isReadonly, info.declaration); + return createIndexInfo(info.keyType, instantiateType(info.type, mapper), info.isReadonly, info.declaration, info.components); } // Returns true if the given expression contains (at any level of nesting) a function or arrow expression @@ -25352,7 +25391,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } } - const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, sameMap(getIndexInfosOfType(type), info => createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly))); + const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, sameMap(getIndexInfosOfType(type), info => createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly, info.declaration, info.components))); result.objectFlags |= getObjectFlags(type) & (ObjectFlags.JSLiteral | ObjectFlags.NonInferrableType); // Retain js literal flag through widening return result; } @@ -32810,9 +32849,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), TypeFlags.ESSymbol)); } + function isSymbolWithComputedName(symbol: Symbol) { + const firstDecl = symbol.declarations?.[0]; + return firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name); + } + // NOTE: currently does not make pattern literal indexers, eg `${number}px` function getObjectLiteralIndexInfo(isReadonly: boolean, offset: number, properties: Symbol[], keyType: Type): IndexInfo { const propTypes: Type[] = []; + let components: ElementWithComputedPropertyName[] | undefined; for (let i = offset; i < properties.length; i++) { const prop = properties[i]; if ( @@ -32821,10 +32866,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { keyType === esSymbolType && isSymbolWithSymbolName(prop) ) { propTypes.push(getTypeOfSymbol(properties[i])); + if (isSymbolWithComputedName(properties[i])) { + components = append(components, properties[i].declarations?.[0]! as ElementWithComputedPropertyName); + } } } const unionType = propTypes.length ? getUnionType(propTypes, UnionReduction.Subtype) : undefinedType; - return createIndexInfo(keyType, unionType, isReadonly); + return createIndexInfo(keyType, unionType, isReadonly, /*declaration*/ undefined, components); } function getImmediateAliasedSymbol(symbol: Symbol): Symbol | undefined { @@ -46239,9 +46287,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const typeDeclaration = symbol.valueDeclaration; if (typeDeclaration && isClassLike(typeDeclaration)) { for (const member of typeDeclaration.members) { - // 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 (!isStatic(member) && !hasBindableName(member)) { + // Only process instance properties against instance index signatures and static properties against static index signatures + if ( + ( + (!isStaticIndex && !isStatic(member)) || + (isStaticIndex && isStatic(member)) + ) && !hasBindableName(member) + ) { const symbol = getSymbolOfDeclaration(member); checkIndexConstraintForProperty(type, symbol, getTypeOfExpression((member as DynamicNamedDeclaration).name.expression), getNonMissingTypeOfSymbol(symbol)); } @@ -50848,6 +50900,29 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { for (const info of infoList!) { if (info.declaration) continue; if (info === anyBaseTypeIndexInfo) continue; // inherited, but looks like a late-bound signature because it has no declarations + if (info.components) { + const allComponentComputedNamesSerializable = every(info.components, e => { + return !!(e.name && isComputedPropertyName(e.name) && isEntityNameExpression(e.name.expression) && enclosing && isEntityNameVisible(e.name.expression, enclosing, /*shouldComputeAliasToMakeVisible*/ false)?.accessibility === SymbolAccessibility.Accessible); + }); + if (allComponentComputedNamesSerializable) { + const newComponents = filter(info.components, e => { + // skip late bound props that contribute to the index signature - they'll be preserved via other means + return !hasLateBindableName(e); + }); + result.push(...map(newComponents, e => { + trackComputedName(e.name.expression as EntityNameExpression); + const mods = infoList === staticInfos ? [factory.createModifier(SyntaxKind.StaticKeyword)] as Modifier[] : undefined; + return factory.createPropertyDeclaration( + append(mods, info.isReadonly ? factory.createModifier(SyntaxKind.ReadonlyKeyword) : undefined), + e.name, + (isPropertySignature(e) || isPropertyDeclaration(e) || isMethodSignature(e) || isMethodDeclaration(e) || isGetAccessor(e) || isSetAccessor(e)) && e.questionToken ? factory.createToken(SyntaxKind.QuestionToken) : undefined, + nodeBuilder.typeToTypeNode(getTypeOfSymbol(e.symbol), enclosing, flags, internalFlags, tracker), + /*initializer*/ undefined, + ); + })); + continue; + } + } const node = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, enclosing, flags, internalFlags, tracker); if (node && infoList === staticInfos) { (((node as Mutable).modifiers ||= factory.createNodeArray()) as MutableNodeArray).unshift(factory.createModifier(SyntaxKind.StaticKeyword)); @@ -50858,6 +50933,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } return result; + + function trackComputedName(accessExpression: EntityNameOrEntityNameExpression) { + if (!tracker.trackSymbol) return; + // get symbol of the first identifier of the entityName + const firstIdentifier = getFirstIdentifier(accessExpression); + const name = resolveName(firstIdentifier, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*isUse*/ true); + if (name) { + tracker.trackSymbol(name, enclosing, SymbolFlags.Value); + } + } }, }; @@ -52311,7 +52396,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function checkGrammarForInvalidDynamicName(node: DeclarationName, message: DiagnosticMessage) { - if (isNonBindableDynamicName(node)) { + // Even non-bindable names are allowed as late-bound implied index signatures so long as the name is a simple `a.b.c` type name expression + if (isNonBindableDynamicName(node) && !isEntityNameExpression(isElementAccessExpression(node) ? skipParentheses(node.argumentExpression) : (node as ComputedPropertyName).expression)) { return grammarErrorOnNode(node, message); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ff0285e980c16..449ad50cb014d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5886,7 +5886,7 @@ export interface EmitResolver { getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): Statement[] | undefined; isImportRequiredByAugmentation(decl: ImportDeclaration): boolean; isDefinitelyReferenceToGlobalSymbolObject(node: Node): boolean; - createLateBoundIndexSignatures(cls: ClassLikeDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): IndexSignatureDeclaration[] | undefined; + createLateBoundIndexSignatures(cls: ClassLikeDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): (IndexSignatureDeclaration | PropertyDeclaration)[] | undefined; } // dprint-ignore @@ -7020,11 +7020,14 @@ export const enum IndexKind { Number, } +export type ElementWithComputedPropertyName = (ClassElement | ObjectLiteralElement) & { name: ComputedPropertyName; }; + export interface IndexInfo { keyType: Type; type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; + components?: ElementWithComputedPropertyName[]; } /** @internal */ diff --git a/tests/baselines/reference/ES5SymbolProperty1.types b/tests/baselines/reference/ES5SymbolProperty1.types index d32a461728c98..6be7f701e4a12 100644 --- a/tests/baselines/reference/ES5SymbolProperty1.types +++ b/tests/baselines/reference/ES5SymbolProperty1.types @@ -11,10 +11,10 @@ var Symbol: SymbolConstructor; > : ^^^^^^^^^^^^^^^^^ var obj = { ->obj : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [Symbol.foo]: 0} : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>obj : { [Symbol.foo]: number; } +> : ^^ ^^^^^^ ^^ +>{ [Symbol.foo]: 0} : { [Symbol.foo]: number; } +> : ^^ ^^^^^^ ^^ [Symbol.foo]: 0 >[Symbol.foo] : number @@ -32,8 +32,8 @@ var obj = { obj[Symbol.foo]; >obj[Symbol.foo] : number > : ^^^^^^ ->obj : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>obj : { [Symbol.foo]: number; } +> : ^^ ^^^^^^ ^^ >Symbol.foo : string > : ^^^^^^ >Symbol : SymbolConstructor diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 66810d2f55d6a..e7d26171cf4cd 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -6852,11 +6852,15 @@ declare namespace ts { String = 0, Number = 1, } + type ElementWithComputedPropertyName = (ClassElement | ObjectLiteralElement) & { + name: ComputedPropertyName; + }; interface IndexInfo { keyType: Type; type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; + components?: ElementWithComputedPropertyName[]; } enum InferencePriority { None = 0, diff --git a/tests/baselines/reference/capturedParametersInInitializers1.types b/tests/baselines/reference/capturedParametersInInitializers1.types index ff287cc2aad01..ac0b6cf4d8304 100644 --- a/tests/baselines/reference/capturedParametersInInitializers1.types +++ b/tests/baselines/reference/capturedParametersInInitializers1.types @@ -177,12 +177,12 @@ function foo8(y = (async () => z)(), z = 1) { // error - used as computed name of method function foo9(y = {[z]() { return z; }}, z = 1) { ->foo9 : (y?: { [x: number]: () => number; }, z?: number) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ->y : { [x: number]: () => number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{[z]() { return z; }} : { [x: number]: () => number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>foo9 : (y?: { [z]: () => number; }, z?: number) => void +> : ^ ^^^^^ ^^^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^ +>y : { [z]: () => number; } +> : ^^ ^^^^^^^^^^^^ ^^ +>{[z]() { return z; }} : { [z]: () => number; } +> : ^^ ^^^^^^^^^^^^ ^^ >[z] : () => number > : ^^^^^^^^^^^^ >z : number diff --git a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt index 7f7e502bfbba2..0576ba7b95af3 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt +++ b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt @@ -1,11 +1,10 @@ capturedParametersInInitializers2.ts(3,20): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. capturedParametersInInitializers2.ts(4,14): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. capturedParametersInInitializers2.ts(6,10): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. -capturedParametersInInitializers2.ts(13,26): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. capturedParametersInInitializers2.ts(13,27): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. -==== capturedParametersInInitializers2.ts (5 errors) ==== +==== capturedParametersInInitializers2.ts (4 errors) ==== function foo( y = class { static c = x; @@ -25,8 +24,6 @@ capturedParametersInInitializers2.ts(13,27): error TS2373: Parameter 'y' cannot y.c } function foo2(y = class {[x] = x}, x = 1) { - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ~ !!! error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. } \ No newline at end of file diff --git a/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.types b/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.types index 2620f9a3459e3..d90db1d4894ca 100644 --- a/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.types +++ b/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.types @@ -24,10 +24,10 @@ let s = `${n}`; > : ^^^^^^ const numericIndex = { [n]: 1 }; ->numericIndex : { [x: number]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [n]: 1 } : { [x: number]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>numericIndex : { [n]: number; } +> : ^^ ^^^^^^ ^^ +>{ [n]: 1 } : { [n]: number; } +> : ^^ ^^^^^^ ^^ >[n] : number > : ^^^^^^ >n : number @@ -42,18 +42,18 @@ numericIndex[n].toFixed(); > : ^ ^^^ ^^^^^ >numericIndex[n] : number > : ^^^^^^ ->numericIndex : { [x: number]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>numericIndex : { [n]: number; } +> : ^^ ^^^^^^ ^^ >n : number > : ^^^^^^ >toFixed : (fractionDigits?: number) => string > : ^ ^^^ ^^^^^ const stringIndex = { [s]: 1 }; ->stringIndex : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [s]: 1 } : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>stringIndex : { [s]: number; } +> : ^^ ^^^^^^ ^^ +>{ [s]: 1 } : { [s]: number; } +> : ^^ ^^^^^^ ^^ >[s] : number > : ^^^^^^ >s : string @@ -68,8 +68,8 @@ stringIndex[s].toFixed(); > : ^ ^^^ ^^^^^ >stringIndex[s] : number > : ^^^^^^ ->stringIndex : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>stringIndex : { [s]: number; } +> : ^^ ^^^^^^ ^^ >s : string > : ^^^^^^ >toFixed : (fractionDigits?: number) => string diff --git a/tests/baselines/reference/classNonUniqueSymbolMethodHasSymbolIndexer.js b/tests/baselines/reference/classNonUniqueSymbolMethodHasSymbolIndexer.js index b62a61483a00d..87e6bdcbef296 100644 --- a/tests/baselines/reference/classNonUniqueSymbolMethodHasSymbolIndexer.js +++ b/tests/baselines/reference/classNonUniqueSymbolMethodHasSymbolIndexer.js @@ -27,13 +27,15 @@ export const Mixer = Mix(class { //// [classNonUniqueSymbolMethodHasSymbolIndexer.d.ts] +declare const a: symbol; export declare class A { - [x: symbol]: () => number; + [a]: () => number; } export declare const Mixer: { new (): { - [x: symbol]: () => number; + [a]: () => number; }; } & (new (...args: any[]) => { mixed: true; }); +export {}; diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.types b/tests/baselines/reference/commaOperatorInConditionalExpression.types index edf5514a3b631..6bb1b1b70f76a 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.types +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.types @@ -8,8 +8,8 @@ function f (m: string) { > : ^^^^^^ [1, 2, 3].map(i => { ->[1, 2, 3].map(i => { return true? { [m]: i } : { [m]: i + 1 } }) : { [x: string]: number; }[] -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[1, 2, 3].map(i => { return true? { [m]: i } : { [m]: i + 1 } }) : { [m]: number; }[] +> : ^^ ^^^^^^ ^^^^ >[1, 2, 3].map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ >[1, 2, 3] : number[] @@ -22,26 +22,26 @@ function f (m: string) { > : ^ >map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ ->i => { return true? { [m]: i } : { [m]: i + 1 } } : (i: number) => { [x: string]: number; } -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>i => { return true? { [m]: i } : { [m]: i + 1 } } : (i: number) => { [m]: number; } +> : ^ ^^^^^^^^^^^^^^^ ^^^^^^ ^^ >i : number > : ^^^^^^ return true? { [m]: i } : { [m]: i + 1 } ->true? { [m]: i } : { [m]: i + 1 } : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>true? { [m]: i } : { [m]: i + 1 } : { [m]: number; } +> : ^^ ^^^^^^ ^^ >true : true > : ^^^^ ->{ [m]: i } : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [m]: i } : { [m]: number; } +> : ^^ ^^^^^^ ^^ >[m] : number > : ^^^^^^ >m : string > : ^^^^^^ >i : number > : ^^^^^^ ->{ [m]: i + 1 } : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [m]: i + 1 } : { [m]: number; } +> : ^^ ^^^^^^ ^^ >[m] : number > : ^^^^^^ >m : string diff --git a/tests/baselines/reference/complicatedPrivacy.errors.txt b/tests/baselines/reference/complicatedPrivacy.errors.txt index 4f493474e6eec..0131f5117a6f9 100644 --- a/tests/baselines/reference/complicatedPrivacy.errors.txt +++ b/tests/baselines/reference/complicatedPrivacy.errors.txt @@ -1,10 +1,9 @@ complicatedPrivacy.ts(11,24): error TS1054: A 'get' accessor cannot have parameters. -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. complicatedPrivacy.ts(35,6): error TS2693: 'number' only refers to a type, but is being used as a value here. complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo5' has no exported member 'i6'. -==== complicatedPrivacy.ts (4 errors) ==== +==== complicatedPrivacy.ts (3 errors) ==== module m1 { export module m2 { @@ -42,8 +41,6 @@ complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo5' has no exported me export function f4(arg1: { [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 TS2693: 'number' only refers to a type, but is being used as a value here. }) { diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.types b/tests/baselines/reference/computedPropertiesInDestructuring1.types index ed398829a4bf5..856a0ff50af44 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.types +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.types @@ -181,8 +181,8 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; > : ^^^^^^^^^^^^^^^^ >{[foo]: bar} = {bar: "bar"} : { bar: string; } > : ^^^^^^^^^^^^^^^^ ->{[foo]: bar} : { [x: string]: any; } -> : ^^^^^^^^^^^^^^^^^^^^^ +>{[foo]: bar} : { [foo]: any; } +> : ^^ ^^^ ^^ >[foo] : any > : ^^^ >foo : string @@ -241,10 +241,10 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; [{[foo]: bar4}] = [{bar: "bar"}]; >[{[foo]: bar4}] = [{bar: "bar"}] : [{ bar: string; }] > : ^^^^^^^^^^^^^^^^^^ ->[{[foo]: bar4}] : [{ [x: string]: any; }] -> : ^^^^^^^^^^^^^^^^^^^^^^^ ->{[foo]: bar4} : { [x: string]: any; } -> : ^^^^^^^^^^^^^^^^^^^^^ +>[{[foo]: bar4}] : [{ [foo]: any; }] +> : ^^^ ^^^ ^^^ +>{[foo]: bar4} : { [foo]: any; } +> : ^^ ^^^ ^^ >[foo] : any > : ^^^ >foo : string diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types index bb5f7bf36b885..dd3954b215340 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types +++ b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types @@ -193,8 +193,8 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; > : ^^^^^^^^^^^^^^^^ >{[foo]: bar} = {bar: "bar"} : { bar: string; } > : ^^^^^^^^^^^^^^^^ ->{[foo]: bar} : { [x: string]: any; } -> : ^^^^^^^^^^^^^^^^^^^^^ +>{[foo]: bar} : { [foo]: any; } +> : ^^ ^^^ ^^ >[foo] : any > : ^^^ >foo : string @@ -253,10 +253,10 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; [{[foo]: bar4}] = [{bar: "bar"}]; >[{[foo]: bar4}] = [{bar: "bar"}] : [{ bar: string; }] > : ^^^^^^^^^^^^^^^^^^ ->[{[foo]: bar4}] : [{ [x: string]: any; }] -> : ^^^^^^^^^^^^^^^^^^^^^^^ ->{[foo]: bar4} : { [x: string]: any; } -> : ^^^^^^^^^^^^^^^^^^^^^ +>[{[foo]: bar4}] : [{ [foo]: any; }] +> : ^^^ ^^^ ^^^ +>{[foo]: bar4} : { [foo]: any; } +> : ^^ ^^^ ^^ >[foo] : any > : ^^^ >foo : string diff --git a/tests/baselines/reference/computedPropertiesNarrowed.errors.txt b/tests/baselines/reference/computedPropertiesNarrowed.errors.txt index f4aae6aa04d2a..3d6bf4c8cc890 100644 --- a/tests/baselines/reference/computedPropertiesNarrowed.errors.txt +++ b/tests/baselines/reference/computedPropertiesNarrowed.errors.txt @@ -1,6 +1,7 @@ computedPropertiesNarrowed.ts(5,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. computedPropertiesNarrowed.ts(11,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. computedPropertiesNarrowed.ts(18,20): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. +computedPropertiesNarrowed.ts(20,5): error TS9010: Variable must have an explicit type annotation with --isolatedDeclarations. computedPropertiesNarrowed.ts(22,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. computedPropertiesNarrowed.ts(26,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. computedPropertiesNarrowed.ts(31,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. @@ -9,7 +10,7 @@ computedPropertiesNarrowed.ts(42,5): error TS9038: Computed property names on cl computedPropertiesNarrowed.ts(47,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. -==== computedPropertiesNarrowed.ts (9 errors) ==== +==== computedPropertiesNarrowed.ts (10 errors) ==== const x: 0 | 1 = Math.random()? 0: 1; declare function assert(n: number): asserts n is 1; assert(x); @@ -39,6 +40,9 @@ computedPropertiesNarrowed.ts(47,5): error TS9038: Computed property names on cl !!! related TS9027 computedPropertiesNarrowed.ts:18:12: Add a type annotation to the variable o32. let u = Symbol(); + ~ +!!! error TS9010: Variable must have an explicit type annotation with --isolatedDeclarations. +!!! related TS9027 computedPropertiesNarrowed.ts:20:5: Add a type annotation to the variable u. export let o4 = { [u]: 1 // Should error, nut a unique symbol ~~~ diff --git a/tests/baselines/reference/computedPropertiesNarrowed.types b/tests/baselines/reference/computedPropertiesNarrowed.types index 81a74a3aca456..86530413cbaee 100644 --- a/tests/baselines/reference/computedPropertiesNarrowed.types +++ b/tests/baselines/reference/computedPropertiesNarrowed.types @@ -122,10 +122,10 @@ let u = Symbol(); > : ^^^^^^^^^^^^^^^^^ export let o4 = { ->o4 : { [x: symbol]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [u]: 1 // Should error, nut a unique symbol} : { [x: symbol]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>o4 : { [u]: number; } +> : ^^ ^^^^^^ ^^ +>{ [u]: 1 // Should error, nut a unique symbol} : { [u]: number; } +> : ^^ ^^^^^^ ^^ [u]: 1 // Should error, nut a unique symbol >[u] : number diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt index 54170d241bb85..7803fd8078d63 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt @@ -1,26 +1,19 @@ -computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES5.ts(9,5): error TS2411: Property '[+s]' of type 'string' is not assignable to 'number' index type 'number'. computedPropertyNames12_ES5.ts(9,5): error TS2411: Property '[+s]' of type 'string' is not assignable to 'string' index type 'number'. -computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -==== computedPropertyNames12_ES5.ts (10 errors) ==== +==== computedPropertyNames12_ES5.ts (7 errors) ==== var s: string; var n: number; var a: any; class C { [s]: number; - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. [n] = n; - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. static [s + s]: string; ~~~~~~~ !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @@ -37,8 +30,6 @@ computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in static [""]: number; [0]: number; [a]: number; - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. static [true]: number; ~~~~~~~~~~~ !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt index 045be616de457..08016db3ddd77 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt @@ -1,26 +1,19 @@ -computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES6.ts(9,5): error TS2411: Property '[+s]' of type 'string' is not assignable to 'number' index type 'number'. computedPropertyNames12_ES6.ts(9,5): error TS2411: Property '[+s]' of type 'string' is not assignable to 'string' index type 'number'. -computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -==== computedPropertyNames12_ES6.ts (10 errors) ==== +==== computedPropertyNames12_ES6.ts (7 errors) ==== var s: string; var n: number; var a: any; class C { [s]: number; - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. [n] = n; - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. static [s + s]: string; ~~~~~~~ !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @@ -37,8 +30,6 @@ computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in static [""]: number; [0]: number; [a]: number; - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. static [true]: number; ~~~~~~~~~~~ !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.types b/tests/baselines/reference/computedPropertyNames48_ES5.types index 94a8541879a4d..8f91b12db5bf8 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.types +++ b/tests/baselines/reference/computedPropertyNames48_ES5.types @@ -24,8 +24,8 @@ extractIndexer({ > : ^^^^^^ >extractIndexer : (p: { [n: number]: T; }) => T > : ^ ^^ ^^ ^^^^^ ->{ [a]: ""} : { [x: number]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [a]: ""} : { [a]: string; } +> : ^^ ^^^^^^ ^^ [a]: "" >[a] : string diff --git a/tests/baselines/reference/computedPropertyNames48_ES6.types b/tests/baselines/reference/computedPropertyNames48_ES6.types index f472c49e97a25..94072728bd2af 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES6.types +++ b/tests/baselines/reference/computedPropertyNames48_ES6.types @@ -24,8 +24,8 @@ extractIndexer({ > : ^^^^^^ >extractIndexer : (p: { [n: number]: T; }) => T > : ^ ^^ ^^ ^^^^^ ->{ [a]: ""} : { [x: number]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [a]: ""} : { [a]: string; } +> : ^^ ^^^^^^ ^^ [a]: "" >[a] : string diff --git a/tests/baselines/reference/computedPropertyNames6_ES5.types b/tests/baselines/reference/computedPropertyNames6_ES5.types index 61996955d5bba..9008b073a471a 100644 --- a/tests/baselines/reference/computedPropertyNames6_ES5.types +++ b/tests/baselines/reference/computedPropertyNames6_ES5.types @@ -14,10 +14,10 @@ var p3: string | boolean; > : ^^^^^^^^^^^^^^^^ var v = { ->v : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [p1]: 0, [p2]: 1, [p3]: 2} : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>v : { [p1]: number; [p2]: number; [p3]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^ ^^ +>{ [p1]: 0, [p2]: 1, [p3]: 2} : { [p1]: number; [p2]: number; [p3]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^ ^^ [p1]: 0, >[p1] : number diff --git a/tests/baselines/reference/computedPropertyNames6_ES6.types b/tests/baselines/reference/computedPropertyNames6_ES6.types index dd4e7605e3837..aaf0013097b9e 100644 --- a/tests/baselines/reference/computedPropertyNames6_ES6.types +++ b/tests/baselines/reference/computedPropertyNames6_ES6.types @@ -14,10 +14,10 @@ var p3: string | boolean; > : ^^^^^^^^^^^^^^^^ var v = { ->v : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [p1]: 0, [p2]: 1, [p3]: 2} : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>v : { [p1]: number; [p2]: number; [p3]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^ ^^ +>{ [p1]: 0, [p2]: 1, [p3]: 2} : { [p1]: number; [p2]: number; [p3]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^ ^^ [p1]: 0, >[p1] : number diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt deleted file mode 100644 index 50cecd98bdfe6..0000000000000 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -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. -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. - - -==== computedPropertyNamesOnOverloads_ES5.ts (2 errors) ==== - var methodName = "method"; - var accessorName = "accessor"; - 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. - [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. - [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 deleted file mode 100644 index c5e632c6de2ef..0000000000000 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -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. -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. - - -==== computedPropertyNamesOnOverloads_ES6.ts (2 errors) ==== - var methodName = "method"; - var accessorName = "accessor"; - 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. - [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. - [methodName](v?: string) { } - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitAnyComputedPropertyInClass.js b/tests/baselines/reference/declarationEmitAnyComputedPropertyInClass.js index bc3473ad4d914..ba0c87ed11d33 100644 --- a/tests/baselines/reference/declarationEmitAnyComputedPropertyInClass.js +++ b/tests/baselines/reference/declarationEmitAnyComputedPropertyInClass.js @@ -27,6 +27,7 @@ exports.C = C; //// [main.d.ts] +import Test from "abcdefgh"; export declare class C { - [x: number]: () => void; + [Test.someKey]: () => void; } diff --git a/tests/baselines/reference/declarationEmitClassMemberWithComputedPropertyName.js b/tests/baselines/reference/declarationEmitClassMemberWithComputedPropertyName.js index 1445e1f383e8a..e8afbcac41d82 100644 --- a/tests/baselines/reference/declarationEmitClassMemberWithComputedPropertyName.js +++ b/tests/baselines/reference/declarationEmitClassMemberWithComputedPropertyName.js @@ -75,9 +75,9 @@ declare class Foo { static p1: number; p1: number; } -export declare const t1: (typeof Foo)[typeof k1]; +export declare const t1: () => number; export declare const t2: () => string; -export declare const t3: typeof Foo.foo; +export declare const t3: () => number; export declare const t4: () => string; export declare const t5: typeof Foo.m1; export declare const t6: () => void; diff --git a/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.js b/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.js new file mode 100644 index 0000000000000..f3f96a4af5ba2 --- /dev/null +++ b/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/declarationEmitComputedNameWithQuestionToken.ts] //// + +//// [declarationEmitComputedNameWithQuestionToken.ts] +declare var something: string; +export const dataSomething = `data-${something}` as const; + +export class WithData { + [dataSomething]?() { + return "something"; + } +} + +export const a = (new WithData())["ahahahaahah"]!(); + +//// [declarationEmitComputedNameWithQuestionToken.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = exports.WithData = exports.dataSomething = void 0; +exports.dataSomething = "data-".concat(something); +var WithData = /** @class */ (function () { + function WithData() { + } + WithData.prototype[exports.dataSomething] = function () { + return "something"; + }; + return WithData; +}()); +exports.WithData = WithData; +exports.a = (new WithData())["ahahahaahah"](); + + +//// [declarationEmitComputedNameWithQuestionToken.d.ts] +export declare const dataSomething: `data-${string}`; +export declare class WithData { + [dataSomething]?: () => string; +} +export declare const a: string; diff --git a/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.symbols b/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.symbols new file mode 100644 index 0000000000000..747ecb52b8f69 --- /dev/null +++ b/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/declarationEmitComputedNameWithQuestionToken.ts] //// + +=== declarationEmitComputedNameWithQuestionToken.ts === +declare var something: string; +>something : Symbol(something, Decl(declarationEmitComputedNameWithQuestionToken.ts, 0, 11)) + +export const dataSomething = `data-${something}` as const; +>dataSomething : Symbol(dataSomething, Decl(declarationEmitComputedNameWithQuestionToken.ts, 1, 12)) +>something : Symbol(something, Decl(declarationEmitComputedNameWithQuestionToken.ts, 0, 11)) +>const : Symbol(const) + +export class WithData { +>WithData : Symbol(WithData, Decl(declarationEmitComputedNameWithQuestionToken.ts, 1, 58)) + + [dataSomething]?() { +>[dataSomething] : Symbol(WithData[dataSomething], Decl(declarationEmitComputedNameWithQuestionToken.ts, 3, 23)) +>dataSomething : Symbol(dataSomething, Decl(declarationEmitComputedNameWithQuestionToken.ts, 1, 12)) + + return "something"; + } +} + +export const a = (new WithData())["ahahahaahah"]!(); +>a : Symbol(a, Decl(declarationEmitComputedNameWithQuestionToken.ts, 9, 12)) +>WithData : Symbol(WithData, Decl(declarationEmitComputedNameWithQuestionToken.ts, 1, 58)) + diff --git a/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.types b/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.types new file mode 100644 index 0000000000000..033778d09d8fe --- /dev/null +++ b/tests/baselines/reference/declarationEmitComputedNameWithQuestionToken.types @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/declarationEmitComputedNameWithQuestionToken.ts] //// + +=== declarationEmitComputedNameWithQuestionToken.ts === +declare var something: string; +>something : string +> : ^^^^^^ + +export const dataSomething = `data-${something}` as const; +>dataSomething : `data-${string}` +> : ^^^^^^^^^^^^^^^^ +>`data-${something}` as const : `data-${string}` +> : ^^^^^^^^^^^^^^^^ +>`data-${something}` : `data-${string}` +> : ^^^^^^^^^^^^^^^^ +>something : string +> : ^^^^^^ + +export class WithData { +>WithData : WithData +> : ^^^^^^^^ + + [dataSomething]?() { +>[dataSomething] : () => string +> : ^^^^^^^^^^^^ +>dataSomething : `data-${string}` +> : ^^^^^^^^^^^^^^^^ + + return "something"; +>"something" : "something" +> : ^^^^^^^^^^^ + } +} + +export const a = (new WithData())["ahahahaahah"]!(); +>a : string +> : ^^^^^^ +>(new WithData())["ahahahaahah"]!() : string +> : ^^^^^^ +>(new WithData())["ahahahaahah"]! : () => string +> : ^^^^^^^^^^^^ +>(new WithData())["ahahahaahah"] : () => string +> : ^^^^^^^^^^^^ +>(new WithData()) : WithData +> : ^^^^^^^^ +>new WithData() : WithData +> : ^^^^^^^^ +>WithData : typeof WithData +> : ^^^^^^^^^^^^^^^ +>"ahahahaahah" : "ahahahaahah" +> : ^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/declarationEmitComputedNamesInaccessible.js b/tests/baselines/reference/declarationEmitComputedNamesInaccessible.js new file mode 100644 index 0000000000000..39a3113c03f08 --- /dev/null +++ b/tests/baselines/reference/declarationEmitComputedNamesInaccessible.js @@ -0,0 +1,64 @@ +//// [tests/cases/compiler/declarationEmitComputedNamesInaccessible.ts] //// + +//// [declarationEmitComputedNamesInaccessible.ts] +export function f1() { + const localClassFieldName = Math.random() > 0.5 ? "g1" : "g2"; + const localOtherField = localClassFieldName === "g1" ? "g2" : "g1"; + const localStaticField = Math.random() > 0.5 ? "s1" : "s2"; + return class ParameterizedHolder { + [localClassFieldName]() { + return "value"; + } + [localOtherField]() { + return 42; + } + static [localStaticField]() { + return { static: true }; + } + static [localStaticField]() { + return { static: "sometimes" }; + } + } +} + +//// [declarationEmitComputedNamesInaccessible.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f1 = f1; +function f1() { + var localClassFieldName = Math.random() > 0.5 ? "g1" : "g2"; + var localOtherField = localClassFieldName === "g1" ? "g2" : "g1"; + var localStaticField = Math.random() > 0.5 ? "s1" : "s2"; + return /** @class */ (function () { + function ParameterizedHolder() { + } + ParameterizedHolder.prototype[localClassFieldName] = function () { + return "value"; + }; + ParameterizedHolder.prototype[localOtherField] = function () { + return 42; + }; + ParameterizedHolder[localStaticField] = function () { + return { static: true }; + }; + ParameterizedHolder[localStaticField] = function () { + return { static: "sometimes" }; + }; + return ParameterizedHolder; + }()); +} + + +//// [declarationEmitComputedNamesInaccessible.d.ts] +export declare function f1(): { + new (): { + [x: string]: (() => string) | (() => number); + }; + [x: string]: { + [x: string]: (() => string) | (() => number); + } | (() => { + static: boolean; + }) | (() => { + static: string; + }); +}; diff --git a/tests/baselines/reference/declarationEmitComputedNamesInaccessible.symbols b/tests/baselines/reference/declarationEmitComputedNamesInaccessible.symbols new file mode 100644 index 0000000000000..3e72a96d75a16 --- /dev/null +++ b/tests/baselines/reference/declarationEmitComputedNamesInaccessible.symbols @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/declarationEmitComputedNamesInaccessible.ts] //// + +=== declarationEmitComputedNamesInaccessible.ts === +export function f1() { +>f1 : Symbol(f1, Decl(declarationEmitComputedNamesInaccessible.ts, 0, 0)) + + const localClassFieldName = Math.random() > 0.5 ? "g1" : "g2"; +>localClassFieldName : Symbol(localClassFieldName, Decl(declarationEmitComputedNamesInaccessible.ts, 1, 9)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + const localOtherField = localClassFieldName === "g1" ? "g2" : "g1"; +>localOtherField : Symbol(localOtherField, Decl(declarationEmitComputedNamesInaccessible.ts, 2, 9)) +>localClassFieldName : Symbol(localClassFieldName, Decl(declarationEmitComputedNamesInaccessible.ts, 1, 9)) + + const localStaticField = Math.random() > 0.5 ? "s1" : "s2"; +>localStaticField : Symbol(localStaticField, Decl(declarationEmitComputedNamesInaccessible.ts, 3, 9)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + return class ParameterizedHolder { +>ParameterizedHolder : Symbol(ParameterizedHolder, Decl(declarationEmitComputedNamesInaccessible.ts, 4, 10)) + + [localClassFieldName]() { +>[localClassFieldName] : Symbol(ParameterizedHolder[localClassFieldName], Decl(declarationEmitComputedNamesInaccessible.ts, 4, 38)) +>localClassFieldName : Symbol(localClassFieldName, Decl(declarationEmitComputedNamesInaccessible.ts, 1, 9)) + + return "value"; + } + [localOtherField]() { +>[localOtherField] : Symbol(ParameterizedHolder[localOtherField], Decl(declarationEmitComputedNamesInaccessible.ts, 7, 9)) +>localOtherField : Symbol(localOtherField, Decl(declarationEmitComputedNamesInaccessible.ts, 2, 9)) + + return 42; + } + static [localStaticField]() { +>[localStaticField] : Symbol(ParameterizedHolder[localStaticField], Decl(declarationEmitComputedNamesInaccessible.ts, 10, 9)) +>localStaticField : Symbol(localStaticField, Decl(declarationEmitComputedNamesInaccessible.ts, 3, 9)) + + return { static: true }; +>static : Symbol(static, Decl(declarationEmitComputedNamesInaccessible.ts, 12, 20)) + } + static [localStaticField]() { +>[localStaticField] : Symbol(ParameterizedHolder[localStaticField], Decl(declarationEmitComputedNamesInaccessible.ts, 13, 9)) +>localStaticField : Symbol(localStaticField, Decl(declarationEmitComputedNamesInaccessible.ts, 3, 9)) + + return { static: "sometimes" }; +>static : Symbol(static, Decl(declarationEmitComputedNamesInaccessible.ts, 15, 20)) + } + } +} diff --git a/tests/baselines/reference/declarationEmitComputedNamesInaccessible.types b/tests/baselines/reference/declarationEmitComputedNamesInaccessible.types new file mode 100644 index 0000000000000..4c04167fb0ab5 --- /dev/null +++ b/tests/baselines/reference/declarationEmitComputedNamesInaccessible.types @@ -0,0 +1,123 @@ +//// [tests/cases/compiler/declarationEmitComputedNamesInaccessible.ts] //// + +=== declarationEmitComputedNamesInaccessible.ts === +export function f1() { +>f1 : () => typeof ParameterizedHolder +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const localClassFieldName = Math.random() > 0.5 ? "g1" : "g2"; +>localClassFieldName : "g1" | "g2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 ? "g1" : "g2" : "g1" | "g2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 : boolean +> : ^^^^^^^ +>Math.random() : number +> : ^^^^^^ +>Math.random : () => number +> : ^^^^^^ +>Math : Math +> : ^^^^ +>random : () => number +> : ^^^^^^ +>0.5 : 0.5 +> : ^^^ +>"g1" : "g1" +> : ^^^^ +>"g2" : "g2" +> : ^^^^ + + const localOtherField = localClassFieldName === "g1" ? "g2" : "g1"; +>localOtherField : "g1" | "g2" +> : ^^^^^^^^^^^ +>localClassFieldName === "g1" ? "g2" : "g1" : "g1" | "g2" +> : ^^^^^^^^^^^ +>localClassFieldName === "g1" : boolean +> : ^^^^^^^ +>localClassFieldName : "g1" | "g2" +> : ^^^^^^^^^^^ +>"g1" : "g1" +> : ^^^^ +>"g2" : "g2" +> : ^^^^ +>"g1" : "g1" +> : ^^^^ + + const localStaticField = Math.random() > 0.5 ? "s1" : "s2"; +>localStaticField : "s1" | "s2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 ? "s1" : "s2" : "s1" | "s2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 : boolean +> : ^^^^^^^ +>Math.random() : number +> : ^^^^^^ +>Math.random : () => number +> : ^^^^^^ +>Math : Math +> : ^^^^ +>random : () => number +> : ^^^^^^ +>0.5 : 0.5 +> : ^^^ +>"s1" : "s1" +> : ^^^^ +>"s2" : "s2" +> : ^^^^ + + return class ParameterizedHolder { +>class ParameterizedHolder { [localClassFieldName]() { return "value"; } [localOtherField]() { return 42; } static [localStaticField]() { return { static: true }; } static [localStaticField]() { return { static: "sometimes" }; } } : typeof ParameterizedHolder +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ParameterizedHolder : typeof ParameterizedHolder +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [localClassFieldName]() { +>[localClassFieldName] : () => string +> : ^^^^^^^^^^^^ +>localClassFieldName : "g1" | "g2" +> : ^^^^^^^^^^^ + + return "value"; +>"value" : "value" +> : ^^^^^^^ + } + [localOtherField]() { +>[localOtherField] : () => number +> : ^^^^^^^^^^^^ +>localOtherField : "g1" | "g2" +> : ^^^^^^^^^^^ + + return 42; +>42 : 42 +> : ^^ + } + static [localStaticField]() { +>[localStaticField] : () => { static: boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>localStaticField : "s1" | "s2" +> : ^^^^^^^^^^^ + + return { static: true }; +>{ static: true } : { static: boolean; } +> : ^^^^^^^^^^^^^^^^^^^^ +>static : boolean +> : ^^^^^^^ +>true : true +> : ^^^^ + } + static [localStaticField]() { +>[localStaticField] : () => { static: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>localStaticField : "s1" | "s2" +> : ^^^^^^^^^^^ + + return { static: "sometimes" }; +>{ static: "sometimes" } : { static: string; } +> : ^^^^^^^^^^^^^^^^^^^ +>static : string +> : ^^^^^^ +>"sometimes" : "sometimes" +> : ^^^^^^^^^^^ + } + } +} diff --git a/tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.errors.txt b/tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.errors.txt index bef0d0f6357bb..e757df4afd97e 100644 --- a/tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.errors.txt +++ b/tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.errors.txt @@ -1,11 +1,8 @@ -type.ts(1,28): 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. type.ts(1,29): error TS2304: Cannot find name 'Enum'. -==== type.ts (2 errors) ==== +==== type.ts (1 errors) ==== export type Type = { x?: { [Enum.A]: 0 } }; - ~~~~~~~~ -!!! 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 'Enum'. diff --git a/tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.errors.txt b/tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.errors.txt index a960f11f4c2ad..0762563c151a0 100644 --- a/tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.errors.txt +++ b/tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.errors.txt @@ -1,8 +1,7 @@ -type.ts(7,28): 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. type.ts(7,28): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== type.ts (2 errors) ==== +==== type.ts (1 errors) ==== export namespace Foo { export enum Enum { A = "a", @@ -11,8 +10,6 @@ type.ts(7,28): error TS2464: A computed property name must be of type 'string', } export type Type = { x?: { [Foo.Enum]: 0 } }; ~~~~~~~~~~ -!!! 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 TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ==== index.ts (0 errors) ==== diff --git a/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.js b/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.js new file mode 100644 index 0000000000000..bbf6ae6b79f88 --- /dev/null +++ b/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/declarationEmitMultipleComputedNamesSameDomain.ts] //// + +//// [declarationEmitMultipleComputedNamesSameDomain.ts] +declare const x: string; +declare const y: "y"; + +export class Test { + [x] = 10; + [y] = 10; +} + +//// [declarationEmitMultipleComputedNamesSameDomain.js] +"use strict"; +var _a, _b; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Test = void 0; +var Test = /** @class */ (function () { + function Test() { + this[_a] = 10; + this[_b] = 10; + } + return Test; +}()); +exports.Test = Test; +_a = x, _b = y; + + +//// [declarationEmitMultipleComputedNamesSameDomain.d.ts] +declare const x: string; +declare const y: "y"; +export declare class Test { + [x]: number; + [y]: number; +} +export {}; diff --git a/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.symbols b/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.symbols new file mode 100644 index 0000000000000..93b5225c9dfb8 --- /dev/null +++ b/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/declarationEmitMultipleComputedNamesSameDomain.ts] //// + +=== declarationEmitMultipleComputedNamesSameDomain.ts === +declare const x: string; +>x : Symbol(x, Decl(declarationEmitMultipleComputedNamesSameDomain.ts, 0, 13)) + +declare const y: "y"; +>y : Symbol(y, Decl(declarationEmitMultipleComputedNamesSameDomain.ts, 1, 13)) + +export class Test { +>Test : Symbol(Test, Decl(declarationEmitMultipleComputedNamesSameDomain.ts, 1, 21)) + + [x] = 10; +>[x] : Symbol(Test[x], Decl(declarationEmitMultipleComputedNamesSameDomain.ts, 3, 19)) +>x : Symbol(x, Decl(declarationEmitMultipleComputedNamesSameDomain.ts, 0, 13)) + + [y] = 10; +>[y] : Symbol(Test[y], Decl(declarationEmitMultipleComputedNamesSameDomain.ts, 4, 13)) +>y : Symbol(y, Decl(declarationEmitMultipleComputedNamesSameDomain.ts, 1, 13)) +} diff --git a/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.types b/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.types new file mode 100644 index 0000000000000..22327884dd636 --- /dev/null +++ b/tests/baselines/reference/declarationEmitMultipleComputedNamesSameDomain.types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/declarationEmitMultipleComputedNamesSameDomain.ts] //// + +=== declarationEmitMultipleComputedNamesSameDomain.ts === +declare const x: string; +>x : string +> : ^^^^^^ + +declare const y: "y"; +>y : "y" +> : ^^^ + +export class Test { +>Test : Test +> : ^^^^ + + [x] = 10; +>[x] : number +> : ^^^^^^ +>x : string +> : ^^^^^^ +>10 : 10 +> : ^^ + + [y] = 10; +>[y] : number +> : ^^^^^^ +>y : "y" +> : ^^^ +>10 : 10 +> : ^^ +} diff --git a/tests/baselines/reference/declarationEmitSimpleComputedNames1.js b/tests/baselines/reference/declarationEmitSimpleComputedNames1.js new file mode 100644 index 0000000000000..88a7c5ac1e91a --- /dev/null +++ b/tests/baselines/reference/declarationEmitSimpleComputedNames1.js @@ -0,0 +1,102 @@ +//// [tests/cases/compiler/declarationEmitSimpleComputedNames1.ts] //// + +//// [declarationEmitSimpleComputedNames1.ts] +export const fieldName = Math.random() > 0.5 ? "f1" : "f2"; +export const conatainer = { + [fieldName]() { + return "result"; + } +}; + +const classFieldName = Math.random() > 0.5 ? "g1" : "g2"; +const otherField = classFieldName === "g1" ? "g2" : "g1"; +const staticField = Math.random() > 0.5 ? "s1" : "s2"; +export class Holder { + [classFieldName]() { + return "value"; + } + [otherField]() { + return 42; + } + static [staticField]() { + return { static: true }; + } + static [staticField]() { + return { static: "sometimes" }; + } +} + +/** + * Could be `"prototype"`, so all static string indexers include the instance type + */ +export const staticLookup = Holder["some" + "thing"]; +export const instanceLookup = (new Holder())["some" + "thing"]; + + +//// [declarationEmitSimpleComputedNames1.js] +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.instanceLookup = exports.staticLookup = exports.Holder = exports.conatainer = exports.fieldName = void 0; +exports.fieldName = Math.random() > 0.5 ? "f1" : "f2"; +exports.conatainer = (_a = {}, + _a[exports.fieldName] = function () { + return "result"; + }, + _a); +var classFieldName = Math.random() > 0.5 ? "g1" : "g2"; +var otherField = classFieldName === "g1" ? "g2" : "g1"; +var staticField = Math.random() > 0.5 ? "s1" : "s2"; +var Holder = /** @class */ (function () { + function Holder() { + } + Holder.prototype[classFieldName] = function () { + return "value"; + }; + Holder.prototype[otherField] = function () { + return 42; + }; + Holder[staticField] = function () { + return { static: true }; + }; + Holder[staticField] = function () { + return { static: "sometimes" }; + }; + return Holder; +}()); +exports.Holder = Holder; +/** + * Could be `"prototype"`, so all static string indexers include the instance type + */ +exports.staticLookup = Holder["some" + "thing"]; +exports.instanceLookup = (new Holder())["some" + "thing"]; + + +//// [declarationEmitSimpleComputedNames1.d.ts] +export declare const fieldName: string; +export declare const conatainer: { + [fieldName]: () => string; +}; +declare const classFieldName: string; +declare const otherField: string; +declare const staticField: string; +export declare class Holder { + static [staticField]: () => { + static: boolean; + }; + static [staticField]: () => { + static: string; + }; + [classFieldName]: () => string; + [otherField]: () => number; +} +/** + * Could be `"prototype"`, so all static string indexers include the instance type + */ +export declare const staticLookup: Holder | (() => { + static: boolean; +}) | (() => { + static: string; +}); +export declare const instanceLookup: (() => string) | (() => number); +export {}; diff --git a/tests/baselines/reference/declarationEmitSimpleComputedNames1.symbols b/tests/baselines/reference/declarationEmitSimpleComputedNames1.symbols new file mode 100644 index 0000000000000..84580bb454992 --- /dev/null +++ b/tests/baselines/reference/declarationEmitSimpleComputedNames1.symbols @@ -0,0 +1,78 @@ +//// [tests/cases/compiler/declarationEmitSimpleComputedNames1.ts] //// + +=== declarationEmitSimpleComputedNames1.ts === +export const fieldName = Math.random() > 0.5 ? "f1" : "f2"; +>fieldName : Symbol(fieldName, Decl(declarationEmitSimpleComputedNames1.ts, 0, 12)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + +export const conatainer = { +>conatainer : Symbol(conatainer, Decl(declarationEmitSimpleComputedNames1.ts, 1, 12)) + + [fieldName]() { +>[fieldName] : Symbol([fieldName], Decl(declarationEmitSimpleComputedNames1.ts, 1, 27)) +>fieldName : Symbol(fieldName, Decl(declarationEmitSimpleComputedNames1.ts, 0, 12)) + + return "result"; + } +}; + +const classFieldName = Math.random() > 0.5 ? "g1" : "g2"; +>classFieldName : Symbol(classFieldName, Decl(declarationEmitSimpleComputedNames1.ts, 7, 5)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + +const otherField = classFieldName === "g1" ? "g2" : "g1"; +>otherField : Symbol(otherField, Decl(declarationEmitSimpleComputedNames1.ts, 8, 5)) +>classFieldName : Symbol(classFieldName, Decl(declarationEmitSimpleComputedNames1.ts, 7, 5)) + +const staticField = Math.random() > 0.5 ? "s1" : "s2"; +>staticField : Symbol(staticField, Decl(declarationEmitSimpleComputedNames1.ts, 9, 5)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + +export class Holder { +>Holder : Symbol(Holder, Decl(declarationEmitSimpleComputedNames1.ts, 9, 54)) + + [classFieldName]() { +>[classFieldName] : Symbol(Holder[classFieldName], Decl(declarationEmitSimpleComputedNames1.ts, 10, 21)) +>classFieldName : Symbol(classFieldName, Decl(declarationEmitSimpleComputedNames1.ts, 7, 5)) + + return "value"; + } + [otherField]() { +>[otherField] : Symbol(Holder[otherField], Decl(declarationEmitSimpleComputedNames1.ts, 13, 5)) +>otherField : Symbol(otherField, Decl(declarationEmitSimpleComputedNames1.ts, 8, 5)) + + return 42; + } + static [staticField]() { +>[staticField] : Symbol(Holder[staticField], Decl(declarationEmitSimpleComputedNames1.ts, 16, 5)) +>staticField : Symbol(staticField, Decl(declarationEmitSimpleComputedNames1.ts, 9, 5)) + + return { static: true }; +>static : Symbol(static, Decl(declarationEmitSimpleComputedNames1.ts, 18, 16)) + } + static [staticField]() { +>[staticField] : Symbol(Holder[staticField], Decl(declarationEmitSimpleComputedNames1.ts, 19, 5)) +>staticField : Symbol(staticField, Decl(declarationEmitSimpleComputedNames1.ts, 9, 5)) + + return { static: "sometimes" }; +>static : Symbol(static, Decl(declarationEmitSimpleComputedNames1.ts, 21, 16)) + } +} + +/** + * Could be `"prototype"`, so all static string indexers include the instance type + */ +export const staticLookup = Holder["some" + "thing"]; +>staticLookup : Symbol(staticLookup, Decl(declarationEmitSimpleComputedNames1.ts, 28, 12)) +>Holder : Symbol(Holder, Decl(declarationEmitSimpleComputedNames1.ts, 9, 54)) + +export const instanceLookup = (new Holder())["some" + "thing"]; +>instanceLookup : Symbol(instanceLookup, Decl(declarationEmitSimpleComputedNames1.ts, 29, 12)) +>Holder : Symbol(Holder, Decl(declarationEmitSimpleComputedNames1.ts, 9, 54)) + diff --git a/tests/baselines/reference/declarationEmitSimpleComputedNames1.types b/tests/baselines/reference/declarationEmitSimpleComputedNames1.types new file mode 100644 index 0000000000000..773301e49e9d7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitSimpleComputedNames1.types @@ -0,0 +1,192 @@ +//// [tests/cases/compiler/declarationEmitSimpleComputedNames1.ts] //// + +=== declarationEmitSimpleComputedNames1.ts === +export const fieldName = Math.random() > 0.5 ? "f1" : "f2"; +>fieldName : "f1" | "f2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 ? "f1" : "f2" : "f1" | "f2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 : boolean +> : ^^^^^^^ +>Math.random() : number +> : ^^^^^^ +>Math.random : () => number +> : ^^^^^^ +>Math : Math +> : ^^^^ +>random : () => number +> : ^^^^^^ +>0.5 : 0.5 +> : ^^^ +>"f1" : "f1" +> : ^^^^ +>"f2" : "f2" +> : ^^^^ + +export const conatainer = { +>conatainer : { [fieldName]: () => string; } +> : ^^ ^^^^^^^^^^^^ ^^ +>{ [fieldName]() { return "result"; }} : { [fieldName]: () => string; } +> : ^^ ^^^^^^^^^^^^ ^^ + + [fieldName]() { +>[fieldName] : () => string +> : ^^^^^^^^^^^^ +>fieldName : "f1" | "f2" +> : ^^^^^^^^^^^ + + return "result"; +>"result" : "result" +> : ^^^^^^^^ + } +}; + +const classFieldName = Math.random() > 0.5 ? "g1" : "g2"; +>classFieldName : "g1" | "g2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 ? "g1" : "g2" : "g1" | "g2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 : boolean +> : ^^^^^^^ +>Math.random() : number +> : ^^^^^^ +>Math.random : () => number +> : ^^^^^^ +>Math : Math +> : ^^^^ +>random : () => number +> : ^^^^^^ +>0.5 : 0.5 +> : ^^^ +>"g1" : "g1" +> : ^^^^ +>"g2" : "g2" +> : ^^^^ + +const otherField = classFieldName === "g1" ? "g2" : "g1"; +>otherField : "g1" | "g2" +> : ^^^^^^^^^^^ +>classFieldName === "g1" ? "g2" : "g1" : "g1" | "g2" +> : ^^^^^^^^^^^ +>classFieldName === "g1" : boolean +> : ^^^^^^^ +>classFieldName : "g1" | "g2" +> : ^^^^^^^^^^^ +>"g1" : "g1" +> : ^^^^ +>"g2" : "g2" +> : ^^^^ +>"g1" : "g1" +> : ^^^^ + +const staticField = Math.random() > 0.5 ? "s1" : "s2"; +>staticField : "s1" | "s2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 ? "s1" : "s2" : "s1" | "s2" +> : ^^^^^^^^^^^ +>Math.random() > 0.5 : boolean +> : ^^^^^^^ +>Math.random() : number +> : ^^^^^^ +>Math.random : () => number +> : ^^^^^^ +>Math : Math +> : ^^^^ +>random : () => number +> : ^^^^^^ +>0.5 : 0.5 +> : ^^^ +>"s1" : "s1" +> : ^^^^ +>"s2" : "s2" +> : ^^^^ + +export class Holder { +>Holder : Holder +> : ^^^^^^ + + [classFieldName]() { +>[classFieldName] : () => string +> : ^^^^^^^^^^^^ +>classFieldName : "g1" | "g2" +> : ^^^^^^^^^^^ + + return "value"; +>"value" : "value" +> : ^^^^^^^ + } + [otherField]() { +>[otherField] : () => number +> : ^^^^^^^^^^^^ +>otherField : "g1" | "g2" +> : ^^^^^^^^^^^ + + return 42; +>42 : 42 +> : ^^ + } + static [staticField]() { +>[staticField] : () => { static: boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>staticField : "s1" | "s2" +> : ^^^^^^^^^^^ + + return { static: true }; +>{ static: true } : { static: boolean; } +> : ^^^^^^^^^^^^^^^^^^^^ +>static : boolean +> : ^^^^^^^ +>true : true +> : ^^^^ + } + static [staticField]() { +>[staticField] : () => { static: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>staticField : "s1" | "s2" +> : ^^^^^^^^^^^ + + return { static: "sometimes" }; +>{ static: "sometimes" } : { static: string; } +> : ^^^^^^^^^^^^^^^^^^^ +>static : string +> : ^^^^^^ +>"sometimes" : "sometimes" +> : ^^^^^^^^^^^ + } +} + +/** + * Could be `"prototype"`, so all static string indexers include the instance type + */ +export const staticLookup = Holder["some" + "thing"]; +>staticLookup : Holder | (() => { static: boolean; }) | (() => { static: string; }) +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Holder["some" + "thing"] : Holder | (() => { static: boolean; }) | (() => { static: string; }) +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Holder : typeof Holder +> : ^^^^^^^^^^^^^ +>"some" + "thing" : string +> : ^^^^^^ +>"some" : "some" +> : ^^^^^^ +>"thing" : "thing" +> : ^^^^^^^ + +export const instanceLookup = (new Holder())["some" + "thing"]; +>instanceLookup : (() => string) | (() => number) +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(new Holder())["some" + "thing"] : (() => string) | (() => number) +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(new Holder()) : Holder +> : ^^^^^^ +>new Holder() : Holder +> : ^^^^^^ +>Holder : typeof Holder +> : ^^^^^^^^^^^^^ +>"some" + "thing" : string +> : ^^^^^^ +>"some" : "some" +> : ^^^^^^ +>"thing" : "thing" +> : ^^^^^^^ + diff --git a/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt b/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt index 9648cb6502bf1..a035483e36f1a 100644 --- a/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt +++ b/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt @@ -1,9 +1,6 @@ decoratorsOnComputedProperties.ts(18,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(19,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(20,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(21,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(22,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(23,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(27,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(28,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(29,5): error TS1206: Decorators are not valid here. @@ -11,15 +8,11 @@ decoratorsOnComputedProperties.ts(30,5): error TS1206: Decorators are not valid decoratorsOnComputedProperties.ts(35,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(36,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(37,5): error TS1206: Decorators are not valid here. -decoratorsOnComputedProperties.ts(38,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(39,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(40,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(52,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(53,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(54,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(55,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(56,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(57,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(62,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(63,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(64,5): error TS1206: Decorators are not valid here. @@ -27,15 +20,11 @@ decoratorsOnComputedProperties.ts(65,5): error TS1206: Decorators are not valid decoratorsOnComputedProperties.ts(70,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(71,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(72,5): error TS1206: Decorators are not valid here. -decoratorsOnComputedProperties.ts(73,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(74,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(75,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(88,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(89,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(90,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(92,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(93,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(94,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(98,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(99,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(100,5): error TS1206: Decorators are not valid here. @@ -43,15 +32,11 @@ decoratorsOnComputedProperties.ts(101,5): error TS1206: Decorators are not valid decoratorsOnComputedProperties.ts(106,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(107,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(108,5): error TS1206: Decorators are not valid here. -decoratorsOnComputedProperties.ts(110,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(111,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(112,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(124,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(125,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(126,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(128,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(129,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(131,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(135,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(136,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(137,5): error TS1206: Decorators are not valid here. @@ -59,15 +44,11 @@ decoratorsOnComputedProperties.ts(138,5): error TS1206: Decorators are not valid decoratorsOnComputedProperties.ts(143,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(144,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(145,5): error TS1206: Decorators are not valid here. -decoratorsOnComputedProperties.ts(147,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(148,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(150,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(162,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(163,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(164,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(166,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(167,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -decoratorsOnComputedProperties.ts(169,8): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(173,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(174,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(175,5): error TS1206: Decorators are not valid here. @@ -76,12 +57,11 @@ decoratorsOnComputedProperties.ts(181,5): error TS1166: A computed property name decoratorsOnComputedProperties.ts(182,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(183,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(184,5): error TS1206: Decorators are not valid here. -decoratorsOnComputedProperties.ts(185,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. decoratorsOnComputedProperties.ts(186,5): error TS1206: Decorators are not valid here. decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid here. -==== decoratorsOnComputedProperties.ts (81 errors) ==== +==== decoratorsOnComputedProperties.ts (61 errors) ==== function x(o: object, k: PropertyKey) { } let i = 0; function foo(): string { return ++i + ""; } @@ -109,14 +89,8 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid ~~~~~~~ !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. } void class B { @@ -146,8 +120,6 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid ~ !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -175,14 +147,8 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid ~~~~~~~ !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ["some" + "method"]() {} } @@ -213,8 +179,6 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid ~ !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -244,14 +208,8 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ["some" + "method"]() {} [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. } void class F { @@ -282,8 +240,6 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid !!! error TS1206: Decorators are not valid here. ["some" + "method"]() {} [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -312,15 +268,9 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ["some" + "method"]() {} [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 have a simple literal type or a 'unique symbol' type. } void class H { @@ -351,8 +301,6 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid !!! error TS1206: Decorators are not valid here. ["some" + "method"]() {} [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -382,15 +330,9 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid !!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x ["some" + "method"]() {} [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 have a simple literal type or a 'unique symbol' type. } void class J { @@ -423,8 +365,6 @@ decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid ~ !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; - ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=es5).types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=es5).types index 36d767841dc12..d57b5e21b9e7c 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=es5).types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=es5).types @@ -36,16 +36,16 @@ const { [K.a]: aVal, [K.b]: bVal } = (() => { > : ^^^^^^ >bVal : number > : ^^^^^^ ->(() => { return { [K.a]: 1, [K.b]: 1 };})() : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->(() => { return { [K.a]: 1, [K.b]: 1 };}) : () => { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->() => { return { [K.a]: 1, [K.b]: 1 };} : () => { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(() => { return { [K.a]: 1, [K.b]: 1 };})() : { [K.a]: number; [K.b]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^^ +>(() => { return { [K.a]: 1, [K.b]: 1 };}) : () => { [K.a]: number; [K.b]: number; } +> : ^^^^^^^^ ^^^^^^ ^ ^^^^^^ ^^ +>() => { return { [K.a]: 1, [K.b]: 1 };} : () => { [K.a]: number; [K.b]: number; } +> : ^^^^^^^^ ^^^^^^ ^ ^^^^^^ ^^ return { [K.a]: 1, [K.b]: 1 }; ->{ [K.a]: 1, [K.b]: 1 } : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [K.a]: 1, [K.b]: 1 } : { [K.a]: number; [K.b]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^^ >[K.a] : number > : ^^^^^^ >K.a : string diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=esnext).types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=esnext).types index 36d767841dc12..d57b5e21b9e7c 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=esnext).types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment8(target=esnext).types @@ -36,16 +36,16 @@ const { [K.a]: aVal, [K.b]: bVal } = (() => { > : ^^^^^^ >bVal : number > : ^^^^^^ ->(() => { return { [K.a]: 1, [K.b]: 1 };})() : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->(() => { return { [K.a]: 1, [K.b]: 1 };}) : () => { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->() => { return { [K.a]: 1, [K.b]: 1 };} : () => { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(() => { return { [K.a]: 1, [K.b]: 1 };})() : { [K.a]: number; [K.b]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^^ +>(() => { return { [K.a]: 1, [K.b]: 1 };}) : () => { [K.a]: number; [K.b]: number; } +> : ^^^^^^^^ ^^^^^^ ^ ^^^^^^ ^^ +>() => { return { [K.a]: 1, [K.b]: 1 };} : () => { [K.a]: number; [K.b]: number; } +> : ^^^^^^^^ ^^^^^^ ^ ^^^^^^ ^^ return { [K.a]: 1, [K.b]: 1 }; ->{ [K.a]: 1, [K.b]: 1 } : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [K.a]: 1, [K.b]: 1 } : { [K.a]: number; [K.b]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^^ >[K.a] : number > : ^^^^^^ >K.a : string diff --git a/tests/baselines/reference/duplicateObjectLiteralProperty_computedNameNegative1.types b/tests/baselines/reference/duplicateObjectLiteralProperty_computedNameNegative1.types index 439a70c9aefbb..3502ce16af34e 100644 --- a/tests/baselines/reference/duplicateObjectLiteralProperty_computedNameNegative1.types +++ b/tests/baselines/reference/duplicateObjectLiteralProperty_computedNameNegative1.types @@ -49,8 +49,8 @@ function bar(props: { x?: string; y?: string }) { } function foo({ x = "", y = "" }: { x?: string; y?: string }) { ->foo : ({ x, y }: { x?: string; y?: string; }) => { [x: string]: number; } -> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>foo : ({ x, y }: { x?: string; y?: string; }) => { [x]: number; [y]: number; } +> : ^ ^^ ^^^^^^^ ^^^^^^ ^ ^^^^^^ ^^ >x : string > : ^^^^^^ >"" : "" @@ -65,8 +65,8 @@ function foo({ x = "", y = "" }: { x?: string; y?: string }) { > : ^^^^^^^^^^^^^^^^^^ return { ->{ [x]: 1, [y]: 2, } : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [x]: 1, [y]: 2, } : { [x]: number; [y]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^ ^^ [x]: 1, >[x] : number diff --git a/tests/baselines/reference/es5-asyncFunctionObjectLiterals.types b/tests/baselines/reference/es5-asyncFunctionObjectLiterals.types index 13fb970b13c87..5440253681124 100644 --- a/tests/baselines/reference/es5-asyncFunctionObjectLiterals.types +++ b/tests/baselines/reference/es5-asyncFunctionObjectLiterals.types @@ -84,11 +84,11 @@ async function objectLiteral3() { > : ^^^^^^^^^^^^^^^^^^^ x = { ->x = { [a]: await y, b: z } : { [x: number]: any; b: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x = { [a]: await y, b: z } : { [a]: any; b: any; } +> : ^^ ^^^ ^^^^^^^^^^ >x : any ->{ [a]: await y, b: z } : { [x: number]: any; b: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [a]: await y, b: z } : { [a]: any; b: any; } +> : ^^ ^^^ ^^^^^^^^^^ [a]: await y, >[a] : any @@ -108,11 +108,11 @@ async function objectLiteral4() { > : ^^^^^^^^^^^^^^^^^^^ x = { ->x = { a: await y, [b]: z } : { [x: number]: any; a: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x = { a: await y, [b]: z } : { [b]: any; a: any; } +> : ^^ ^^^ ^^^^^^^^^^ >x : any ->{ a: await y, [b]: z } : { [x: number]: any; a: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ a: await y, [b]: z } : { [b]: any; a: any; } +> : ^^ ^^^ ^^^^^^^^^^ a: await y, >a : any @@ -156,11 +156,11 @@ async function objectLiteral6() { > : ^^^^^^^^^^^^^^^^^^^ x = { ->x = { a: y, [b]: await z } : { [x: number]: any; a: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x = { a: y, [b]: await z } : { [b]: any; a: any; } +> : ^^ ^^^ ^^^^^^^^^^ >x : any ->{ a: y, [b]: await z } : { [x: number]: any; a: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ a: y, [b]: await z } : { [b]: any; a: any; } +> : ^^ ^^^ ^^^^^^^^^^ a: y, >a : any diff --git a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedAutoAccessor.errors.txt b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedAutoAccessor.errors.txt index 06bccfaa9217d..b898766dbb070 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedAutoAccessor.errors.txt +++ b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedAutoAccessor.errors.txt @@ -1,10 +1,9 @@ main.ts(8,5): error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(8,5): error TS2343: This syntax requires an imported helper named '__propKey' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(8,5): error TS2343: This syntax requires an imported helper named '__runInitializers' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -main.ts(8,26): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -==== main.ts (4 errors) ==== +==== main.ts (3 errors) ==== export {} declare var dec: any; @@ -19,8 +18,6 @@ main.ts(8,26): error TS1166: A computed property name in a class property declar !!! error TS2343: This syntax requires an imported helper named '__propKey' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. ~~~~ !!! error TS2343: This syntax requires an imported helper named '__runInitializers' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. } ==== tslib.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedField.errors.txt b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedField.errors.txt index 3eb65c8280788..d08a1c6ef44be 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedField.errors.txt +++ b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-staticComputedField.errors.txt @@ -1,10 +1,9 @@ main.ts(8,5): error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(8,5): error TS2343: This syntax requires an imported helper named '__propKey' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(8,5): error TS2343: This syntax requires an imported helper named '__runInitializers' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -main.ts(8,17): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. -==== main.ts (4 errors) ==== +==== main.ts (3 errors) ==== export {} declare var dec: any; @@ -19,8 +18,6 @@ main.ts(8,17): error TS1166: A computed property name in a class property declar !!! error TS2343: This syntax requires an imported helper named '__propKey' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. ~~~~ !!! error TS2343: This syntax requires an imported helper named '__runInitializers' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. } ==== tslib.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.errors.txt b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.errors.txt index 62c7f82b6d1c9..ee9cd74f912e2 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.errors.txt +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.errors.txt @@ -1,19 +1,16 @@ -main.ts(6,11): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. main.ts(6,17): error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(6,17): error TS2343: This syntax requires an imported helper named '__propKey' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(6,17): error TS2343: This syntax requires an imported helper named '__runInitializers' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(6,17): error TS2343: This syntax requires an imported helper named '__setFunctionName' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -==== main.ts (5 errors) ==== +==== main.ts (4 errors) ==== export {}; declare var dec: any; declare var x: any; // uses __esDecorate, __runInitializers, __setFunctionName, __propKey class C { [x] = @dec class {} } - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ~~~~ !!! error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. ~~~~ diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index d8dcbc68bf3d1..268ca3698bb88 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,17 +1,13 @@ -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. indexSignatureMustHaveTypeAnnotation.ts(3,6): error TS2304: Cannot find name 'x'. indexSignatureMustHaveTypeAnnotation.ts(4,5): error TS1021: An index signature must have a type annotation. -indexSignatureMustHaveTypeAnnotation.ts(9,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. indexSignatureMustHaveTypeAnnotation.ts(9,6): error TS2304: Cannot find name 'x'. indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021: An index signature must have a type annotation. -==== indexSignatureMustHaveTypeAnnotation.ts (6 errors) ==== +==== indexSignatureMustHaveTypeAnnotation.ts (4 errors) ==== interface I { // 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 TS2304: Cannot find name 'x'. [x: string]; @@ -22,8 +18,6 @@ indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021: An index signature class C { // Used to be indexer, now it is a computed property [x]: string - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. diff --git a/tests/baselines/reference/indexSignatures1.types b/tests/baselines/reference/indexSignatures1.types index f33d4ebdf16eb..8dff518b5679a 100644 --- a/tests/baselines/reference/indexSignatures1.types +++ b/tests/baselines/reference/indexSignatures1.types @@ -1564,8 +1564,8 @@ type A = Record; const a: A = { [id]: 'test' } >a : A > : ^ ->{ [id]: 'test' } : { [x: string]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [id]: 'test' } : { [id]: string; } +> : ^^ ^^^^^^ ^^ >[id] : string > : ^^^^^^ >id : `${number}-${number}-${number}-${number}` diff --git a/tests/baselines/reference/indexWithoutParamType2.errors.txt b/tests/baselines/reference/indexWithoutParamType2.errors.txt index c44ef69c03b45..322a5cb854bc0 100644 --- a/tests/baselines/reference/indexWithoutParamType2.errors.txt +++ b/tests/baselines/reference/indexWithoutParamType2.errors.txt @@ -1,13 +1,10 @@ -indexWithoutParamType2.ts(3,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. indexWithoutParamType2.ts(3,6): error TS2304: Cannot find name 'x'. -==== indexWithoutParamType2.ts (2 errors) ==== +==== indexWithoutParamType2.ts (1 errors) ==== class C { // Used to be indexer, now it is a computed property [x]: string - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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/isolatedDeclarationErrorsClasses.errors.txt b/tests/baselines/reference/isolatedDeclarationErrorsClasses.errors.txt index 32bd70436499d..7e9b2904f7a2e 100644 --- a/tests/baselines/reference/isolatedDeclarationErrorsClasses.errors.txt +++ b/tests/baselines/reference/isolatedDeclarationErrorsClasses.errors.txt @@ -7,21 +7,21 @@ isolatedDeclarationErrorsClasses.ts(11,9): error TS9009: At least one accessor m isolatedDeclarationErrorsClasses.ts(12,9): error TS7032: Property 'setOnly' implicitly has type 'any', because its set accessor lacks a parameter type annotation. isolatedDeclarationErrorsClasses.ts(12,17): error TS7006: Parameter 'value' implicitly has an 'any' type. isolatedDeclarationErrorsClasses.ts(12,17): error TS9009: At least one accessor must have an explicit type annotation with --isolatedDeclarations. -isolatedDeclarationErrorsClasses.ts(36,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. isolatedDeclarationErrorsClasses.ts(36,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(36,6): error TS2304: Cannot find name 'missing'. isolatedDeclarationErrorsClasses.ts(38,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(40,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. +isolatedDeclarationErrorsClasses.ts(42,5): error TS9008: Method must have an explicit return type annotation with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(42,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(44,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(44,35): error TS7006: Parameter 'v' implicitly has an 'any' type. +isolatedDeclarationErrorsClasses.ts(44,35): error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(46,9): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(48,9): error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation. isolatedDeclarationErrorsClasses.ts(48,9): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. isolatedDeclarationErrorsClasses.ts(48,39): error TS7006: Parameter 'value' implicitly has an 'any' type. isolatedDeclarationErrorsClasses.ts(50,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. isolatedDeclarationErrorsClasses.ts(50,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. -isolatedDeclarationErrorsClasses.ts(55,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. isolatedDeclarationErrorsClasses.ts(56,5): error TS7010: '[noAnnotationLiteralName]', which lacks return-type annotation, implicitly has an 'any' return type. isolatedDeclarationErrorsClasses.ts(56,5): error TS9013: Expression type can't be inferred with --isolatedDeclarations. @@ -88,8 +88,6 @@ isolatedDeclarationErrorsClasses.ts(56,5): error TS9013: Expression type can't b // Should not be reported as an isolated declaration error [missing] = 1; ~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. - ~~~~~~~~~ !!! error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. ~~~~~~~ !!! error TS2304: Cannot find name 'missing'. @@ -104,6 +102,9 @@ isolatedDeclarationErrorsClasses.ts(56,5): error TS9013: Expression type can't b [noAnnotationStringName]() { } ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS9008: Method must have an explicit return type annotation with --isolatedDeclarations. +!!! related TS9034 isolatedDeclarationErrorsClasses.ts:42:5: Add a return type to the method + ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. [noParamAnnotationStringName](v): void { } @@ -111,6 +112,9 @@ isolatedDeclarationErrorsClasses.ts(56,5): error TS9013: Expression type can't b !!! error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. ~ !!! error TS7006: Parameter 'v' implicitly has an 'any' type. + ~ +!!! error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations. +!!! related TS9028 isolatedDeclarationErrorsClasses.ts:44:35: Add a type annotation to the parameter v. get [noAnnotationStringName]() { return 0;} ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -134,8 +138,6 @@ isolatedDeclarationErrorsClasses.ts(56,5): error TS9013: Expression type can't b export interface I { [noAnnotationStringName]: 10; - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! 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. [noAnnotationLiteralName](); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS7010: '[noAnnotationLiteralName]', which lacks return-type annotation, implicitly has an 'any' return type. diff --git a/tests/baselines/reference/overloadsWithComputedNames.errors.txt b/tests/baselines/reference/overloadsWithComputedNames.errors.txt index 018a56183254c..f737574398768 100644 --- a/tests/baselines/reference/overloadsWithComputedNames.errors.txt +++ b/tests/baselines/reference/overloadsWithComputedNames.errors.txt @@ -1,15 +1,11 @@ overloadsWithComputedNames.ts(4,5): error TS2389: Function implementation name must be '["B"]'. overloadsWithComputedNames.ts(14,5): error TS2391: Function implementation is missing or not immediately following the declaration. overloadsWithComputedNames.ts(16,5): error TS2389: Function implementation name must be '["bar"]'. -overloadsWithComputedNames.ts(28,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. overloadsWithComputedNames.ts(29,5): error TS2391: Function implementation is missing or not immediately following the declaration. -overloadsWithComputedNames.ts(35,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. -overloadsWithComputedNames.ts(42,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. -overloadsWithComputedNames.ts(47,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. overloadsWithComputedNames.ts(52,5): error TS2391: Function implementation is missing or not immediately following the declaration. -==== overloadsWithComputedNames.ts (9 errors) ==== +==== overloadsWithComputedNames.ts (5 errors) ==== // https://github.com/microsoft/TypeScript/issues/52329 class Person { ["B"](a: number): string; @@ -44,8 +40,6 @@ overloadsWithComputedNames.ts(52,5): error TS2391: Function implementation is mi class C1 { [sym](): void; // should error - ~~~~~ -!!! 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. [uniqueSym2](): void; // should error ~~~~~~~~~~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. @@ -55,8 +49,6 @@ overloadsWithComputedNames.ts(52,5): error TS2391: Function implementation is mi interface I1 { [sym](): void; // should error - ~~~~~ -!!! 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. [uniqueSym2](): void; [uniqueSym](): void; [uniqueSym](): void; @@ -64,15 +56,11 @@ overloadsWithComputedNames.ts(52,5): error TS2391: Function implementation is mi class C2 { [strUnion](): void; // should error - ~~~~~~~~~~ -!!! 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. [strUnion]() { } } class I2 { [strUnion](): void; // should error - ~~~~~~~~~~ -!!! 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. [strUnion]() { } } diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js index 9066e8c7d57a3..22e2a11cfe682 100644 --- a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=false).js @@ -31,19 +31,19 @@ class Derived3 extends Base3 { //// [overrideDynamicName1.d.ts] declare let prop: string; declare class Base1 { - [x: string]: () => void; + [prop]: () => void; } declare class Derived1 extends Base1 { - [x: string]: () => void; + [prop]: () => void; } declare class Base2 { - [x: string]: () => void; + [prop]: () => void; } declare class Derived2 extends Base2 { - [x: string]: () => void; + [prop]: () => void; } declare class Base3 { } declare class Derived3 extends Base3 { - [x: string]: () => void; + [prop]: () => void; } diff --git a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js index 9066e8c7d57a3..22e2a11cfe682 100644 --- a/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js +++ b/tests/baselines/reference/overrideDynamicName1(noimplicitoverride=true).js @@ -31,19 +31,19 @@ class Derived3 extends Base3 { //// [overrideDynamicName1.d.ts] declare let prop: string; declare class Base1 { - [x: string]: () => void; + [prop]: () => void; } declare class Derived1 extends Base1 { - [x: string]: () => void; + [prop]: () => void; } declare class Base2 { - [x: string]: () => void; + [prop]: () => void; } declare class Derived2 extends Base2 { - [x: string]: () => void; + [prop]: () => void; } declare class Base3 { } declare class Derived3 extends Base3 { - [x: string]: () => void; + [prop]: () => void; } diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js index d02cbd16d47ea..17d12eb6de30e 100644 --- a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=false).js @@ -31,19 +31,19 @@ class Derived3 extends Base3 { //// [overrideLateBindableIndexSignature1.d.ts] declare const sym: symbol; declare class Base1 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Derived1 extends Base1 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Base2 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Derived2 extends Base2 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Base3 { } declare class Derived3 extends Base3 { - [x: symbol]: () => void; + [sym]: () => void; } diff --git a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js index d02cbd16d47ea..17d12eb6de30e 100644 --- a/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js +++ b/tests/baselines/reference/overrideLateBindableIndexSignature1(noimplicitoverride=true).js @@ -31,19 +31,19 @@ class Derived3 extends Base3 { //// [overrideLateBindableIndexSignature1.d.ts] declare const sym: symbol; declare class Base1 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Derived1 extends Base1 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Base2 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Derived2 extends Base2 { - [x: symbol]: () => void; + [sym]: () => void; } declare class Base3 { } declare class Derived3 extends Base3 { - [x: symbol]: () => void; + [sym]: () => void; } diff --git a/tests/baselines/reference/parserComputedPropertyName10.errors.txt b/tests/baselines/reference/parserComputedPropertyName10.errors.txt index 32fbe013596b7..741471e54aa3b 100644 --- a/tests/baselines/reference/parserComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName10.errors.txt @@ -1,12 +1,9 @@ -parserComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName10.ts (2 errors) ==== +==== parserComputedPropertyName10.ts (1 errors) ==== class C { [e] = 1 - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 cfe94442ffdc4..4dfe2f9d82f99 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,12 +1,9 @@ -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. parserComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName11.ts (2 errors) ==== +==== parserComputedPropertyName11.ts (1 errors) ==== 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 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 69b30e2c35da2..53c44acb4a038 100644 --- a/tests/baselines/reference/parserComputedPropertyName13.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -1,10 +1,7 @@ -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. parserComputedPropertyName13.ts(1,11): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName13.ts (2 errors) ==== +==== parserComputedPropertyName13.ts (1 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 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 3136843bcf21e..5c6ae269c428e 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,10 +1,7 @@ -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. parserComputedPropertyName14.ts(1,11): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName14.ts (2 errors) ==== +==== parserComputedPropertyName14.ts (1 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 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 29736f6b09a37..227273a64d931 100644 --- a/tests/baselines/reference/parserComputedPropertyName15.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -1,10 +1,7 @@ -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. parserComputedPropertyName15.ts(1,32): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName15.ts (2 errors) ==== +==== parserComputedPropertyName15.ts (1 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 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 2397af84fb33d..0d22c4cd91d5b 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,10 +1,7 @@ -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. parserComputedPropertyName18.ts(1,11): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName18.ts (2 errors) ==== +==== parserComputedPropertyName18.ts (1 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 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 5be905e3aa0c8..5210616149d80 100644 --- a/tests/baselines/reference/parserComputedPropertyName19.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -1,10 +1,7 @@ -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. parserComputedPropertyName19.ts(1,11): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName19.ts (2 errors) ==== +==== parserComputedPropertyName19.ts (1 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 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 d29e06ed30261..b7030748fe180 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,12 +1,9 @@ -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. parserComputedPropertyName20.ts(2,6): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName20.ts (2 errors) ==== +==== parserComputedPropertyName20.ts (1 errors) ==== 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 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 d45641eaf3212..2af44eefc8c89 100644 --- a/tests/baselines/reference/parserComputedPropertyName21.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -1,12 +1,9 @@ -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. parserComputedPropertyName21.ts(2,6): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName21.ts (2 errors) ==== +==== parserComputedPropertyName21.ts (1 errors) ==== 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 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 684b9b0fb5866..d17736855f574 100644 --- a/tests/baselines/reference/parserComputedPropertyName22.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName22.errors.txt @@ -1,12 +1,9 @@ -parserComputedPropertyName22.ts(2,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName22.ts(2,6): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName22.ts (2 errors) ==== +==== parserComputedPropertyName22.ts (1 errors) ==== declare class C { [e]: number - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 01abebb9877e6..36df2f0397386 100644 --- a/tests/baselines/reference/parserComputedPropertyName25.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName25.errors.txt @@ -1,14 +1,11 @@ -parserComputedPropertyName25.ts(3,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName25.ts(3,6): error TS2304: Cannot find name 'e'. parserComputedPropertyName25.ts(4,6): error TS2304: Cannot find name 'e2'. -==== parserComputedPropertyName25.ts (3 errors) ==== +==== parserComputedPropertyName25.ts (2 errors) ==== class C { // No ASI [e] = 0 - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 91c6094a7bbc9..c9df8537bbc27 100644 --- a/tests/baselines/reference/parserComputedPropertyName28.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName28.errors.txt @@ -1,19 +1,13 @@ -parserComputedPropertyName28.ts(2,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName28.ts(2,6): error TS2304: Cannot find name 'e'. -parserComputedPropertyName28.ts(3,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName28.ts(3,6): error TS2304: Cannot find name 'e2'. -==== parserComputedPropertyName28.ts (4 errors) ==== +==== parserComputedPropertyName28.ts (2 errors) ==== class C { [e]: number = 0; - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 have a simple 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 86ae960157e5a..400a280cf2106 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -1,23 +1,17 @@ -parserComputedPropertyName29.ts(3,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName29.ts(3,6): error TS2304: Cannot find name 'e'. parserComputedPropertyName29.ts(3,11): error TS2304: Cannot find name 'id'. -parserComputedPropertyName29.ts(4,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName29.ts(4,6): error TS2304: Cannot find name 'e2'. -==== parserComputedPropertyName29.ts (5 errors) ==== +==== parserComputedPropertyName29.ts (3 errors) ==== class C { // yes ASI [e] = id++ - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 have a simple 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 eb373b7f4fc39..da4a580e9d7b4 100644 --- a/tests/baselines/reference/parserComputedPropertyName31.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName31.errors.txt @@ -1,20 +1,14 @@ -parserComputedPropertyName31.ts(3,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName31.ts(3,6): error TS2304: Cannot find name 'e'. -parserComputedPropertyName31.ts(4,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName31.ts(4,6): error TS2304: Cannot find name 'e2'. -==== parserComputedPropertyName31.ts (4 errors) ==== +==== parserComputedPropertyName31.ts (2 errors) ==== class C { // yes ASI [e]: number - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 have a simple 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 8afa1a90c81f0..969e09b6e6b74 100644 --- a/tests/baselines/reference/parserComputedPropertyName32.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -1,12 +1,9 @@ -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. parserComputedPropertyName32.ts(2,6): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName32.ts (2 errors) ==== +==== parserComputedPropertyName32.ts (1 errors) ==== 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 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 93f41eafb388d..9232b4dc95a41 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName36.errors.txt @@ -1,13 +1,10 @@ -parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName36.ts(2,6): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. parserComputedPropertyName36.ts(2,6): error TS2304: Cannot find name 'public'. -==== parserComputedPropertyName36.ts (3 errors) ==== +==== parserComputedPropertyName36.ts (2 errors) ==== class C { [public ]: string; - ~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 4e8af831f3b0c..0f2e575c27ae2 100644 --- a/tests/baselines/reference/parserComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName7.errors.txt @@ -1,12 +1,9 @@ -parserComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName7.ts (2 errors) ==== +==== parserComputedPropertyName7.ts (1 errors) ==== class C { [e] - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 4e78253d918d4..aeecc4322a5bd 100644 --- a/tests/baselines/reference/parserComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName8.errors.txt @@ -1,12 +1,9 @@ -parserComputedPropertyName8.ts(2,11): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName8.ts(2,12): error TS2304: Cannot find name 'e'. -==== parserComputedPropertyName8.ts (2 errors) ==== +==== parserComputedPropertyName8.ts (1 errors) ==== class C { public [e] - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 514b4f14a9776..f51501e848aaa 100644 --- a/tests/baselines/reference/parserComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName9.errors.txt @@ -1,13 +1,10 @@ -parserComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. parserComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. -==== parserComputedPropertyName9.ts (3 errors) ==== +==== parserComputedPropertyName9.ts (2 errors) ==== class C { [e]: Type - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 96fd1db3465ed..63fbb6b4237cb 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt @@ -1,12 +1,9 @@ -parserES5ComputedPropertyName1.ts(2,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserES5ComputedPropertyName1.ts(2,6): error TS2304: Cannot find name 'e'. -==== parserES5ComputedPropertyName1.ts (2 errors) ==== +==== parserES5ComputedPropertyName1.ts (1 errors) ==== declare class C { [e]: number - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 9f48af31a775d..be53362605576 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt @@ -1,12 +1,9 @@ -parserES5ComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserES5ComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. -==== parserES5ComputedPropertyName10.ts (2 errors) ==== +==== parserES5ComputedPropertyName10.ts (1 errors) ==== class C { [e] = 1 - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 479c01d727dd5..d216c821625d2 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,12 +1,9 @@ -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. parserES5ComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. -==== parserES5ComputedPropertyName11.ts (2 errors) ==== +==== parserES5ComputedPropertyName11.ts (1 errors) ==== 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 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 f9e5ce838b77d..c54d1e44b5f8f 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -1,12 +1,9 @@ -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. parserES5ComputedPropertyName5.ts(2,6): error TS2304: Cannot find name 'e'. -==== parserES5ComputedPropertyName5.ts (2 errors) ==== +==== parserES5ComputedPropertyName5.ts (1 errors) ==== 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 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 7ef1fabb0c7f5..bffd87321cbac 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt @@ -1,12 +1,9 @@ -parserES5ComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserES5ComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. -==== parserES5ComputedPropertyName7.ts (2 errors) ==== +==== parserES5ComputedPropertyName7.ts (1 errors) ==== class C { [e] - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple 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 4f2851d8e837c..2295c143ba179 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -1,10 +1,7 @@ -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. parserES5ComputedPropertyName8.ts(1,11): error TS2304: Cannot find name 'e'. -==== parserES5ComputedPropertyName8.ts (2 errors) ==== +==== parserES5ComputedPropertyName8.ts (1 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 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 b5733d2d06e28..361313645c7ee 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt @@ -1,13 +1,10 @@ -parserES5ComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserES5ComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. parserES5ComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. -==== parserES5ComputedPropertyName9.ts (3 errors) ==== +==== parserES5ComputedPropertyName9.ts (2 errors) ==== class C { [e]: Type - ~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. ~~~~ diff --git a/tests/baselines/reference/parserES5SymbolProperty1.errors.txt b/tests/baselines/reference/parserES5SymbolProperty1.errors.txt index 97784e12e11e7..17c9069cbc669 100644 --- a/tests/baselines/reference/parserES5SymbolProperty1.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty1.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty1.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. parserES5SymbolProperty1.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty1.ts (2 errors) ==== +==== parserES5SymbolProperty1.ts (1 errors) ==== interface I { [Symbol.iterator]: 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 TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolProperty2.errors.txt b/tests/baselines/reference/parserES5SymbolProperty2.errors.txt index 16fff8a5de664..547a3c8f0b422 100644 --- a/tests/baselines/reference/parserES5SymbolProperty2.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty2.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty2.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. parserES5SymbolProperty2.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty2.ts (2 errors) ==== +==== parserES5SymbolProperty2.ts (1 errors) ==== interface I { [Symbol.unscopables](): 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 TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolProperty3.errors.txt b/tests/baselines/reference/parserES5SymbolProperty3.errors.txt index 1dc35398595e6..36a420d067dcb 100644 --- a/tests/baselines/reference/parserES5SymbolProperty3.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty3.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty3.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. parserES5SymbolProperty3.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty3.ts (2 errors) ==== +==== parserES5SymbolProperty3.ts (1 errors) ==== declare class C { [Symbol.unscopables](): string; - ~~~~~~~~~~~~~~~~~~~~ -!!! 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 TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolProperty4.errors.txt b/tests/baselines/reference/parserES5SymbolProperty4.errors.txt index 733aea6decf07..d2dbaed5761ec 100644 --- a/tests/baselines/reference/parserES5SymbolProperty4.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty4.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty4.ts(2,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserES5SymbolProperty4.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty4.ts (2 errors) ==== +==== parserES5SymbolProperty4.ts (1 errors) ==== declare class C { [Symbol.isRegExp]: string; - ~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ~~~~~~ !!! error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolProperty5.errors.txt b/tests/baselines/reference/parserES5SymbolProperty5.errors.txt index c1c4d7fb49de8..cc04ef7048e61 100644 --- a/tests/baselines/reference/parserES5SymbolProperty5.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty5.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty5.ts(2,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserES5SymbolProperty5.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty5.ts (2 errors) ==== +==== parserES5SymbolProperty5.ts (1 errors) ==== class C { [Symbol.isRegExp]: string; - ~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ~~~~~~ !!! error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolProperty6.errors.txt b/tests/baselines/reference/parserES5SymbolProperty6.errors.txt index 8b37ebc18ac3a..8bd6ad8e5f074 100644 --- a/tests/baselines/reference/parserES5SymbolProperty6.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty6.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty6.ts(2,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. parserES5SymbolProperty6.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty6.ts (2 errors) ==== +==== parserES5SymbolProperty6.ts (1 errors) ==== class C { [Symbol.toStringTag]: string = ""; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. ~~~~~~ !!! error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolProperty8.errors.txt b/tests/baselines/reference/parserES5SymbolProperty8.errors.txt index a1fd554227adc..fbab2b7b28e74 100644 --- a/tests/baselines/reference/parserES5SymbolProperty8.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty8.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty8.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. parserES5SymbolProperty8.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty8.ts (2 errors) ==== +==== parserES5SymbolProperty8.ts (1 errors) ==== var x: { [Symbol.toPrimitive](): string - ~~~~~~~~~~~~~~~~~~~~ -!!! 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 TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolProperty9.errors.txt b/tests/baselines/reference/parserES5SymbolProperty9.errors.txt index 680c9da3816fe..ee9a898bef6b9 100644 --- a/tests/baselines/reference/parserES5SymbolProperty9.errors.txt +++ b/tests/baselines/reference/parserES5SymbolProperty9.errors.txt @@ -1,12 +1,9 @@ -parserES5SymbolProperty9.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. parserES5SymbolProperty9.ts(2,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. -==== parserES5SymbolProperty9.ts (2 errors) ==== +==== parserES5SymbolProperty9.ts (1 errors) ==== var x: { [Symbol.toPrimitive]: string - ~~~~~~~~~~~~~~~~~~~~ -!!! 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 TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature11.errors.txt b/tests/baselines/reference/parserIndexSignature11.errors.txt index 8a129399db711..3e95b906714b6 100644 --- a/tests/baselines/reference/parserIndexSignature11.errors.txt +++ b/tests/baselines/reference/parserIndexSignature11.errors.txt @@ -1,14 +1,11 @@ -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. parserIndexSignature11.ts(2,10): error TS2304: Cannot find name 'p'. parserIndexSignature11.ts(3,9): error TS1021: An index signature must have a type annotation. parserIndexSignature11.ts(4,10): error TS1096: An index signature must have exactly one parameter. -==== parserIndexSignature11.ts (4 errors) ==== +==== parserIndexSignature11.ts (3 errors) ==== 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 TS2304: Cannot find name 'p'. [p1: string]; diff --git a/tests/baselines/reference/parserIndexSignature5.errors.txt b/tests/baselines/reference/parserIndexSignature5.errors.txt index 9ce3a68de66f9..9648dfc73e26d 100644 --- a/tests/baselines/reference/parserIndexSignature5.errors.txt +++ b/tests/baselines/reference/parserIndexSignature5.errors.txt @@ -1,12 +1,9 @@ -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. parserIndexSignature5.ts(2,4): error TS2304: Cannot find name 'a'. -==== parserIndexSignature5.ts (2 errors) ==== +==== parserIndexSignature5.ts (1 errors) ==== 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 TS2304: Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/privateIndexer2.types b/tests/baselines/reference/privateIndexer2.types index 5a677679be881..56c2517372e82 100644 --- a/tests/baselines/reference/privateIndexer2.types +++ b/tests/baselines/reference/privateIndexer2.types @@ -6,8 +6,8 @@ var x = { >x : any > : ^^^ ->{ private [x: string]: string;} : { [x: number]: any; string: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ private [x: string]: string;} : { [x]: any; string: any; } +> : ^^ ^^^ ^^^^^^^^^^^^^^^ private [x: string]: string; >[x : any diff --git a/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types b/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types index b52272a38b3d3..c1c4ed9ed2c8c 100644 --- a/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types +++ b/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types @@ -30,15 +30,15 @@ function Multimap(ik, iv) { // without type annotation this._map2 = { [ik]: iv }; ->this._map2 = { [ik]: iv } : { [x: string]: V; } -> : ^^^^^^^^^^^^^^^^^^^ +>this._map2 = { [ik]: iv } : { [ik]: V; } +> : ^^ ^ ^^ >this._map2 : any >this : this > : ^^^^ >_map2 : any > : ^^^ ->{ [ik]: iv } : { [x: string]: V; } -> : ^^^^^^^^^^^^^^^^^^^ +>{ [ik]: iv } : { [ik]: V; } +> : ^^ ^ ^^ >[ik] : V > : ^ >ik : string diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index f7ec925652e22..fd64c78a5b3d2 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,4 +1,3 @@ -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. propertyAssignment.ts(4,14): error TS2304: Cannot find name 'index'. 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'. @@ -6,13 +5,11 @@ propertyAssignment.ts(14,1): error TS2322: Type '{ x: number; }' is not assignab Type '{ x: number; }' provides no match for the signature '(): void'. -==== propertyAssignment.ts (4 errors) ==== +==== propertyAssignment.ts (3 errors) ==== var foo1: { new ():any; } var bar1: { x : number; } 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 TS2304: Cannot find name 'index'. var bar2: { x : number; } diff --git a/tests/baselines/reference/spreadInvalidArgumentType.types b/tests/baselines/reference/spreadInvalidArgumentType.types index d1d64b92fee1b..a739136eea56a 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.types +++ b/tests/baselines/reference/spreadInvalidArgumentType.types @@ -105,7 +105,7 @@ function f(p1: T, p2: T[]) { > : ^ var o2 = { ...p2 }; // OK ->o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>o2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^ ^^^ ^^^^^^^^^^^^^ ^^^^ ^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^ ^^^^^ ^^^ ^^^ ^^^^^^^^ ^^^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^ ^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^ ^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^ ^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^ ^^^^^^ ^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^ >{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^ ^^^ ^^^^^^^^^^^^^ ^^^^ ^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^ ^^^^^ ^^^ ^^^ ^^^^^^^^ ^^^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^ ^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^ ^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^ ^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^ ^^^^^^ ^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ ^^^^^ ^^ ^^ ^^^^^^^^^^^^^ ^^^^^^^^^^ diff --git a/tests/baselines/reference/symbolProperty1.types b/tests/baselines/reference/symbolProperty1.types index 5c01d231afea3..b7e4b384472ad 100644 --- a/tests/baselines/reference/symbolProperty1.types +++ b/tests/baselines/reference/symbolProperty1.types @@ -6,10 +6,10 @@ var s: symbol; > : ^^^^^^ var x = { ->x : { [x: symbol]: number | (() => void); } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [s]: 0, [s]() { }, get [s]() { return 0; }} : { [x: symbol]: number | (() => void); } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { [s]: number; [s]: () => void; [s]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^^^^^ ^ ^^^^^^ ^^ +>{ [s]: 0, [s]() { }, get [s]() { return 0; }} : { [s]: number; [s]: () => void; [s]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^^^^^ ^ ^^^^^^ ^^ [s]: 0, >[s] : number diff --git a/tests/baselines/reference/symbolProperty2.types b/tests/baselines/reference/symbolProperty2.types index ac2ae475176ce..04f5ac5075af5 100644 --- a/tests/baselines/reference/symbolProperty2.types +++ b/tests/baselines/reference/symbolProperty2.types @@ -10,10 +10,10 @@ var s = Symbol(); > : ^^^^^^^^^^^^^^^^^ var x = { ->x : { [x: symbol]: number | (() => void); } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [s]: 0, [s]() { }, get [s]() { return 0; }} : { [x: symbol]: number | (() => void); } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { [s]: number; [s]: () => void; [s]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^^^^^ ^ ^^^^^^ ^^ +>{ [s]: 0, [s]() { }, get [s]() { return 0; }} : { [s]: number; [s]: () => void; [s]: number; } +> : ^^ ^^^^^^ ^ ^^^^^^^^^^ ^ ^^^^^^ ^^ [s]: 0, >[s] : number diff --git a/tests/baselines/reference/symbolProperty52.types b/tests/baselines/reference/symbolProperty52.types index c28ae737470bb..bdc3468c6a734 100644 --- a/tests/baselines/reference/symbolProperty52.types +++ b/tests/baselines/reference/symbolProperty52.types @@ -2,10 +2,10 @@ === symbolProperty52.ts === var obj = { ->obj : { [x: number]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [Symbol.nonsense]: 0} : { [x: number]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>obj : { [Symbol.nonsense]: number; } +> : ^^ ^^^^^^ ^^ +>{ [Symbol.nonsense]: 0} : { [Symbol.nonsense]: number; } +> : ^^ ^^^^^^ ^^ [Symbol.nonsense]: 0 >[Symbol.nonsense] : number @@ -24,16 +24,16 @@ var obj = { obj = {}; >obj = {} : {} > : ^^ ->obj : { [x: number]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>obj : { [Symbol.nonsense]: number; } +> : ^^ ^^^^^^ ^^ >{} : {} > : ^^ obj[Symbol.nonsense]; >obj[Symbol.nonsense] : number > : ^^^^^^ ->obj : { [x: number]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>obj : { [Symbol.nonsense]: number; } +> : ^^ ^^^^^^ ^^ >Symbol.nonsense : any > : ^^^ >Symbol : SymbolConstructor diff --git a/tests/baselines/reference/symbolProperty58.types b/tests/baselines/reference/symbolProperty58.types index e987e5dd34152..40cec15acc7a1 100644 --- a/tests/baselines/reference/symbolProperty58.types +++ b/tests/baselines/reference/symbolProperty58.types @@ -8,10 +8,10 @@ interface SymbolConstructor { } var obj = { ->obj : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->{ [Symbol.foo]: 0} : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>obj : { [Symbol.foo]: number; } +> : ^^ ^^^^^^ ^^ +>{ [Symbol.foo]: 0} : { [Symbol.foo]: number; } +> : ^^ ^^^^^^ ^^ [Symbol.foo]: 0 >[Symbol.foo] : number diff --git a/tests/baselines/reference/symbolProperty59.errors.txt b/tests/baselines/reference/symbolProperty59.errors.txt index 8886ebb7360a6..fae26a075ea03 100644 --- a/tests/baselines/reference/symbolProperty59.errors.txt +++ b/tests/baselines/reference/symbolProperty59.errors.txt @@ -1,12 +1,9 @@ -symbolProperty59.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. symbolProperty59.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== symbolProperty59.ts (2 errors) ==== +==== symbolProperty59.ts (1 errors) ==== interface I { [Symbol.keyFor]: 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 TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. } \ No newline at end of file diff --git a/tests/baselines/reference/transformParenthesizesConditionalSubexpression.types b/tests/baselines/reference/transformParenthesizesConditionalSubexpression.types index d60f73fbf2e52..1ffd170d76a8a 100644 --- a/tests/baselines/reference/transformParenthesizesConditionalSubexpression.types +++ b/tests/baselines/reference/transformParenthesizesConditionalSubexpression.types @@ -8,20 +8,20 @@ var K = 'k' > : ^^^ var a = { p : (true ? { [K] : 'v'} : null) } ->a : { p: { [x: string]: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ p : (true ? { [K] : 'v'} : null) } : { p: { [x: string]: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->p : { [x: string]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->(true ? { [K] : 'v'} : null) : { [x: string]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ ->true ? { [K] : 'v'} : null : { [x: string]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>a : { p: { [K]: string; }; } +> : ^^^^^^^ ^^^^^^ ^^^^^ +>{ p : (true ? { [K] : 'v'} : null) } : { p: { [K]: string; }; } +> : ^^^^^^^ ^^^^^^ ^^^^^ +>p : { [K]: string; } +> : ^^ ^^^^^^ ^^ +>(true ? { [K] : 'v'} : null) : { [K]: string; } +> : ^^ ^^^^^^ ^^ +>true ? { [K] : 'v'} : null : { [K]: string; } +> : ^^ ^^^^^^ ^^ >true : true > : ^^^^ ->{ [K] : 'v'} : { [x: string]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [K] : 'v'} : { [K]: string; } +> : ^^ ^^^^^^ ^^ >[K] : string > : ^^^^^^ >K : string @@ -40,8 +40,8 @@ var b = { p : (true ? { [K] : 'v'} as any : null) } >true : true > : ^^^^ >{ [K] : 'v'} as any : any ->{ [K] : 'v'} : { [x: string]: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ [K] : 'v'} : { [K]: string; } +> : ^^ ^^^^^^ ^^ >[K] : string > : ^^^^^^ >K : string diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types index 0bcb6fc9eb882..3e34cb5174cba 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types @@ -208,8 +208,8 @@ export function T9(a: any, b: any, c: any, d: any) { > : ^^^^^^ >"T9" : "T9" > : ^^^^ ->{ [__proto__]: null } : { [x: string]: null; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ [__proto__]: null } : { [__proto__]: null; } +> : ^^ ^^^^ ^^ >[__proto__] : null > : ^^^^ >__proto__ : string diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types index 0bcb6fc9eb882..3e34cb5174cba 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types @@ -208,8 +208,8 @@ export function T9(a: any, b: any, c: any, d: any) { > : ^^^^^^ >"T9" : "T9" > : ^^^^ ->{ [__proto__]: null } : { [x: string]: null; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ [__proto__]: null } : { [__proto__]: null; } +> : ^^ ^^^^ ^^ >[__proto__] : null > : ^^^^ >__proto__ : string diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types index 0bcb6fc9eb882..3e34cb5174cba 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types @@ -208,8 +208,8 @@ export function T9(a: any, b: any, c: any, d: any) { > : ^^^^^^ >"T9" : "T9" > : ^^^^ ->{ [__proto__]: null } : { [x: string]: null; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ [__proto__]: null } : { [__proto__]: null; } +> : ^^ ^^^^ ^^ >[__proto__] : null > : ^^^^ >__proto__ : string diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types index bb23f0c415629..42e8b670c4453 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types @@ -239,8 +239,8 @@ export function T10(a: any, b: any, c: any, d: any) { > : ^^^^^^ >"T10" : "T10" > : ^^^^^ ->{ [__proto__]: null } : { [x: string]: null; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ [__proto__]: null } : { [__proto__]: null; } +> : ^^ ^^^^ ^^ >[__proto__] : null > : ^^^^ >__proto__ : string diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types index bb23f0c415629..42e8b670c4453 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types @@ -239,8 +239,8 @@ export function T10(a: any, b: any, c: any, d: any) { > : ^^^^^^ >"T10" : "T10" > : ^^^^^ ->{ [__proto__]: null } : { [x: string]: null; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ [__proto__]: null } : { [__proto__]: null; } +> : ^^ ^^^^ ^^ >[__proto__] : null > : ^^^^ >__proto__ : string diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types index bb23f0c415629..42e8b670c4453 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types @@ -239,8 +239,8 @@ export function T10(a: any, b: any, c: any, d: any) { > : ^^^^^^ >"T10" : "T10" > : ^^^^^ ->{ [__proto__]: null } : { [x: string]: null; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ [__proto__]: null } : { [__proto__]: null; } +> : ^^ ^^^^ ^^ >[__proto__] : null > : ^^^^ >__proto__ : string diff --git a/tests/baselines/reference/typeUsedAsTypeLiteralIndex.errors.txt b/tests/baselines/reference/typeUsedAsTypeLiteralIndex.errors.txt index b9b206d89061e..844865d1a7e7f 100644 --- a/tests/baselines/reference/typeUsedAsTypeLiteralIndex.errors.txt +++ b/tests/baselines/reference/typeUsedAsTypeLiteralIndex.errors.txt @@ -1,19 +1,13 @@ -typeUsedAsTypeLiteralIndex.ts(3,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. typeUsedAsTypeLiteralIndex.ts(3,6): error TS2690: 'K' only refers to a type, but is being used as a value here. Did you mean to use 'P in K'? -typeUsedAsTypeLiteralIndex.ts(13,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. typeUsedAsTypeLiteralIndex.ts(13,6): error TS2690: 'K2' only refers to a type, but is being used as a value here. Did you mean to use 'K in K2'? -typeUsedAsTypeLiteralIndex.ts(18,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. typeUsedAsTypeLiteralIndex.ts(18,6): error TS2690: 'K3' only refers to a type, but is being used as a value here. Did you mean to use 'K in K3'? -typeUsedAsTypeLiteralIndex.ts(23,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. typeUsedAsTypeLiteralIndex.ts(23,6): error TS2693: 'K4' only refers to a type, but is being used as a value here. -==== typeUsedAsTypeLiteralIndex.ts (8 errors) ==== +==== typeUsedAsTypeLiteralIndex.ts (4 errors) ==== type K = number | string; type T = { [K]: number; // Did you mean to use 'P in K'? - ~~~ -!!! 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 TS2690: 'K' only refers to a type, but is being used as a value here. Did you mean to use 'P in K'? } @@ -26,8 +20,6 @@ typeUsedAsTypeLiteralIndex.ts(23,6): error TS2693: 'K4' only refers to a type, b type K2 = "x" | "y"; type T2 = { [K2]: number; // Did you mean to use 'K in K2'? - ~~~~ -!!! 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 TS2690: 'K2' only refers to a type, but is being used as a value here. Did you mean to use 'K in K2'? } @@ -35,8 +27,6 @@ typeUsedAsTypeLiteralIndex.ts(23,6): error TS2693: 'K4' only refers to a type, b type K3 = number | string; type T3 = { [K3]: number; // Did you mean to use 'K in K3'? - ~~~~ -!!! 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 TS2690: 'K3' only refers to a type, but is being used as a value here. Did you mean to use 'K in K3'? } @@ -44,8 +34,6 @@ typeUsedAsTypeLiteralIndex.ts(23,6): error TS2693: 'K4' only refers to a type, b type K4 = number | string; type T4 = { [K4]: 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 TS2693: 'K4' only refers to a type, but is being used as a value here. k4: string; diff --git a/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.types b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.types index 2e85bb726478d..7a898b8424909 100644 --- a/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.types +++ b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.types @@ -113,8 +113,8 @@ class D { > : ^ ...{get [D.D]() {return 0;}} // should be an error ->{get [D.D]() {return 0;}} : { [x: string]: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>{get [D.D]() {return 0;}} : { [D.D]: number; } +> : ^^ ^^^^^^ ^^ >[D.D] : number > : ^^^^^^ >D.D : string diff --git a/tests/cases/compiler/declarationEmitComputedNameWithQuestionToken.ts b/tests/cases/compiler/declarationEmitComputedNameWithQuestionToken.ts new file mode 100644 index 0000000000000..88062b0c314ee --- /dev/null +++ b/tests/cases/compiler/declarationEmitComputedNameWithQuestionToken.ts @@ -0,0 +1,12 @@ +//@declaration: true + +declare var something: string; +export const dataSomething = `data-${something}` as const; + +export class WithData { + [dataSomething]?() { + return "something"; + } +} + +export const a = (new WithData())["ahahahaahah"]!(); \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitComputedNamesInaccessible.ts b/tests/cases/compiler/declarationEmitComputedNamesInaccessible.ts new file mode 100644 index 0000000000000..06ec83b4a5056 --- /dev/null +++ b/tests/cases/compiler/declarationEmitComputedNamesInaccessible.ts @@ -0,0 +1,20 @@ +// @declaration: true +export function f1() { + const localClassFieldName = Math.random() > 0.5 ? "g1" : "g2"; + const localOtherField = localClassFieldName === "g1" ? "g2" : "g1"; + const localStaticField = Math.random() > 0.5 ? "s1" : "s2"; + return class ParameterizedHolder { + [localClassFieldName]() { + return "value"; + } + [localOtherField]() { + return 42; + } + static [localStaticField]() { + return { static: true }; + } + static [localStaticField]() { + return { static: "sometimes" }; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitMultipleComputedNamesSameDomain.ts b/tests/cases/compiler/declarationEmitMultipleComputedNamesSameDomain.ts new file mode 100644 index 0000000000000..ca073c63c5e9c --- /dev/null +++ b/tests/cases/compiler/declarationEmitMultipleComputedNamesSameDomain.ts @@ -0,0 +1,8 @@ +// @declaration: true +declare const x: string; +declare const y: "y"; + +export class Test { + [x] = 10; + [y] = 10; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitSimpleComputedNames1.ts b/tests/cases/compiler/declarationEmitSimpleComputedNames1.ts new file mode 100644 index 0000000000000..19ca35b2da3ab --- /dev/null +++ b/tests/cases/compiler/declarationEmitSimpleComputedNames1.ts @@ -0,0 +1,32 @@ +// @declaration: true + +export const fieldName = Math.random() > 0.5 ? "f1" : "f2"; +export const conatainer = { + [fieldName]() { + return "result"; + } +}; + +const classFieldName = Math.random() > 0.5 ? "g1" : "g2"; +const otherField = classFieldName === "g1" ? "g2" : "g1"; +const staticField = Math.random() > 0.5 ? "s1" : "s2"; +export class Holder { + [classFieldName]() { + return "value"; + } + [otherField]() { + return 42; + } + static [staticField]() { + return { static: true }; + } + static [staticField]() { + return { static: "sometimes" }; + } +} + +/** + * Could be `"prototype"`, so all static string indexers include the instance type + */ +export const staticLookup = Holder["some" + "thing"]; +export const instanceLookup = (new Holder())["some" + "thing"];