Skip to content

Commit b5cece1

Browse files
authored
Reparse JSDoc annotations on get accessors (#3608)
1 parent 34cf1ba commit b5cece1

6 files changed

Lines changed: 29 additions & 80 deletions

File tree

internal/fourslash/_scripts/failingTests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ TestGetJavaScriptQuickInfo4
209209
TestGetJavaScriptQuickInfo5
210210
TestGetJavaScriptQuickInfo6
211211
TestGetJavaScriptQuickInfo7
212-
TestGetJavaScriptQuickInfo8
213212
TestGetJavaScriptSyntacticDiagnostics24
214213
TestGetJSXOutliningSpans
215214
TestHoverOverComment

internal/parser/reparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node)
288288
}
289289
}
290290
case ast.KindVariableDeclaration, ast.KindExportAssignment, ast.KindPropertyDeclaration, ast.KindPropertyAssignment,
291-
ast.KindShorthandPropertyAssignment:
291+
ast.KindShorthandPropertyAssignment, ast.KindGetAccessor:
292292
if parent.Type() == nil && tag.TypeExpression() != nil {
293293
parent.AsMutable().SetType(p.addDeepCloneReparse(tag.TypeExpression().Type()))
294294
p.finishMutatedNode(parent)

testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ declare class С1 {
201201
}
202202
declare class С2 {
203203
/** @type {string=} */
204-
get p1(): undefined;
204+
get p1(): string | undefined;
205205
/** @type {string | undefined} */
206-
get p2(): undefined;
206+
get p2(): string | undefined;
207207
/** @type {?string} */
208-
get p3(): null;
208+
get p3(): string | null;
209209
/** @type {string | null} */
210-
get p4(): null;
210+
get p4(): string | null;
211211
}
212212
declare class С3 {
213213
/** @type {string=} */

testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,30 @@ class С2 {
2828

2929
/** @type {string=} */
3030
get p1() {
31-
>p1 : undefined
31+
>p1 : string | undefined
3232

3333
return undefined;
3434
>undefined : undefined
3535
}
3636

3737
/** @type {string | undefined} */
3838
get p2() {
39-
>p2 : undefined
39+
>p2 : string | undefined
4040

4141
return undefined;
4242
>undefined : undefined
4343
}
4444

4545
/** @type {?string} */
4646
get p3() {
47-
>p3 : null
47+
>p3 : string | null
4848

4949
return null;
5050
}
5151

5252
/** @type {string | null} */
5353
get p4() {
54-
>p4 : null
54+
>p4 : string | null
5555

5656
return null;
5757
}

testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.types.diff

Lines changed: 0 additions & 37 deletions
This file was deleted.

testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.js.diff

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,33 @@
11
--- old.jsDeclarationsReusesExistingTypeAnnotations.js
22
+++ new.jsDeclarationsReusesExistingTypeAnnotations.js
3-
@@= skipped -200, +200 lines =@@
4-
}
5-
declare class С2 {
6-
/** @type {string=} */
7-
- get p1(): string | undefined;
8-
+ get p1(): undefined;
9-
/** @type {string | undefined} */
10-
- get p2(): string | undefined;
11-
+ get p2(): undefined;
12-
/** @type {?string} */
13-
- get p3(): string | null;
14-
+ get p3(): null;
15-
/** @type {string | null} */
16-
- get p4(): string | null;
17-
+ get p4(): null;
3+
@@= skipped -209, +209 lines =@@
4+
get p4(): string | null;
185
}
196
declare class С3 {
207
- /** @param {string=} value */
218
- set p1(value: string | undefined);
229
/** @type {string=} */
2310
get p1(): string | undefined;
11+
- /** @param {string | undefined} value */
12+
- set p2(value: string | undefined);
2413
+ /** @param {string=} value */
2514
+ set p1(value?: string | undefined);
26-
+ /** @type {string | undefined} */
27-
+ get p2(): string | undefined;
28-
/** @param {string | undefined} value */
29-
set p2(value: string | undefined);
30-
- /** @type {string | undefined} */
31-
- get p2(): string | undefined;
32-
+ /** @type {?string} */
33-
+ get p3(): string | null;
34-
/** @param {?string} value */
35-
set p3(value: string | null);
36-
- /** @type {?string} */
37-
- get p3(): string | null;
38-
+ /** @type {string | null} */
39-
+ get p4(): string | null;
40-
/** @param {string | null} value */
41-
set p4(value: string | null);
42-
- /** @type {string | null} */
43-
- get p4(): string | null;
15+
/** @type {string | undefined} */
16+
get p2(): string | undefined;
17+
- /** @param {?string} value */
18+
- set p3(value: string | null);
19+
+ /** @param {string | undefined} value */
20+
+ set p2(value: string | undefined);
21+
/** @type {?string} */
22+
get p3(): string | null;
23+
- /** @param {string | null} value */
24+
- set p4(value: string | null);
25+
+ /** @param {?string} value */
26+
+ set p3(value: string | null);
27+
/** @type {string | null} */
28+
get p4(): string | null;
29+
+ /** @param {string | null} value */
30+
+ set p4(value: string | null);
4431
}
4532
declare class С4 {
4633
/** @param {string=} value */

0 commit comments

Comments
 (0)