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

feat(parser/ts): support optional variance annotations #4008

Merged
merged 12 commits into from Mar 23, 2022

Conversation

magic-akari
Copy link
Member

Description:
Implement: Optional variance annotations

BREAKING CHANGE:

Related issue (if exists):

@magic-akari magic-akari marked this pull request as ready for review March 16, 2022 12:26
@kdy1
Copy link
Member

kdy1 commented Mar 16, 2022

Is it included in rc? I didn't check the typescript blog recently...

@magic-akari
Copy link
Member Author

No, I just made it "ready for review".
I was concerned that there might be some issues that needed to be revised.

do not merge until microsoft/TypeScript#48240 is merged.

@kdy1
Copy link
Member

kdy1 commented Mar 16, 2022

I see, thanks!

Copy link
Member

@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.

LGTM. Thank you!
Not marking as approval as to prevent mistake

@magic-akari
Copy link
Member Author

I'm testing the type variance annotations with JSX(tsx).

const validJSX = <in T>() => {}</in>;

const validTypeVarianceFN = <in T,>() => {};

const expectedError = <in T>() => {};

The first two are parsed expected.
However, the last one did not report an error.

Single type parameter T should have a trailing comma.

When I investigated, I found that this was a pre-existing issue.
What do you think about it?
Maybe we should open a new issue to track it.

const expectedError = <T>() => {};

@kdy1
Copy link
Member

kdy1 commented Mar 17, 2022

I didn't know that const expectedError = <T>() => {}; is an error. I think we need an issue, thank you!

@magic-akari
Copy link
Member Author

Babel will revert this feature and defer it to Babel 8.
cc @kdy1

@nicolo-ribaudo
Copy link

Note that it should be an error only in TSX files, not in TS files. Due to how Babel needs to be configured, many people enabled TSX mode also for .ts files: swc might not have the same problem and you might be able to ship it without introducing breakages.

@kdy1
Copy link
Member

kdy1 commented Mar 23, 2022

@magic-akari I found that typescript PR is merged, and you added some tests.
Is this PR ready to review?

@magic-akari
Copy link
Member Author

Yes. It's ready for review.

Copy link
Member

@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.

Thank you!


swc-bump:

  • swc_atoms
  • swc_ecma_ast --breaking

@kdy1 kdy1 enabled auto-merge (squash) March 23, 2022 14:15
@kdy1 kdy1 added this to the v1.2.161 milestone Mar 23, 2022
@kdy1 kdy1 merged commit bf1924d into swc-project:main Mar 23, 2022
@magic-akari magic-akari deleted the feat/ts-varianceAnnotations branch March 24, 2022 08:16
@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 25, 2022
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.

None yet

3 participants