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

panic: Expected scope (7, 0) in index.ts, found scope (7, 2) (while parsing "index.ts") #2991

Closed
jakebailey opened this issue Mar 15, 2023 · 5 comments

Comments

@jakebailey
Copy link

jakebailey commented Mar 15, 2023

I was futzing around with decorators and thought I'd throw a new-style decorator into esbuild to see what old-style decorators would have output (was too lazy to open a new TS playground and change settings).

I was surprised to see a panic:

Error: Build failed with 1 error:
error: panic: Expected scope (7, 0) in index.ts, found scope (7, 2) (while parsing "index.ts")

The code is just:

@((target, context) => {
  target.staticProp
  //      ^?
})
class Foo {
  static staticProp = 1234;
}

Which, is not legal TS code for old-style decorators, but is for new-style. esbuild doesn't support new style decorators yet, but, the panicking seems unintentional.

esbuild playground

@hyrious
Copy link

hyrious commented Mar 15, 2023

Except for the new decorator proposal, the decorator expression is also valid TypeScript.

TypeScript Playground Link

@jakebailey
Copy link
Author

Hm. With my exact code, I got errors. Maybe that's not right.

@jakebailey
Copy link
Author

Ah, it's just because of that second parameter, apparently.

@evanw
Copy link
Owner

evanw commented Mar 15, 2023

Sorry about that. Looks like I'm missing test coverage for decorators that are inline function expressions. Will fix.

@evanw evanw closed this as completed in 3b38ce3 Mar 15, 2023
@jakebailey
Copy link
Author

Thanks for the fix!

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

3 participants