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

refactor(es/typescript): Extract type annotation proposal out #9127

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Jul 3, 2024

Description:

The Node.js team wants a Wasm package that only implements type annotation proposals. So we need to refactor our TypeScript transform to allow it.

Related issue:

@kdy1 kdy1 self-assigned this Jul 3, 2024
@kdy1 kdy1 added this to the Planned milestone Jul 3, 2024
@kdy1
Copy link
Member Author

kdy1 commented Jul 3, 2024

@magic-akari Can you take a look? I looked at the TypeScript transform source code, but I'm not sure if applying StripType::default() is enough.

@magic-akari

This comment was marked as off-topic.

@magic-akari
Copy link
Member

What I would like is for some option or collection of options where I can use SWC to implement the Type Annotations proposal, but nothing more. In particular, see https://github.com/tc39/proposal-type-annotations#intentional-omissions:

Originally posted by @GeoffreyBooth in nodejs/loaders#208 (comment)

Based on this requirement, I believe we only need to export StripType. What do you think? @kdy1

@kdy1
Copy link
Member Author

kdy1 commented Jul 3, 2024

I was thinking the same. I'll add a function for it.

@kdy1
Copy link
Member Author

kdy1 commented Jul 3, 2024

Thank you!

@kdy1 kdy1 marked this pull request as ready for review July 3, 2024 05:34
@kdy1 kdy1 requested review from a team as code owners July 3, 2024 05:34
Copy link
Member Author

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

swc-bump:

  • swc_ecma_transforms_typescript
  • swc_core

@kdy1 kdy1 requested a review from magic-akari July 3, 2024 05:34
@magic-akari
Copy link
Member

magic-akari commented Jul 3, 2024

When using only StripType::default(), the following occurs:

  • Enums and namespaces are disregarded and remain in place. (Previously handled by Transform)
  • Implicit type imports are ignored; only syntactic type imports are processed by StripType. (Previously handled by StripImportExport)
  • Declarations such as import foo = require('foo') and export = foo are left unprocessed. (Previously handled by Transform)
  • Class constructor parameter properties are also left unprocessed. (Previously handled by Transform)

Are we on the same page? CC @GeoffreyBooth

@kdy1 kdy1 merged commit dfee5f8 into swc-project:main Jul 3, 2024
149 checks passed
@kdy1 kdy1 deleted the ts2 branch July 3, 2024 06:10
@kdy1 kdy1 modified the milestones: Planned, v1.6.7 Jul 3, 2024
@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants