support JSDoc comments inherited for parameter properties (#44329)
* support JSDoc comments inherited for parameter properties * Update formats Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
parent
a3eadfe905
commit
4af8333a4e
|
@ -591,7 +591,11 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration, cb: (symbol: Symbol) => T[] | undefined): T[] | undefined {
|
function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration, cb: (symbol: Symbol) => T[] | undefined): T[] | undefined {
|
||||||
return firstDefined(declaration.parent ? getAllSuperTypeNodes(declaration.parent) : emptyArray, superTypeNode => {
|
const classOrInterfaceDeclaration = declaration.parent?.kind === SyntaxKind.Constructor ? declaration.parent.parent : declaration.parent;
|
||||||
|
if (!classOrInterfaceDeclaration) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
|
||||||
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
|
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
|
||||||
return symbol ? cb(symbol) : undefined;
|
return symbol ? cb(symbol) : undefined;
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"marker": {
|
||||||
|
"fileName": "/tests/cases/fourslash/quickInfoOnParameterProperties.ts",
|
||||||
|
"position": 226,
|
||||||
|
"name": "1"
|
||||||
|
},
|
||||||
|
"quickInfo": {
|
||||||
|
"kind": "property",
|
||||||
|
"kindModifiers": "public",
|
||||||
|
"textSpan": {
|
||||||
|
"start": 224,
|
||||||
|
"length": 4
|
||||||
|
},
|
||||||
|
"displayParts": [
|
||||||
|
{
|
||||||
|
"text": "(",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "property",
|
||||||
|
"kind": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": ")",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": " ",
|
||||||
|
"kind": "space"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Foo",
|
||||||
|
"kind": "className"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": ".",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "name",
|
||||||
|
"kind": "propertyName"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": ":",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": " ",
|
||||||
|
"kind": "space"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "string",
|
||||||
|
"kind": "keyword"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"documentation": [
|
||||||
|
{
|
||||||
|
"text": "this is the name of blabla \n- use blabla",
|
||||||
|
"kind": "text"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"marker": {
|
||||||
|
"fileName": "/tests/cases/fourslash/quickInfoOnParameterProperties.ts",
|
||||||
|
"position": 347,
|
||||||
|
"name": "2"
|
||||||
|
},
|
||||||
|
"quickInfo": {
|
||||||
|
"kind": "property",
|
||||||
|
"kindModifiers": "public",
|
||||||
|
"textSpan": {
|
||||||
|
"start": 345,
|
||||||
|
"length": 4
|
||||||
|
},
|
||||||
|
"displayParts": [
|
||||||
|
{
|
||||||
|
"text": "(",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "property",
|
||||||
|
"kind": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": ")",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": " ",
|
||||||
|
"kind": "space"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Foo2",
|
||||||
|
"kind": "className"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": ".",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "name",
|
||||||
|
"kind": "propertyName"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": ":",
|
||||||
|
"kind": "punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": " ",
|
||||||
|
"kind": "space"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "string",
|
||||||
|
"kind": "keyword"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"documentation": [
|
||||||
|
{
|
||||||
|
"text": "this is the name of blabla \n- use blabla",
|
||||||
|
"kind": "text"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
29
tests/cases/fourslash/quickInfoOnParameterProperties.ts
Normal file
29
tests/cases/fourslash/quickInfoOnParameterProperties.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/// <reference path='fourslash.ts' />
|
||||||
|
|
||||||
|
////interface IFoo {
|
||||||
|
//// /** this is the name of blabla
|
||||||
|
//// * - use blabla
|
||||||
|
//// * @example blabla
|
||||||
|
//// */
|
||||||
|
//// name?: string;
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////// test1 should work
|
||||||
|
////class Foo implements IFoo {
|
||||||
|
//// //public name: string = '';
|
||||||
|
//// constructor(
|
||||||
|
//// public na/*1*/me: string, // documentation should leech and work !
|
||||||
|
//// ) {
|
||||||
|
//// }
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////// test2 work
|
||||||
|
////class Foo2 implements IFoo {
|
||||||
|
//// public na/*2*/me: string = ''; // documentation leeched and work !
|
||||||
|
//// constructor(
|
||||||
|
//// //public name: string,
|
||||||
|
//// ) {
|
||||||
|
//// }
|
||||||
|
////}
|
||||||
|
|
||||||
|
verify.baselineQuickInfo()
|
Loading…
Reference in a new issue