🔎 Search Terms
commonjs, exports, function
🕗 Version & Regression Information
⏯ Playground Link
Thanks for merging I'm still seeing an odd behavior I think is related: here's the minimal repro I could find - bug workbench link
💻 Code
// @showEmittedFile: main.ts
// @module: commonjs
// @filename: main.ts
import { Foo } from "./file-with-export"
export function createFoo(): Foo {
return {};
}
export {createFoo as createFooV2};
// @filename: file-with-export.ts
export interface Foo {}
🙁 Actual behavior
main.js has two exports for createFoo and createFooV2:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFoo = createFoo;
exports.createFooV2 = createFoo;
exports.createFoo = createFoo;
exports.createFooV2 = createFoo;
function createFoo() {
return {};
}
🙂 Expected behavior
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFoo = createFoo;
exports.createFooV2 = createFoo;
function createFoo() {
return {};
}
Additional information about the issue
I believe this is a result of the fix for #58473. (I still appreciate having these duplicate exports rather than the compiler dropping the exports entirely 😃 )
In the debugger, I see that this exportedFunctions (
|
exportedFunctions: Set<FunctionDeclaration>; // all of the top-level exported function declarations |
) set contains two separate
createFoo nodes.
If I remove the export {createFoo as createFooV2} from the repro, or remove the declared return type : Foo, I get the expected behavior.
This was uncovered by testing the latest TS version in Google (#58685)
🔎 Search Terms
commonjs, exports, function
🕗 Version & Regression Information
⏯ Playground Link
Thanks for merging I'm still seeing an odd behavior I think is related: here's the minimal repro I could find - bug workbench link
💻 Code
🙁 Actual behavior
main.js has two exports for
createFooandcreateFooV2:🙂 Expected behavior
Additional information about the issue
I believe this is a result of the fix for #58473. (I still appreciate having these duplicate exports rather than the compiler dropping the exports entirely 😃 )
In the debugger, I see that this
exportedFunctions(TypeScript/src/compiler/transformers/utilities.ts
Line 108 in 506f3e2
createFoonodes.If I remove the
export {createFoo as createFooV2}from the repro, or remove the declared return type: Foo, I get the expected behavior.This was uncovered by testing the latest TS version in Google (#58685)