diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index da3b4d9dbd6..a8a92caf904 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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); } } diff --git a/tests/baselines/reference/jsDeclarationsInheritedTypes.js b/tests/baselines/reference/jsDeclarationsInheritedTypes.js new file mode 100644 index 00000000000..5fce213976e --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsInheritedTypes.js @@ -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; +}; diff --git a/tests/baselines/reference/jsDeclarationsInheritedTypes.symbols b/tests/baselines/reference/jsDeclarationsInheritedTypes.symbols new file mode 100644 index 00000000000..b649cacc669 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsInheritedTypes.symbols @@ -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)) +} + diff --git a/tests/baselines/reference/jsDeclarationsInheritedTypes.types b/tests/baselines/reference/jsDeclarationsInheritedTypes.types new file mode 100644 index 00000000000..9898379887e --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsInheritedTypes.types @@ -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 +} + diff --git a/tests/cases/compiler/jsDeclarationsInheritedTypes.ts b/tests/cases/compiler/jsDeclarationsInheritedTypes.ts new file mode 100644 index 00000000000..303d3ba9bac --- /dev/null +++ b/tests/cases/compiler/jsDeclarationsInheritedTypes.ts @@ -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; +}