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

Typescript parsing error when there is ">=>" in source code #1016

Closed
Shenmin-Z opened this issue Mar 20, 2021 · 1 comment
Closed

Typescript parsing error when there is ">=>" in source code #1016

Shenmin-Z opened this issue Mar 20, 2021 · 1 comment

Comments

@Shenmin-Z
Copy link

Shenmin-Z commented Mar 20, 2021

Source code:

():Array<number>=>{return [1]}

When using esbuild:

❯ esbuild a.ts
 > a.ts: error: Expected "=>" but found ":"
    1  ():Array<number>=>{return [1]}
      ╵   ^

1 error

Problem seems to be gone when a space is added between > and =>

New source code:

():Array<number> =>{return [1]}
//              ^ add space here!

Result:

❯ esbuild a.ts
() => {
  return [1];
};

Thanks!

@evanw evanw closed this as completed in 512eb19 Mar 20, 2021
@evanw
Copy link
Owner

evanw commented Mar 20, 2021

Thanks for the report. This was tripping up esbuild's TypeScript parser because the >= token was split into a > token and a = token because the > token is needed to close the type parameter list, but the = token was not being combined with the following > token to form a => token. To fix this, esbuild needs to expand the = token into the following characters if possible, which can result in a =>, ==, or === token. The fix for this will go out with the next release.

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

Successfully merging a pull request may close this issue.

2 participants