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

Generic functions with default parameters in TSX error out #2410

Closed
thatsmydoing opened this issue Jul 24, 2022 · 1 comment
Closed

Generic functions with default parameters in TSX error out #2410

thatsmydoing opened this issue Jul 24, 2022 · 1 comment

Comments

@thatsmydoing
Copy link

In esbuild 0.14.49, the following code in a tsx file

const foo = <T = unknown>(t: T) => null;

throws the following error

✘ [ERROR] Expected ">" but found "="

    index.tsx:1:15:
      1 │ const foo = <T = unknown>(t: T) => null;
        │                ^
        ╵                >

1 error

In typescript 4.7.4, the above compiles just fine.

For our particular case, we can workaround it by using the alternative generics in TSX workaround of using a comma but that doesn't apply to all cases.

const foo = <T,>(t: T) => null;
@evanw
Copy link
Owner

evanw commented Jul 24, 2022

Thanks for the report. It looks like this changed relatively recently: microsoft/TypeScript#47062. This will need to be changed in esbuild as well to match.

@evanw evanw closed this as completed in 2c2ef24 Jul 24, 2022
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