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 #3049

Closed
charliematters opened this issue Apr 11, 2023 · 2 comments
Closed

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

@evanw
Copy link
Owner

evanw commented Apr 11, 2023

Data from stdin is a raw string without any file extension attached, so esbuild has no information about what type of file it is. In that case, esbuild defaults to assuming the input is JavaScript. You need to specify a different loader if that's not the case (e.g. --loader=ts).

I'm closing this issue because esbuild is working as expected.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2023
@charliematters
Copy link
Author

Ah, that makes sense - thanks. Now I just have to apply that to my esbuild-loader config!

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