Skip to content

[ts-beta 5.5] Function declarations are not exported when targeting commonJS - js emit regression Β #58699

Closed
@dragomirtitian

Description

@dragomirtitian

πŸ”Ž Search Terms

JavaScript emit commonjs

πŸ•— Version & Regression Information

  • This changed between versions 5.4 and 5.5beta

⏯ Playground Link

Playground Link

πŸ’» Code

function getProgram(source: string) {}
export { getProgram }

πŸ™ Actual behavior

The following js is generated:

Object.defineProperty(exports, "__esModule", { value: true });
exports.getProgram = void 0;
function getProgram(source) { }

This does not actually add the function to the export. So when importing getProgram it will be undefined.

πŸ™‚ Expected behavior

Emit should be the same as 5.4 where the function is actually exported:

Object.defineProperty(exports, "__esModule", { value: true });
exports.getProgram = void 0;
function getProgram(source) { }
exports.getProgram = getProgram;

Additional information about the issue

This seems to affect only function declarations. Variables, classes seem to be exported correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions