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

fix(es/parser): Rescan << as < when parsing type args #8607

Merged
merged 4 commits into from
Feb 6, 2024

Conversation

yannkaiser
Copy link
Contributor

@yannkaiser yannkaiser commented Feb 5, 2024

Description:

The related issue is a product to the fact that the lexer sees a << token in fun<<T>... and therefore parses the type args as an arrow function.

This PR adds the handling of the "split" of << when beginning to parse type args.

I am open for suggestions, I still find this a bit odd (in parse_ts_type_args()):

if is!(p, "<<") {
    p.input.cut_lshift();
} else {
    expect!(p, '<');
}

Related issue:

@yannkaiser yannkaiser requested a review from a team as a code owner February 5, 2024 21:22
Copy link

changeset-bot bot commented Feb 5, 2024

⚠️ No Changeset found

Latest commit: 9de9c1b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kdy1
Copy link
Member

kdy1 commented Feb 6, 2024

Can you add some test cases for #8209 and #7187?

@kdy1 kdy1 added this to the Planned milestone Feb 6, 2024
@yannkaiser
Copy link
Contributor Author

Sure, I added the test cases in the ecma_parser and swc packages, not sure if it was necessary to have in both though but i felt like it would be a good idea since the expected output is different.

@kdy1 kdy1 changed the title fix(es/parser): handle rescanning for LShift when parsing type args fix(es/parser): Rescan << as < when parsing type args Feb 6, 2024
@kdy1 kdy1 enabled auto-merge (squash) February 6, 2024 14:30
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.

Thanks! It was a headache to me.


swc-bump:

  • swc_ecma_parser

@kdy1 kdy1 merged commit 9e6dad9 into swc-project:main Feb 6, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.4.1 Feb 13, 2024
@swc-project swc-project locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
2 participants