fix(44693): emit declaration of JSDoc overridden properties with different types (#46797)

This commit is contained in:
Oleksandr T
2021-12-10 11:06:59 -08:00
committed by GitHub
parent 4e39023396
commit df87a8c12d
5 changed files with 188 additions and 1 deletions
+1 -1
View File
@@ -39083,7 +39083,7 @@ namespace ts {
const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
for (const prop of properties) {
const existing = seen.get(prop.escapedName);
if (existing && !isPropertyIdenticalTo(existing, prop)) {
if (existing && prop.parent === existing.parent) {
seen.delete(prop.escapedName);
}
}
@@ -0,0 +1,64 @@
//// [a.js]
/**
* @typedef A
* @property {string} a
*/
/**
* @typedef B
* @property {number} b
*/
class C1 {
/**
* @type {A}
*/
value;
}
class C2 extends C1 {
/**
* @type {A}
*/
value;
}
class C3 extends C1 {
/**
* @type {A & B}
*/
value;
}
//// [a.d.ts]
/**
* @typedef A
* @property {string} a
*/
/**
* @typedef B
* @property {number} b
*/
declare class C1 {
/**
* @type {A}
*/
value: A;
}
declare class C2 extends C1 {
}
declare class C3 extends C1 {
/**
* @type {A & B}
*/
value: A & B;
}
type A = {
a: string;
};
type B = {
b: number;
};
@@ -0,0 +1,43 @@
=== tests/cases/compiler/a.js ===
/**
* @typedef A
* @property {string} a
*/
/**
* @typedef B
* @property {number} b
*/
class C1 {
>C1 : Symbol(C1, Decl(a.js, 0, 0))
/**
* @type {A}
*/
value;
>value : Symbol(C1.value, Decl(a.js, 10, 11))
}
class C2 extends C1 {
>C2 : Symbol(C2, Decl(a.js, 15, 1))
>C1 : Symbol(C1, Decl(a.js, 0, 0))
/**
* @type {A}
*/
value;
>value : Symbol(C2.value, Decl(a.js, 17, 21))
}
class C3 extends C1 {
>C3 : Symbol(C3, Decl(a.js, 22, 1))
>C1 : Symbol(C1, Decl(a.js, 0, 0))
/**
* @type {A & B}
*/
value;
>value : Symbol(C3.value, Decl(a.js, 24, 21))
}
@@ -0,0 +1,43 @@
=== tests/cases/compiler/a.js ===
/**
* @typedef A
* @property {string} a
*/
/**
* @typedef B
* @property {number} b
*/
class C1 {
>C1 : C1
/**
* @type {A}
*/
value;
>value : A
}
class C2 extends C1 {
>C2 : C2
>C1 : C1
/**
* @type {A}
*/
value;
>value : A
}
class C3 extends C1 {
>C3 : C3
>C1 : C1
/**
* @type {A & B}
*/
value;
>value : A & B
}
@@ -0,0 +1,37 @@
// @checkJs: true
// @allowJs: true
// @declaration: true
// @emitDeclarationOnly: true
// @outDir: ./dist
// @filename: a.js
/**
* @typedef A
* @property {string} a
*/
/**
* @typedef B
* @property {number} b
*/
class C1 {
/**
* @type {A}
*/
value;
}
class C2 extends C1 {
/**
* @type {A}
*/
value;
}
class C3 extends C1 {
/**
* @type {A & B}
*/
value;
}