Skip to content

Commit

Permalink
fix(49200): skip duplicated method declarations (#50609)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Sep 21, 2022
1 parent 4d91204 commit 2644f28
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/checker.ts
Expand Up @@ -7280,6 +7280,7 @@ namespace ts {
&& symbol.escapedName !== InternalSymbolName.ExportEquals
&& !(symbol.flags & SymbolFlags.Prototype)
&& !(symbol.flags & SymbolFlags.Class)
&& !(symbol.flags & SymbolFlags.Method)
&& !isConstMergedWithNSPrintableAsSignatureMerge) {
if (propertyAsAlias) {
const createdExport = serializeMaybeAliasAssignment(symbol);
Expand Down
17 changes: 17 additions & 0 deletions tests/baselines/reference/declarationEmitMethodDeclaration.js
@@ -0,0 +1,17 @@
//// [a.js]
export default {
methods: {
foo() { }
}
}




//// [a.d.ts]
declare namespace _default {
namespace methods {
function foo(): void;
}
}
export default _default;
10 changes: 10 additions & 0 deletions tests/baselines/reference/declarationEmitMethodDeclaration.symbols
@@ -0,0 +1,10 @@
=== /a.js ===
export default {
methods: {
>methods : Symbol(methods, Decl(a.js, 0, 16))

foo() { }
>foo : Symbol(foo, Decl(a.js, 1, 14))
}
}

13 changes: 13 additions & 0 deletions tests/baselines/reference/declarationEmitMethodDeclaration.types
@@ -0,0 +1,13 @@
=== /a.js ===
export default {
>{ methods: { foo() { } }} : { methods: { foo(): void; }; }

methods: {
>methods : { foo(): void; }
>{ foo() { } } : { foo(): void; }

foo() { }
>foo : () => void
}
}

10 changes: 10 additions & 0 deletions tests/cases/compiler/declarationEmitMethodDeclaration.ts
@@ -0,0 +1,10 @@
// @allowJs: true
// @checkJs: true
// @declaration: true
// @emitDeclarationOnly: true
// @filename: /a.js
export default {
methods: {
foo() { }
}
}

0 comments on commit 2644f28

Please sign in to comment.