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

Esbuild throws errors on generic arrow functions in certain cases #322

Closed
1 task
charliematters opened this issue Apr 11, 2023 · 2 comments
Closed
1 task
Labels
bug Something isn't working pending triage

Comments

@charliematters
Copy link

Bug description

We have upgraded esbuild-loader to avoid the node 18 bug in webpack, and suddenly we are getting syntax errors which are not being reported by tsc.

It seems that it can no longer parse this line:

const foo = async <T>(bar:T): Promise<T> => bar

The error thrown is Expected ")" but found ":"

I've added a repo which shows that when that file is consumed from stdin it fails, but passing the filename as an argument works as expected

Minimal reproduction link

https://github.com/charliematters/esbuild-issue

Environment

TODO

Can you contribute a fix?

  • I’m interested in opening a pull request for this issue.
@charliematters charliematters added bug Something isn't working pending triage labels Apr 11, 2023
@charliematters
Copy link
Author

This is the wrong repo - I'll move it

@privatenumber
Copy link
Owner

privatenumber commented Apr 11, 2023

You didn't tell esbuild that the input is TypeScript.

Works fine when you do: https://hyrious.me/esbuild-repl/?version=0.17.16&mode=transform&input=const+foo+%3D+async+%3CT%3E%28bar%3AT%29%3A+Promise%3CT%3E+%3D%3E+bar&options=--loader%3Dts

Also, if you recently upgraded esbuild-loader to v3, see the migration guide:
https://github.com/esbuild-kit/esbuild-loader/releases/tag/v3.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage
Projects
None yet
Development

No branches or pull requests

2 participants