From a08b045d2b22c87a6341a0c1d1318271d14acc86 Mon Sep 17 00:00:00 2001 From: Danay <60160912+danay1999@users.noreply.github.com> Date: Thu, 25 Aug 2022 11:57:32 -0700 Subject: [PATCH] Jsdoc property description (#50269) * jsdocPropertyDescription * jsdocPropertyDescription * jsdocPropertyDescription * Fixes #47933 * added additional test * added additional example * fixed bug * changed function to only grab the literal type * added additional condition for literals and symbols * added additional test cases * Update src/services/symbolDisplay.ts Co-authored-by: Andrew Branch * addressed PR review * addressed new PR review Co-authored-by: Danay Fernandez Alfonso Co-authored-by: Andrew Branch --- src/compiler/checker.ts | 30 ++++++++++++++++ src/compiler/types.ts | 2 ++ src/services/symbolDisplay.ts | 36 ++++++++++++++++--- .../reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + .../controlFlowElementAccess2.symbols | 6 ++++ .../reference/controlFlowStringIndex.symbols | 6 ++++ ...essionMustBeOptional(strict=false).symbols | 4 +++ ...ressionMustBeOptional(strict=true).symbols | 4 +++ ...(exactoptionalpropertytypes=false).symbols | 4 +++ ...s(exactoptionalpropertytypes=true).symbols | 4 +++ ...iteralExpressionInArrowFunctionES5.symbols | 2 ++ ...iteralExpressionInArrowFunctionES6.symbols | 2 ++ .../reference/indexSignatures1.symbols | 2 ++ .../reference/keyofAndIndexedAccess2.symbols | 4 +++ ...oPropertyAccessFromIndexSignature1.symbols | 6 ++++ .../noUncheckedIndexedAccess.symbols | 6 ++++ ...ertyAccessOfReadonlyIndexSignature.symbols | 2 ++ ...propertyAccessStringIndexSignature.symbols | 6 ++++ ...sStringIndexSignatureNoImplicitAny.symbols | 6 ++++ .../reference/staticIndexSignature1.symbols | 2 ++ .../reference/staticIndexSignature2.symbols | 2 ++ .../reference/staticIndexSignature4.symbols | 24 +++++++++++++ .../reference/staticIndexSignature6.symbols | 4 +++ .../reference/thisTypeInFunctions2.symbols | 4 +++ ...typeGuardOfFromPropNameInUnionType.symbols | 6 ++++ .../fourslash/jsDocPropertyDescription1.ts | 15 ++++++++ .../fourslash/jsDocPropertyDescription10.ts | 11 ++++++ .../fourslash/jsDocPropertyDescription11.ts | 13 +++++++ .../fourslash/jsDocPropertyDescription12.ts | 11 ++++++ .../fourslash/jsDocPropertyDescription2.ts | 11 ++++++ .../fourslash/jsDocPropertyDescription3.ts | 13 +++++++ .../fourslash/jsDocPropertyDescription4.ts | 11 ++++++ .../fourslash/jsDocPropertyDescription5.ts | 11 ++++++ .../fourslash/jsDocPropertyDescription6.ts | 16 +++++++++ .../fourslash/jsDocPropertyDescription7.ts | 11 ++++++ .../fourslash/jsDocPropertyDescription8.ts | 11 ++++++ .../fourslash/jsDocPropertyDescription9.ts | 17 +++++++++ 38 files changed, 322 insertions(+), 5 deletions(-) create mode 100644 tests/cases/fourslash/jsDocPropertyDescription1.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription10.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription11.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription12.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription2.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription3.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription4.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription5.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription6.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription7.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription8.ts create mode 100644 tests/cases/fourslash/jsDocPropertyDescription9.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b7564a95fad59..0999b8b4eb030 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -439,6 +439,7 @@ namespace ts { getTypeOfPropertyOfType: (type, name) => getTypeOfPropertyOfType(type, escapeLeadingUnderscores(name)), getIndexInfoOfType: (type, kind) => getIndexInfoOfType(type, kind === IndexKind.String ? stringType : numberType), getIndexInfosOfType, + getIndexInfosOfIndexSymbol, getSignaturesOfType, getIndexTypeOfType: (type, kind) => getIndexTypeOfType(type, kind === IndexKind.String ? stringType : numberType), getIndexType: type => getIndexType(type), @@ -42615,6 +42616,35 @@ namespace ts { if (name.kind === SyntaxKind.PropertyAccessExpression) { checkPropertyAccessExpression(name, CheckMode.Normal); + if (!links.resolvedSymbol) { + const expressionType = checkExpressionCached(name.expression); + const infos = getApplicableIndexInfos(expressionType, getLiteralTypeFromPropertyName(name.name)); + if (infos.length && (expressionType as ObjectType).members) { + const resolved = resolveStructuredTypeMembers(expressionType as ObjectType); + const symbol = resolved.members.get(InternalSymbolName.Index); + if (infos === getIndexInfosOfType(expressionType)) { + links.resolvedSymbol = symbol; + } + else if (symbol) { + const symbolLinks = getSymbolLinks(symbol); + const declarationList = mapDefined(infos, i => i.declaration); + const nodeListId = map(declarationList, getNodeId).join(","); + if (!symbolLinks.filteredIndexSymbolCache) { + symbolLinks.filteredIndexSymbolCache = new Map(); + } + if (symbolLinks.filteredIndexSymbolCache.has(nodeListId)) { + links.resolvedSymbol = symbolLinks.filteredIndexSymbolCache.get(nodeListId)!; + } + else { + const copy = createSymbol(SymbolFlags.Signature, InternalSymbolName.Index); + copy.declarations = mapDefined(infos, i => i.declaration); + copy.parent = expressionType.aliasSymbol ? expressionType.aliasSymbol : expressionType.symbol ? expressionType.symbol : getSymbolAtLocation(copy.declarations[0].parent); + symbolLinks.filteredIndexSymbolCache.set(nodeListId, copy); + links.resolvedSymbol = symbolLinks.filteredIndexSymbolCache.get(nodeListId)!; + } + } + } + } } else { checkQualifiedName(name, CheckMode.Normal); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a50ce161f660a..73fefe7637525 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4557,6 +4557,7 @@ namespace ts { /* @internal */ getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; getIndexInfosOfType(type: Type): readonly IndexInfo[]; + getIndexInfosOfIndexSymbol: (indexSymbol: Symbol) => IndexInfo[]; getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; /* @internal */ getIndexType(type: Type): Type; @@ -5373,6 +5374,7 @@ namespace ts { isConstructorDeclaredProperty?: boolean; // Property declared through 'this.x = ...' assignment in constructor tupleLabelDeclaration?: NamedTupleMember | ParameterDeclaration; // Declaration associated with the tuple's label accessibleChainCache?: ESMap; + filteredIndexSymbolCache?: ESMap //Symbol with applicable declarations } /* @internal */ diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 973e28476b6a5..44113d901572e 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -64,6 +64,7 @@ namespace ts.SymbolDisplay { if (flags & SymbolFlags.SetAccessor) return ScriptElementKind.memberSetAccessorElement; if (flags & SymbolFlags.Method) return ScriptElementKind.memberFunctionElement; if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; + if (flags & SymbolFlags.Signature) return ScriptElementKind.indexSignatureElement; if (flags & SymbolFlags.Property) { if (flags & SymbolFlags.Transient && (symbol as TransientSymbol).checkFlags & CheckFlags.Synthetic) { @@ -506,7 +507,6 @@ namespace ts.SymbolDisplay { else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } - // For properties, variables and local vars: show the type if (symbolKind === ScriptElementKind.memberVariableElement || symbolKind === ScriptElementKind.memberGetAccessorElement || @@ -514,11 +514,12 @@ namespace ts.SymbolDisplay { symbolKind === ScriptElementKind.jsxAttribute || symbolFlags & SymbolFlags.Variable || symbolKind === ScriptElementKind.localVariableElement || + symbolKind === ScriptElementKind.indexSignatureElement || isThisExpression) { displayParts.push(punctuationPart(SyntaxKind.ColonToken)); displayParts.push(spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter) { + if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter && symbolKind !== ScriptElementKind.indexSignatureElement) { const typeParameterParts = mapToDisplayParts(writer => { const param = typeChecker.typeParameterToDeclaration(type as TypeParameter, enclosingDeclaration, symbolDisplayNodeBuilderFlags)!; getPrinter().writeNode(EmitHint.Unspecified, param, getSourceFileOfNode(getParseTreeNode(enclosingDeclaration)), writer); @@ -639,13 +640,38 @@ namespace ts.SymbolDisplay { } function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node) { + let indexInfos; + if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - const fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, - SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind); - addRange(displayParts, fullSymbolDisplayParts); + if (symbolKind === ScriptElementKind.indexSignatureElement) { + indexInfos = typeChecker.getIndexInfosOfIndexSymbol(symbolToDisplay); + } + let fullSymbolDisplayParts: SymbolDisplayPart[] = []; + if (symbolToDisplay.flags & SymbolFlags.Signature && indexInfos) { + if (symbolToDisplay.parent) { + fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay.parent); + } + fullSymbolDisplayParts.push(punctuationPart(SyntaxKind.OpenBracketToken)); + //Needed to handle more than one type of index + indexInfos.forEach((info, i) => { + //Needed to handle template literals + fullSymbolDisplayParts.push(...typeToDisplayParts(typeChecker, info.keyType)); + if (i !== indexInfos.length - 1) { + fullSymbolDisplayParts.push(spacePart()); + fullSymbolDisplayParts.push(punctuationPart(SyntaxKind.BarToken)); + fullSymbolDisplayParts.push(spacePart()); + } + }); + fullSymbolDisplayParts.push(punctuationPart(SyntaxKind.CloseBracketToken)); + } + else { + fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, + SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind); + } + addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & SymbolFlags.Optional) { displayParts.push(punctuationPart(SyntaxKind.QuestionToken)); } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5f5edb8b2c10b..89e52380ac983 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2316,6 +2316,7 @@ declare namespace ts { getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; getIndexInfosOfType(type: Type): readonly IndexInfo[]; + getIndexInfosOfIndexSymbol: (indexSymbol: Symbol) => IndexInfo[]; getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 85470b6407cbe..1a135d9fcba4a 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2316,6 +2316,7 @@ declare namespace ts { getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; getIndexInfosOfType(type: Type): readonly IndexInfo[]; + getIndexInfosOfIndexSymbol: (indexSymbol: Symbol) => IndexInfo[]; getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; diff --git a/tests/baselines/reference/controlFlowElementAccess2.symbols b/tests/baselines/reference/controlFlowElementAccess2.symbols index 5cdd890a75973..6768df75f0f3c 100644 --- a/tests/baselines/reference/controlFlowElementAccess2.symbols +++ b/tests/baselines/reference/controlFlowElementAccess2.symbols @@ -13,7 +13,9 @@ if (typeof config['works'] !== 'boolean') { config.works.prop = 'test'; // ok >config.works.prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +>config.works : Symbol(__index, Decl(controlFlowElementAccess2.ts, 0, 23)) >config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) +>works : Symbol(__index, Decl(controlFlowElementAccess2.ts, 0, 23)) >prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } @@ -22,7 +24,9 @@ if (typeof config['works'] !== 'boolean') { >prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) } if (typeof config.works !== 'boolean') { +>config.works : Symbol(__index, Decl(controlFlowElementAccess2.ts, 0, 23)) >config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) +>works : Symbol(__index, Decl(controlFlowElementAccess2.ts, 0, 23)) config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } >config['works'].prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) @@ -31,7 +35,9 @@ if (typeof config.works !== 'boolean') { config.works.prop = 'test'; // ok >config.works.prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +>config.works : Symbol(__index, Decl(controlFlowElementAccess2.ts, 0, 23)) >config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) +>works : Symbol(__index, Decl(controlFlowElementAccess2.ts, 0, 23)) >prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) } diff --git a/tests/baselines/reference/controlFlowStringIndex.symbols b/tests/baselines/reference/controlFlowStringIndex.symbols index 85eacfd0ede7b..caeadd01d0e3e 100644 --- a/tests/baselines/reference/controlFlowStringIndex.symbols +++ b/tests/baselines/reference/controlFlowStringIndex.symbols @@ -14,11 +14,15 @@ declare const value: A; >A : Symbol(A, Decl(controlFlowStringIndex.ts, 0, 0)) if (value.foo !== null) { +>value.foo : Symbol(A.__index, Decl(controlFlowStringIndex.ts, 1, 25)) >value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13)) +>foo : Symbol(A.__index, Decl(controlFlowStringIndex.ts, 1, 25)) value.foo.toExponential() >value.foo.toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --)) +>value.foo : Symbol(A.__index, Decl(controlFlowStringIndex.ts, 1, 25)) >value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13)) +>foo : Symbol(A.__index, Decl(controlFlowStringIndex.ts, 1, 25)) >toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --)) value.other // should still be number | null @@ -27,6 +31,8 @@ if (value.foo !== null) { >other : Symbol(other, Decl(controlFlowStringIndex.ts, 0, 10)) value.bar // should still be number | null +>value.bar : Symbol(A.__index, Decl(controlFlowStringIndex.ts, 1, 25)) >value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13)) +>bar : Symbol(A.__index, Decl(controlFlowStringIndex.ts, 1, 25)) } diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols index aad7423a133ad..0fdd656cdbde5 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols @@ -105,10 +105,14 @@ delete f.j >f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) delete b.a >b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols index aad7423a133ad..0fdd656cdbde5 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols @@ -105,10 +105,14 @@ delete f.j >f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) delete b.a >b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).symbols index 86df5a00f1fa0..175c6caf9e271 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).symbols +++ b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).symbols @@ -158,10 +158,14 @@ delete g.j >g : Symbol(g, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 21, 13)) delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 22, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 22, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) delete b.a >b : Symbol(b, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 23, 13)) diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).symbols index 86df5a00f1fa0..175c6caf9e271 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).symbols +++ b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).symbols @@ -158,10 +158,14 @@ delete g.j >g : Symbol(g, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 21, 13)) delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 22, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) >a : Symbol(a, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 22, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 12, 14)) delete b.a >b : Symbol(b, Decl(deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts, 23, 13)) diff --git a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.symbols b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.symbols index ae5c2b4d71c78..2dbc0d3122862 100644 --- a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.symbols +++ b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.symbols @@ -8,7 +8,9 @@ (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x; >x : Symbol(x, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts, 1, 1)) +>({ "1": "one", "2": "two" } as { [key: string]: string }).x : Symbol(__index, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts, 1, 39)) >"1" : Symbol("1", Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts, 1, 9)) >"2" : Symbol("2", Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts, 1, 21)) >key : Symbol(key, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts, 1, 41)) +>x : Symbol(__index, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts, 1, 39)) diff --git a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.symbols b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.symbols index 77ed54addd964..e3735b9987e79 100644 --- a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.symbols +++ b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.symbols @@ -8,7 +8,9 @@ (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x; >x : Symbol(x, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts, 1, 1)) +>({ "1": "one", "2": "two" } as { [key: string]: string }).x : Symbol(__index, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts, 1, 39)) >"1" : Symbol("1", Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts, 1, 9)) >"2" : Symbol("2", Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts, 1, 21)) >key : Symbol(key, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts, 1, 41)) +>x : Symbol(__index, Decl(emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts, 1, 39)) diff --git a/tests/baselines/reference/indexSignatures1.symbols b/tests/baselines/reference/indexSignatures1.symbols index 40d8740b1b7b2..dab1d380df72b 100644 --- a/tests/baselines/reference/indexSignatures1.symbols +++ b/tests/baselines/reference/indexSignatures1.symbols @@ -133,7 +133,9 @@ const y1 = dom['data123']; const y2 = dom.data123; >y2 : Symbol(y2, Decl(indexSignatures1.ts, 47, 5)) +>dom.data123 : Symbol(__index, Decl(indexSignatures1.ts, 45, 18)) >dom : Symbol(dom, Decl(indexSignatures1.ts, 45, 11)) +>data123 : Symbol(__index, Decl(indexSignatures1.ts, 45, 18)) // Excess property checking for template pattern index signature diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.symbols b/tests/baselines/reference/keyofAndIndexedAccess2.symbols index a17aafe571aa5..b773011935e1a 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess2.symbols @@ -90,7 +90,9 @@ function f2(a: { x: number, y: number }, b: >x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 12, 53)) b.x; +>b.x : Symbol(__index, Decl(keyofAndIndexedAccess2.ts, 12, 82)) >b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77)) +>x : Symbol(__index, Decl(keyofAndIndexedAccess2.ts, 12, 82)) c.x; >c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107)) @@ -105,7 +107,9 @@ function f2(a: { x: number, y: number }, b: >x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 12, 53)) b.x = 1; +>b.x : Symbol(__index, Decl(keyofAndIndexedAccess2.ts, 12, 82)) >b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77)) +>x : Symbol(__index, Decl(keyofAndIndexedAccess2.ts, 12, 82)) c.x = 1; // Error, cannot write to index signature through constraint >c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107)) diff --git a/tests/baselines/reference/noPropertyAccessFromIndexSignature1.symbols b/tests/baselines/reference/noPropertyAccessFromIndexSignature1.symbols index 993a7082251a1..3a9c347dfd419 100644 --- a/tests/baselines/reference/noPropertyAccessFromIndexSignature1.symbols +++ b/tests/baselines/reference/noPropertyAccessFromIndexSignature1.symbols @@ -51,7 +51,9 @@ a["foo"] // access index signature b.foo; +>b.foo : Symbol(B.__index, Decl(noPropertyAccessFromIndexSignature1.ts, 4, 13)) >b : Symbol(b, Decl(noPropertyAccessFromIndexSignature1.ts, 14, 13)) +>foo : Symbol(B.__index, Decl(noPropertyAccessFromIndexSignature1.ts, 4, 13)) b["foo"]; >b : Symbol(b, Decl(noPropertyAccessFromIndexSignature1.ts, 14, 13)) @@ -68,7 +70,9 @@ c["foo"] // access index signature c.bar; +>c.bar : Symbol(C.__index, Decl(noPropertyAccessFromIndexSignature1.ts, 9, 15)) >c : Symbol(c, Decl(noPropertyAccessFromIndexSignature1.ts, 15, 13)) +>bar : Symbol(C.__index, Decl(noPropertyAccessFromIndexSignature1.ts, 9, 15)) c["bar"]; >c : Symbol(c, Decl(noPropertyAccessFromIndexSignature1.ts, 15, 13)) @@ -85,7 +89,9 @@ d?.["foo"] // optional access index signature d?.bar; +>d?.bar : Symbol(C.__index, Decl(noPropertyAccessFromIndexSignature1.ts, 9, 15)) >d : Symbol(d, Decl(noPropertyAccessFromIndexSignature1.ts, 16, 13)) +>bar : Symbol(C.__index, Decl(noPropertyAccessFromIndexSignature1.ts, 9, 15)) d?.["bar"]; >d : Symbol(d, Decl(noPropertyAccessFromIndexSignature1.ts, 16, 13)) diff --git a/tests/baselines/reference/noUncheckedIndexedAccess.symbols b/tests/baselines/reference/noUncheckedIndexedAccess.symbols index 1b0eb6f4d5b63..e04c216d7fa1e 100644 --- a/tests/baselines/reference/noUncheckedIndexedAccess.symbols +++ b/tests/baselines/reference/noUncheckedIndexedAccess.symbols @@ -36,7 +36,9 @@ const e1: boolean = strMap["foo"]; const e2: boolean = strMap.bar; >e2 : Symbol(e2, Decl(noUncheckedIndexedAccess.ts, 12, 5)) +>strMap.bar : Symbol(__index, Decl(noUncheckedIndexedAccess.ts, 8, 23)) >strMap : Symbol(strMap, Decl(noUncheckedIndexedAccess.ts, 8, 13)) +>bar : Symbol(__index, Decl(noUncheckedIndexedAccess.ts, 8, 23)) const e3: boolean = strMap[0]; >e3 : Symbol(e3, Decl(noUncheckedIndexedAccess.ts, 13, 5)) @@ -114,7 +116,9 @@ const ok1: boolean | undefined = strMap["foo"]; const ok2: boolean | undefined = strMap.bar; >ok2 : Symbol(ok2, Decl(noUncheckedIndexedAccess.ts, 28, 5)) +>strMap.bar : Symbol(__index, Decl(noUncheckedIndexedAccess.ts, 8, 23)) >strMap : Symbol(strMap, Decl(noUncheckedIndexedAccess.ts, 8, 13)) +>bar : Symbol(__index, Decl(noUncheckedIndexedAccess.ts, 8, 23)) type T_OK1 = CheckBooleanOnly<(typeof strMap)[string]>; >T_OK1 : Symbol(T_OK1, Decl(noUncheckedIndexedAccess.ts, 28, 44)) @@ -147,7 +151,9 @@ strMap["baz"] = undefined; >undefined : Symbol(undefined) strMap.qua = undefined; +>strMap.qua : Symbol(__index, Decl(noUncheckedIndexedAccess.ts, 8, 23)) >strMap : Symbol(strMap, Decl(noUncheckedIndexedAccess.ts, 8, 13)) +>qua : Symbol(__index, Decl(noUncheckedIndexedAccess.ts, 8, 23)) >undefined : Symbol(undefined) strMap[0] = undefined; diff --git a/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.symbols b/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.symbols index fdb108c736227..ab8649993c04d 100644 --- a/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.symbols +++ b/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.symbols @@ -11,5 +11,7 @@ declare var a: Test; >Test : Symbol(Test, Decl(propertyAccessOfReadonlyIndexSignature.ts, 0, 0)) a.foo = 'baz'; +>a.foo : Symbol(Test.__index, Decl(propertyAccessOfReadonlyIndexSignature.ts, 0, 16)) >a : Symbol(a, Decl(propertyAccessOfReadonlyIndexSignature.ts, 4, 11)) +>foo : Symbol(Test.__index, Decl(propertyAccessOfReadonlyIndexSignature.ts, 0, 16)) diff --git a/tests/baselines/reference/propertyAccessStringIndexSignature.symbols b/tests/baselines/reference/propertyAccessStringIndexSignature.symbols index 8258ecb65d829..24f93a01ebae4 100644 --- a/tests/baselines/reference/propertyAccessStringIndexSignature.symbols +++ b/tests/baselines/reference/propertyAccessStringIndexSignature.symbols @@ -8,13 +8,19 @@ let flags: Flags; >Flags : Symbol(Flags, Decl(propertyAccessStringIndexSignature.ts, 0, 0)) flags.b; +>flags.b : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignature.ts, 0, 17)) >flags : Symbol(flags, Decl(propertyAccessStringIndexSignature.ts, 1, 3)) +>b : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignature.ts, 0, 17)) flags.f; +>flags.f : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignature.ts, 0, 17)) >flags : Symbol(flags, Decl(propertyAccessStringIndexSignature.ts, 1, 3)) +>f : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignature.ts, 0, 17)) flags.isNotNecessarilyNeverFalse; +>flags.isNotNecessarilyNeverFalse : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignature.ts, 0, 17)) >flags : Symbol(flags, Decl(propertyAccessStringIndexSignature.ts, 1, 3)) +>isNotNecessarilyNeverFalse : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignature.ts, 0, 17)) flags['this is fine']; >flags : Symbol(flags, Decl(propertyAccessStringIndexSignature.ts, 1, 3)) diff --git a/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.symbols b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.symbols index 338f0650cce4c..98f95b4c1ea14 100644 --- a/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.symbols +++ b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.symbols @@ -8,13 +8,19 @@ let flags: Flags; >Flags : Symbol(Flags, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 0, 0)) flags.b; +>flags.b : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 0, 17)) >flags : Symbol(flags, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 1, 3)) +>b : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 0, 17)) flags.f; +>flags.f : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 0, 17)) >flags : Symbol(flags, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 1, 3)) +>f : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 0, 17)) flags.isNotNecessarilyNeverFalse; +>flags.isNotNecessarilyNeverFalse : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 0, 17)) >flags : Symbol(flags, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 1, 3)) +>isNotNecessarilyNeverFalse : Symbol(Flags.__index, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 0, 17)) flags['this is fine']; >flags : Symbol(flags, Decl(propertyAccessStringIndexSignatureNoImplicitAny.ts, 1, 3)) diff --git a/tests/baselines/reference/staticIndexSignature1.symbols b/tests/baselines/reference/staticIndexSignature1.symbols index b672f4e22a7e2..a12c00ccb056a 100644 --- a/tests/baselines/reference/staticIndexSignature1.symbols +++ b/tests/baselines/reference/staticIndexSignature1.symbols @@ -13,7 +13,9 @@ C["foo"] = 1 >C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) C.bar = 2; +>C.bar : Symbol(C.__index, Decl(staticIndexSignature1.ts, 0, 9)) >C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) +>bar : Symbol(C.__index, Decl(staticIndexSignature1.ts, 0, 9)) const foo = C["foo"] >foo : Symbol(foo, Decl(staticIndexSignature1.ts, 7, 5)) diff --git a/tests/baselines/reference/staticIndexSignature2.symbols b/tests/baselines/reference/staticIndexSignature2.symbols index abbf36f9733b4..8adb9e8785024 100644 --- a/tests/baselines/reference/staticIndexSignature2.symbols +++ b/tests/baselines/reference/staticIndexSignature2.symbols @@ -13,7 +13,9 @@ C["foo"] = 1 >C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) C.bar = 2; +>C.bar : Symbol(C.__index, Decl(staticIndexSignature2.ts, 0, 9)) >C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) +>bar : Symbol(C.__index, Decl(staticIndexSignature2.ts, 0, 9)) const foo = C["foo"] >foo : Symbol(foo, Decl(staticIndexSignature2.ts, 7, 5)) diff --git a/tests/baselines/reference/staticIndexSignature4.symbols b/tests/baselines/reference/staticIndexSignature4.symbols index 198b01bc80288..3257d2e3c2fe0 100644 --- a/tests/baselines/reference/staticIndexSignature4.symbols +++ b/tests/baselines/reference/staticIndexSignature4.symbols @@ -40,8 +40,12 @@ if (v === 0) { >v : Symbol(v, Decl(staticIndexSignature4.ts, 15, 13)) B.a = D.a +>B.a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) >B : Symbol(B, Decl(staticIndexSignature4.ts, 0, 0)) +>a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) +>D.a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) >D : Symbol(D, Decl(staticIndexSignature4.ts, 3, 1)) +>a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) B[2] = D[2] >B : Symbol(B, Decl(staticIndexSignature4.ts, 0, 0)) @@ -51,8 +55,12 @@ if (v === 0) { >v : Symbol(v, Decl(staticIndexSignature4.ts, 15, 13)) D.a = B.a +>D.a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) >D : Symbol(D, Decl(staticIndexSignature4.ts, 3, 1)) +>a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) +>B.a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) >B : Symbol(B, Decl(staticIndexSignature4.ts, 0, 0)) +>a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) D[2] = B[2] >D : Symbol(D, Decl(staticIndexSignature4.ts, 3, 1)) @@ -62,16 +70,24 @@ if (v === 0) { >v : Symbol(v, Decl(staticIndexSignature4.ts, 15, 13)) B.a = i.a +>B.a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) >B : Symbol(B, Decl(staticIndexSignature4.ts, 0, 0)) +>a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) +>i.a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) >i : Symbol(i, Decl(staticIndexSignature4.ts, 16, 13)) +>a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) B[2] = i[2] >B : Symbol(B, Decl(staticIndexSignature4.ts, 0, 0)) >i : Symbol(i, Decl(staticIndexSignature4.ts, 16, 13)) D.a = i.a +>D.a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) >D : Symbol(D, Decl(staticIndexSignature4.ts, 3, 1)) +>a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) +>i.a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) >i : Symbol(i, Decl(staticIndexSignature4.ts, 16, 13)) +>a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) D[2] = i [2] >D : Symbol(D, Decl(staticIndexSignature4.ts, 3, 1)) @@ -81,8 +97,12 @@ if (v === 0) { >v : Symbol(v, Decl(staticIndexSignature4.ts, 15, 13)) i.a = B.a +>i.a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) >i : Symbol(i, Decl(staticIndexSignature4.ts, 16, 13)) +>a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) +>B.a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) >B : Symbol(B, Decl(staticIndexSignature4.ts, 0, 0)) +>a : Symbol(B.__index, Decl(staticIndexSignature4.ts, 0, 9)) i[2] = B[2] >i : Symbol(i, Decl(staticIndexSignature4.ts, 16, 13)) @@ -92,8 +112,12 @@ if (v === 0) { >v : Symbol(v, Decl(staticIndexSignature4.ts, 15, 13)) i.a = D.a +>i.a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) >i : Symbol(i, Decl(staticIndexSignature4.ts, 16, 13)) +>a : Symbol(IB.__index, Decl(staticIndexSignature4.ts, 10, 14)) +>D.a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) >D : Symbol(D, Decl(staticIndexSignature4.ts, 3, 1)) +>a : Symbol(D.__index, Decl(staticIndexSignature4.ts, 5, 9)) i[2] = B[2] >i : Symbol(i, Decl(staticIndexSignature4.ts, 16, 13)) diff --git a/tests/baselines/reference/staticIndexSignature6.symbols b/tests/baselines/reference/staticIndexSignature6.symbols index f5905cad067db..7204af7e18d04 100644 --- a/tests/baselines/reference/staticIndexSignature6.symbols +++ b/tests/baselines/reference/staticIndexSignature6.symbols @@ -24,10 +24,14 @@ const C = foo() >foo : Symbol(foo, Decl(staticIndexSignature6.ts, 0, 0)) C.a; +>C.a : Symbol((Anonymous class).__index, Decl(staticIndexSignature6.ts, 1, 21)) >C : Symbol(C, Decl(staticIndexSignature6.ts, 9, 5)) +>a : Symbol((Anonymous class).__index, Decl(staticIndexSignature6.ts, 1, 21)) C.a = 1; +>C.a : Symbol((Anonymous class).__index, Decl(staticIndexSignature6.ts, 1, 21)) >C : Symbol(C, Decl(staticIndexSignature6.ts, 9, 5)) +>a : Symbol((Anonymous class).__index, Decl(staticIndexSignature6.ts, 1, 21)) C[2]; >C : Symbol(C, Decl(staticIndexSignature6.ts, 9, 5)) diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols index 82ddc46903ccc..45c72c808159c 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.symbols +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -93,7 +93,9 @@ extend2({ >this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) this.mine +>this.mine : Symbol(IndexedWithoutThis.__index, Decl(thisTypeInFunctions2.ts, 9, 29)) >this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) +>mine : Symbol(IndexedWithoutThis.__index, Decl(thisTypeInFunctions2.ts, 9, 29)) }, mine: 13, @@ -106,7 +108,9 @@ extend2({ >this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) this.mine +>this.mine : Symbol(IndexedWithoutThis.__index, Decl(thisTypeInFunctions2.ts, 9, 29)) >this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) +>mine : Symbol(IndexedWithoutThis.__index, Decl(thisTypeInFunctions2.ts, 9, 29)) } }); diff --git a/tests/baselines/reference/typeGuardOfFromPropNameInUnionType.symbols b/tests/baselines/reference/typeGuardOfFromPropNameInUnionType.symbols index 06912f9d59b7a..845fdcf69d697 100644 --- a/tests/baselines/reference/typeGuardOfFromPropNameInUnionType.symbols +++ b/tests/baselines/reference/typeGuardOfFromPropNameInUnionType.symbols @@ -306,16 +306,22 @@ function f(i: Indexed) { >i : Symbol(i, Decl(typeGuardOfFromPropNameInUnionType.ts, 96, 11)) return i.a; +>i.a : Symbol(Indexed.__index, Decl(typeGuardOfFromPropNameInUnionType.ts, 92, 19)) >i : Symbol(i, Decl(typeGuardOfFromPropNameInUnionType.ts, 96, 11)) +>a : Symbol(Indexed.__index, Decl(typeGuardOfFromPropNameInUnionType.ts, 92, 19)) } else if ("b" in i) { >i : Symbol(i, Decl(typeGuardOfFromPropNameInUnionType.ts, 96, 11)) return i.b; +>i.b : Symbol(Indexed.__index, Decl(typeGuardOfFromPropNameInUnionType.ts, 92, 19)) >i : Symbol(i, Decl(typeGuardOfFromPropNameInUnionType.ts, 96, 11)) +>b : Symbol(Indexed.__index, Decl(typeGuardOfFromPropNameInUnionType.ts, 92, 19)) } return "c" in i && i.c; >i : Symbol(i, Decl(typeGuardOfFromPropNameInUnionType.ts, 96, 11)) +>i.c : Symbol(Indexed.__index, Decl(typeGuardOfFromPropNameInUnionType.ts, 92, 19)) >i : Symbol(i, Decl(typeGuardOfFromPropNameInUnionType.ts, 96, 11)) +>c : Symbol(Indexed.__index, Decl(typeGuardOfFromPropNameInUnionType.ts, 92, 19)) } diff --git a/tests/cases/fourslash/jsDocPropertyDescription1.ts b/tests/cases/fourslash/jsDocPropertyDescription1.ts new file mode 100644 index 0000000000000..8e825c1067d5e --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription1.ts @@ -0,0 +1,15 @@ +/// + +//// interface StringExample { +//// /** Something generic */ +//// [p: string]: any; +//// /** Something specific */ +//// property: number; +//// } +//// function stringExample(e: StringExample) { +//// console.log(e./*property*/property); +//// console.log(e./*string*/anything); +//// } + +verify.quickInfoAt("property", "(property) StringExample.property: number", 'Something specific'); +verify.quickInfoAt("string", "(index) StringExample[string]: any", "Something generic"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription10.ts b/tests/cases/fourslash/jsDocPropertyDescription10.ts new file mode 100644 index 0000000000000..d8e63f754f439 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription10.ts @@ -0,0 +1,11 @@ +/// + +//// class MultipleClass { +//// /** Something generic */ +//// [key: number | symbol | `data-${string}` | `data-${number}`]: string; +//// } +//// function multipleClass(e: typeof MultipleClass) { +//// console.log(e./*multipleClass*/anything); +//// } + +verify.quickInfoAt("multipleClass", "any"); diff --git a/tests/cases/fourslash/jsDocPropertyDescription11.ts b/tests/cases/fourslash/jsDocPropertyDescription11.ts new file mode 100644 index 0000000000000..4c0b1269ced88 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription11.ts @@ -0,0 +1,13 @@ +/// + +//// type AliasExample = { +//// /** Something generic */ +//// [p: string]: string; +//// /** Something else */ +//// [key: `any${string}`]: string; +//// } +//// function aliasExample(e: AliasExample) { +//// console.log(e./*alias*/anything); +//// } + +verify.quickInfoAt("alias", "(index) AliasExample[string | `any${string}`]: string", "Something generic\nSomething else"); diff --git a/tests/cases/fourslash/jsDocPropertyDescription12.ts b/tests/cases/fourslash/jsDocPropertyDescription12.ts new file mode 100644 index 0000000000000..48d4b89cc803f --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription12.ts @@ -0,0 +1,11 @@ +/// + +//// type SymbolAlias = { +//// /** Something generic */ +//// [p: symbol]: string; +//// } +//// function symbolAlias(e: SymbolAlias) { +//// console.log(e./*symbolAlias*/anything); +//// } + +verify.quickInfoAt("symbolAlias", "any"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription2.ts b/tests/cases/fourslash/jsDocPropertyDescription2.ts new file mode 100644 index 0000000000000..bcf8703351cba --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription2.ts @@ -0,0 +1,11 @@ +/// + +//// interface SymbolExample { +//// /** Something generic */ +//// [key: symbol]: string; +//// } +//// function symbolExample(e: SymbolExample) { +//// console.log(e./*symbol*/anything); +//// } + +verify.quickInfoAt("symbol", "any") diff --git a/tests/cases/fourslash/jsDocPropertyDescription3.ts b/tests/cases/fourslash/jsDocPropertyDescription3.ts new file mode 100644 index 0000000000000..bd92fa324acd2 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription3.ts @@ -0,0 +1,13 @@ +/// + +//// interface LiteralExample { +//// /** Something generic */ +//// [key: `data-${string}`]: string; +//// /** Something else */ +//// [key: `prefix${number}`]: number; +//// } +//// function literalExample(e: LiteralExample) { +//// console.log(e./*literal*/anything); +//// } + +verify.quickInfoAt("literal", "any"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription4.ts b/tests/cases/fourslash/jsDocPropertyDescription4.ts new file mode 100644 index 0000000000000..f3d973d9c6b91 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription4.ts @@ -0,0 +1,11 @@ +/// + +//// interface MultipleExample { +//// /** Something generic */ +//// [key: string | number | symbol]: string; +//// } +//// function multipleExample(e: MultipleExample) { +//// console.log(e./*multiple*/anything); +//// } + +verify.quickInfoAt("multiple", "(index) MultipleExample[string | number | symbol]: string", "Something generic"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription5.ts b/tests/cases/fourslash/jsDocPropertyDescription5.ts new file mode 100644 index 0000000000000..1e58e1a4ebf3c --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription5.ts @@ -0,0 +1,11 @@ +/// + +//// interface Multiple1Example { +//// /** Something generic */ +//// [key: number | symbol | `data-${string}` | `data-${number}`]: string; +//// } +//// function multiple1Example(e: Multiple1Example) { +//// console.log(e./*multiple1*/anything); +//// } + +verify.quickInfoAt("multiple1", "any"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription6.ts b/tests/cases/fourslash/jsDocPropertyDescription6.ts new file mode 100644 index 0000000000000..8fda4a9f927d9 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription6.ts @@ -0,0 +1,16 @@ +// / + +//// interface Literal1Example { +//// [key: `prefix${string}`]: number | string; +//// /** Something else */ +//// [key: `prefix${number}`]: number; +//// } +//// function literal1Example(e: Literal1Example) { +//// console.log(e./*literal1*/prefixMember); +//// console.log(e./*literal2*/anything); +//// console.log(e./*literal3*/prefix0); +//// } + +verify.quickInfoAt("literal1", "(index) Literal1Example[`prefix${string}`]: string | number"); +verify.quickInfoAt("literal2", "any"); +verify.quickInfoAt("literal3", "(index) Literal1Example[`prefix${string}` | `prefix${number}`]: number", "Something else"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription7.ts b/tests/cases/fourslash/jsDocPropertyDescription7.ts new file mode 100644 index 0000000000000..aa11c0a8c5417 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription7.ts @@ -0,0 +1,11 @@ +/// + +//// class StringClass { +//// /** Something generic */ +//// static [p: string]: any; +//// } +//// function stringClass(e: typeof StringClass) { +//// console.log(e./*stringClass*/anything); +//// } + +verify.quickInfoAt("stringClass", "(index) StringClass[string]: any", "Something generic"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription8.ts b/tests/cases/fourslash/jsDocPropertyDescription8.ts new file mode 100644 index 0000000000000..553f81c42f368 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription8.ts @@ -0,0 +1,11 @@ +/// + +//// class SymbolClass { +//// /** Something generic */ +//// static [p: symbol]: any; +//// } +//// function symbolClass(e: typeof SymbolClass) { +//// console.log(e./*symbolClass*/anything); +//// } + +verify.quickInfoAt("symbolClass", "any"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocPropertyDescription9.ts b/tests/cases/fourslash/jsDocPropertyDescription9.ts new file mode 100644 index 0000000000000..fe94af996d1b0 --- /dev/null +++ b/tests/cases/fourslash/jsDocPropertyDescription9.ts @@ -0,0 +1,17 @@ +/// + +//// class LiteralClass { +//// /** Something generic */ +//// static [key: `prefix${string}`]: any; +//// /** Something else */ +//// static [key: `prefix${number}`]: number; +//// } +//// function literalClass(e: typeof LiteralClass) { +//// console.log(e./*literal1Class*/prefixMember); +//// console.log(e./*literal2Class*/anything); +//// console.log(e./*literal3Class*/prefix0); +//// } + +verify.quickInfoAt("literal1Class", "(index) LiteralClass[`prefix${string}`]: any", "Something generic"); +verify.quickInfoAt("literal2Class", "any"); +verify.quickInfoAt("literal3Class", "(index) LiteralClass[`prefix${string}` | `prefix${number}`]: any", "Something generic\nSomething else") \ No newline at end of file