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

Support for stripping type annotations #434

Open
nezarati opened this issue Sep 25, 2024 · 2 comments
Open

Support for stripping type annotations #434

nezarati opened this issue Sep 25, 2024 · 2 comments

Comments

@nezarati
Copy link

nezarati commented Sep 25, 2024

JavaScript engines are moving towards native support for type annotations, as seen in the Type Annotations proposal.

Also, Node.js recently supports TS compilation by embedding the Amaro wasm module. It is limited to inline type annotations and doesn't support features like enums or namespaces. It allows running TypeScript files without prior transformation by stripping type annotations.

Does es-module-shims have plans to support for stripping type annotations?

This feature is useful for users by:

  • Reducing build times by eliminating unneeded transformation steps.
  • Leveraging native engine support for type annotations as it becomes available.
@guybedford
Copy link
Owner

While strictly speaking, es-module-shims is designed to be tailored to browser standards, I also really like this idea.

Perhaps the way this can be done is to have a new development build of es-module-shims, that runs type stripping first if the file has a TypeScript extension. This should be relatively straightforward if we just use Amaro (https://www.npmjs.com/package/amaro) like Node.js does.

@guybedford
Copy link
Owner

I went ahead and implemented a simple POC in #435. Feedback welcome.

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

2 participants