Skip to content

Commit df87a8c

Browse files
authored
fix(44693): emit declaration of JSDoc overridden properties with different types (microsoft#46797)
1 parent 4e39023 commit df87a8c

File tree

5 files changed

+188
-1
lines changed

5 files changed

+188
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39083,7 +39083,7 @@ namespace ts {
3908339083
const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
3908439084
for (const prop of properties) {
3908539085
const existing = seen.get(prop.escapedName);
39086-
if (existing && !isPropertyIdenticalTo(existing, prop)) {
39086+
if (existing && prop.parent === existing.parent) {
3908739087
seen.delete(prop.escapedName);
3908839088
}
3908939089
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//// [a.js]
2+
/**
3+
* @typedef A
4+
* @property {string} a
5+
*/
6+
7+
/**
8+
* @typedef B
9+
* @property {number} b
10+
*/
11+
12+
class C1 {
13+
/**
14+
* @type {A}
15+
*/
16+
value;
17+
}
18+
19+
class C2 extends C1 {
20+
/**
21+
* @type {A}
22+
*/
23+
value;
24+
}
25+
26+
class C3 extends C1 {
27+
/**
28+
* @type {A & B}
29+
*/
30+
value;
31+
}
32+
33+
34+
35+
36+
//// [a.d.ts]
37+
/**
38+
* @typedef A
39+
* @property {string} a
40+
*/
41+
/**
42+
* @typedef B
43+
* @property {number} b
44+
*/
45+
declare class C1 {
46+
/**
47+
* @type {A}
48+
*/
49+
value: A;
50+
}
51+
declare class C2 extends C1 {
52+
}
53+
declare class C3 extends C1 {
54+
/**
55+
* @type {A & B}
56+
*/
57+
value: A & B;
58+
}
59+
type A = {
60+
a: string;
61+
};
62+
type B = {
63+
b: number;
64+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
=== tests/cases/compiler/a.js ===
2+
/**
3+
* @typedef A
4+
* @property {string} a
5+
*/
6+
7+
/**
8+
* @typedef B
9+
* @property {number} b
10+
*/
11+
12+
class C1 {
13+
>C1 : Symbol(C1, Decl(a.js, 0, 0))
14+
15+
/**
16+
* @type {A}
17+
*/
18+
value;
19+
>value : Symbol(C1.value, Decl(a.js, 10, 11))
20+
}
21+
22+
class C2 extends C1 {
23+
>C2 : Symbol(C2, Decl(a.js, 15, 1))
24+
>C1 : Symbol(C1, Decl(a.js, 0, 0))
25+
26+
/**
27+
* @type {A}
28+
*/
29+
value;
30+
>value : Symbol(C2.value, Decl(a.js, 17, 21))
31+
}
32+
33+
class C3 extends C1 {
34+
>C3 : Symbol(C3, Decl(a.js, 22, 1))
35+
>C1 : Symbol(C1, Decl(a.js, 0, 0))
36+
37+
/**
38+
* @type {A & B}
39+
*/
40+
value;
41+
>value : Symbol(C3.value, Decl(a.js, 24, 21))
42+
}
43+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
=== tests/cases/compiler/a.js ===
2+
/**
3+
* @typedef A
4+
* @property {string} a
5+
*/
6+
7+
/**
8+
* @typedef B
9+
* @property {number} b
10+
*/
11+
12+
class C1 {
13+
>C1 : C1
14+
15+
/**
16+
* @type {A}
17+
*/
18+
value;
19+
>value : A
20+
}
21+
22+
class C2 extends C1 {
23+
>C2 : C2
24+
>C1 : C1
25+
26+
/**
27+
* @type {A}
28+
*/
29+
value;
30+
>value : A
31+
}
32+
33+
class C3 extends C1 {
34+
>C3 : C3
35+
>C1 : C1
36+
37+
/**
38+
* @type {A & B}
39+
*/
40+
value;
41+
>value : A & B
42+
}
43+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// @checkJs: true
2+
// @allowJs: true
3+
// @declaration: true
4+
// @emitDeclarationOnly: true
5+
// @outDir: ./dist
6+
// @filename: a.js
7+
8+
/**
9+
* @typedef A
10+
* @property {string} a
11+
*/
12+
13+
/**
14+
* @typedef B
15+
* @property {number} b
16+
*/
17+
18+
class C1 {
19+
/**
20+
* @type {A}
21+
*/
22+
value;
23+
}
24+
25+
class C2 extends C1 {
26+
/**
27+
* @type {A}
28+
*/
29+
value;
30+
}
31+
32+
class C3 extends C1 {
33+
/**
34+
* @type {A & B}
35+
*/
36+
value;
37+
}

0 commit comments

Comments
 (0)