Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dragomirtitian opened this issue May 29, 2024 · 4 comments

Comments

@dragomirtitian
Copy link
Contributor

dragomirtitian commented May 29, 2024

πŸ”Ž 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.

@dragomirtitian dragomirtitian changed the title [ts-beta] Function declarations are not exported when targeting commonJS - js emit regression [ts-beta 5.5] Function declarations are not exported when targeting commonJS - js emit regression May 29, 2024
@Andarist
Copy link
Contributor

Andarist commented May 29, 2024

I think a fix for this was merged just yesterday: #58489 , for some reason playground doesn't recognize the latest nightly (5.5.0-dev.20240529), cc @jakebailey

@jakebailey
Copy link
Member

The CI got cancelled and screwed with things, manually fixing it right now

@jakebailey
Copy link
Member

Website should be okay now

@Andarist
Copy link
Contributor

and the playground confirms that this is fixed: TS playground :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants