Skip to content
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

Ban import=require and export= under erasableSyntaxOnly #61175

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Feb 14, 2025

Per discussion; this syntax isn't supported by Node.js/Amaro or ts-blank-space, and export= is not actually erasable as its transformed syntax is module.exports=.

This effectively means you can't write any CJS code under erasableSyntaxOnly (without using const foo = require("foo") and module.exports = ... directly, which do not bind in TS). Perhaps we can make const foo = require("...") and module.exports = ... bind like they do in JS for TS files in the future.

Updates #59601
Updates #61011

return MyClassOk;
}());
//// [commonjs.cjs]
"use strict";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, this means that CJS isn't even erasable because we assume strict and always insert it

@jakebailey jakebailey merged commit 0f4737e into microsoft:main Feb 14, 2025
32 checks passed
@jakebailey
Copy link
Member Author

@typescript-bot cherry-pick this to release-5.8

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 14, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
cherry-pick this to release-5.8 ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

Hey, @jakebailey! I've created #61178 for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants