-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 mistakes typescript generic type for JSX #2363
Comments
Note if the method is not defined with an arrow function it transpiles ok: @action resetRequest = <T>(): IPromiseBasedObservable<T> => {
Object.assign(this.request, RequestState.initialReqState)
return this.request as IPromiseBasedObservable<T>
} to @action resetRequest<T>(): IPromiseBasedObservable<T> {
Object.assign(this.request, RequestState.initialReqState)
return this.request as IPromiseBasedObservable<T>
} |
I get a similar error if I compile your code with the official TypeScript compiler:
You can see it for yourself here: link. So your code is not valid TypeScript. |
Thanks for pointing me in the right direction. Solution is to add a
|
@evanw - we ran into this same issue trying to upgrade to ESBuild loader v3.0.0. |
That code does not appear to cause esbuild's output to differ from TypeScript's output. So esbuild appears to be functioning as expected. As a
As a
|
We only started seeing this after trying to upgrade esbuild-loader to V3 which brings in esbuild 0.17.6. The previous version 2.21.0 and 0.16.17 worked just fine with the same version of TS compiler. |
If you believe you have found a bug with esbuild, then please file a new issue. Make sure you include a self-contained way to reproduce the problem and in this case also a description of why you believe it to be a bug with esbuild. |
I believe I found this too, and have raised #3049 |
When parsing
.ts
astsx
esbuild will mistake generic types for JSX.Here is the file being transpiled
It thinks
<T>(): IPromiseBasedObservable<T>
is JSX.It will eventually error with:
Here is the esbuild serve.js file:
The text was updated successfully, but these errors were encountered: