diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cfdc767d9cf40..dd56dc8ff8905 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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); diff --git a/tests/baselines/reference/declarationEmitMethodDeclaration.js b/tests/baselines/reference/declarationEmitMethodDeclaration.js new file mode 100644 index 0000000000000..d0d7a923e5637 --- /dev/null +++ b/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; diff --git a/tests/baselines/reference/declarationEmitMethodDeclaration.symbols b/tests/baselines/reference/declarationEmitMethodDeclaration.symbols new file mode 100644 index 0000000000000..2496f2870965b --- /dev/null +++ b/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)) + } +} + diff --git a/tests/baselines/reference/declarationEmitMethodDeclaration.types b/tests/baselines/reference/declarationEmitMethodDeclaration.types new file mode 100644 index 0000000000000..c672e7d5dc9b0 --- /dev/null +++ b/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 + } +} + diff --git a/tests/cases/compiler/declarationEmitMethodDeclaration.ts b/tests/cases/compiler/declarationEmitMethodDeclaration.ts new file mode 100644 index 0000000000000..44032d9543ee4 --- /dev/null +++ b/tests/cases/compiler/declarationEmitMethodDeclaration.ts @@ -0,0 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @declaration: true +// @emitDeclarationOnly: true +// @filename: /a.js +export default { + methods: { + foo() { } + } +}