mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-26 03:19:10 -06:00
fix(55434): Renamed field takes on documentation from other field with the same name (#55469)
This commit is contained in:
parent
76f3f47b8b
commit
daa7e985f5
@ -719,11 +719,12 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
|
||||
if (documentation.length === 0 && isIdentifier(location) && symbol.valueDeclaration && isBindingElement(symbol.valueDeclaration)) {
|
||||
const declaration = symbol.valueDeclaration;
|
||||
const parent = declaration.parent;
|
||||
if (isIdentifier(declaration.name) && isObjectBindingPattern(parent)) {
|
||||
const name = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
const name = declaration.propertyName || declaration.name;
|
||||
if (isIdentifier(name) && isObjectBindingPattern(parent)) {
|
||||
const propertyName = getTextOfIdentifierOrLiteral(name);
|
||||
const objectType = typeChecker.getTypeAtLocation(parent);
|
||||
documentation = firstDefined(objectType.isUnion() ? objectType.types : [objectType], t => {
|
||||
const prop = t.getProperty(name);
|
||||
const prop = t.getProperty(propertyName);
|
||||
return prop ? prop.getDocumentationComment(typeChecker) : undefined;
|
||||
}) || emptyArray;
|
||||
}
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
=== /tests/cases/fourslash/quickInfoForObjectBindingElementName06.ts ===
|
||||
// type Foo = {
|
||||
// /**
|
||||
// * Thing is a bar
|
||||
// */
|
||||
// isBar: boolean
|
||||
//
|
||||
// /**
|
||||
// * Thing is a baz
|
||||
// */
|
||||
// isBaz: boolean
|
||||
// }
|
||||
//
|
||||
// function f(): Foo {
|
||||
// return undefined as any
|
||||
// }
|
||||
//
|
||||
// const { isBaz: isBar } = f();
|
||||
// isBar;
|
||||
// ^^^^^
|
||||
// | ----------------------------------------------------------------------
|
||||
// | const isBar: boolean
|
||||
// | Thing is a baz
|
||||
// | ----------------------------------------------------------------------
|
||||
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName06.ts",
|
||||
"position": 217,
|
||||
"name": ""
|
||||
},
|
||||
"item": {
|
||||
"kind": "const",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 212,
|
||||
"length": 5
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "const",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "isBar",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "boolean",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
{
|
||||
"text": "Thing is a baz",
|
||||
"kind": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,22 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////type Foo = {
|
||||
//// /**
|
||||
//// * Thing is a bar
|
||||
//// */
|
||||
//// isBar: boolean
|
||||
////
|
||||
//// /**
|
||||
//// * Thing is a baz
|
||||
//// */
|
||||
//// isBaz: boolean
|
||||
////}
|
||||
////
|
||||
////function f(): Foo {
|
||||
//// return undefined as any
|
||||
////}
|
||||
////
|
||||
////const { isBaz: isBar } = f();
|
||||
////isBar/**/;
|
||||
|
||||
verify.baselineQuickInfo();
|
||||
Loading…
x
Reference in New Issue
Block a user