Skip to content

Commit 4af8333

Browse files
Zzzensandersn
andauthored
support JSDoc comments inherited for parameter properties (#44329)
* support JSDoc comments inherited for parameter properties * Update formats Co-authored-by: Nathan Shively-Sanders <[email protected]> Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent a3eadfe commit 4af8333

File tree

3 files changed

+162
-1
lines changed

3 files changed

+162
-1
lines changed

src/services/services.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,11 @@ namespace ts {
591591
}
592592

593593
function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration, cb: (symbol: Symbol) => T[] | undefined): T[] | undefined {
594-
return firstDefined(declaration.parent ? getAllSuperTypeNodes(declaration.parent) : emptyArray, superTypeNode => {
594+
const classOrInterfaceDeclaration = declaration.parent?.kind === SyntaxKind.Constructor ? declaration.parent.parent : declaration.parent;
595+
if (!classOrInterfaceDeclaration) {
596+
return;
597+
}
598+
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
595599
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
596600
return symbol ? cb(symbol) : undefined;
597601
});
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoOnParameterProperties.ts",
5+
"position": 226,
6+
"name": "1"
7+
},
8+
"quickInfo": {
9+
"kind": "property",
10+
"kindModifiers": "public",
11+
"textSpan": {
12+
"start": 224,
13+
"length": 4
14+
},
15+
"displayParts": [
16+
{
17+
"text": "(",
18+
"kind": "punctuation"
19+
},
20+
{
21+
"text": "property",
22+
"kind": "text"
23+
},
24+
{
25+
"text": ")",
26+
"kind": "punctuation"
27+
},
28+
{
29+
"text": " ",
30+
"kind": "space"
31+
},
32+
{
33+
"text": "Foo",
34+
"kind": "className"
35+
},
36+
{
37+
"text": ".",
38+
"kind": "punctuation"
39+
},
40+
{
41+
"text": "name",
42+
"kind": "propertyName"
43+
},
44+
{
45+
"text": ":",
46+
"kind": "punctuation"
47+
},
48+
{
49+
"text": " ",
50+
"kind": "space"
51+
},
52+
{
53+
"text": "string",
54+
"kind": "keyword"
55+
}
56+
],
57+
"documentation": [
58+
{
59+
"text": "this is the name of blabla \n- use blabla",
60+
"kind": "text"
61+
}
62+
]
63+
}
64+
},
65+
{
66+
"marker": {
67+
"fileName": "/tests/cases/fourslash/quickInfoOnParameterProperties.ts",
68+
"position": 347,
69+
"name": "2"
70+
},
71+
"quickInfo": {
72+
"kind": "property",
73+
"kindModifiers": "public",
74+
"textSpan": {
75+
"start": 345,
76+
"length": 4
77+
},
78+
"displayParts": [
79+
{
80+
"text": "(",
81+
"kind": "punctuation"
82+
},
83+
{
84+
"text": "property",
85+
"kind": "text"
86+
},
87+
{
88+
"text": ")",
89+
"kind": "punctuation"
90+
},
91+
{
92+
"text": " ",
93+
"kind": "space"
94+
},
95+
{
96+
"text": "Foo2",
97+
"kind": "className"
98+
},
99+
{
100+
"text": ".",
101+
"kind": "punctuation"
102+
},
103+
{
104+
"text": "name",
105+
"kind": "propertyName"
106+
},
107+
{
108+
"text": ":",
109+
"kind": "punctuation"
110+
},
111+
{
112+
"text": " ",
113+
"kind": "space"
114+
},
115+
{
116+
"text": "string",
117+
"kind": "keyword"
118+
}
119+
],
120+
"documentation": [
121+
{
122+
"text": "this is the name of blabla \n- use blabla",
123+
"kind": "text"
124+
}
125+
]
126+
}
127+
}
128+
]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////interface IFoo {
4+
//// /** this is the name of blabla
5+
//// * - use blabla
6+
//// * @example blabla
7+
//// */
8+
//// name?: string;
9+
////}
10+
////
11+
////// test1 should work
12+
////class Foo implements IFoo {
13+
//// //public name: string = '';
14+
//// constructor(
15+
//// public na/*1*/me: string, // documentation should leech and work !
16+
//// ) {
17+
//// }
18+
////}
19+
////
20+
////// test2 work
21+
////class Foo2 implements IFoo {
22+
//// public na/*2*/me: string = ''; // documentation leeched and work !
23+
//// constructor(
24+
//// //public name: string,
25+
//// ) {
26+
//// }
27+
////}
28+
29+
verify.baselineQuickInfo()

0 commit comments

Comments
 (0)