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

There is a bug about decorators support in esbuild #15

Open
jincandev opened this issue Dec 11, 2021 · 5 comments
Open

There is a bug about decorators support in esbuild #15

jincandev opened this issue Dec 11, 2021 · 5 comments

Comments

@jincandev
Copy link

Code Position: esbuild-decorators.ts

Regular expressions don't work when decorator functions start with '$'. for example:

function Test(target: any, key?: string, pKey?: any) {
  if(!key) {
    return
  }
  console.log(">>>", Reflect.getMetadata("design:type", target, key))
}

@$Test
class Nardy {

  @$Test
  private name: Date = new Date()

  @$Test
  setName() {}

}

I think we should judge the legal function name instead of limiting it to letters, numbers and underscores next the '@' character

@Brian-McBride
Copy link
Contributor

Hrm, that sounds like a good idea.

I'll look to fix this tomorrow (the 12th), but if you have the time to create a PR with a regex that matches legal function names, that would be awesome.

@Brian-McBride
Copy link
Contributor

Well, it seems a bit more complicated.
https://stackoverflow.com/questions/2008279/validate-a-javascript-function-name

Seems the answer might be in this codebase:
https://github.com/mathiasbynens/mothereff.in/tree/master/js-variables

@jincandev
Copy link
Author

I created a module on npmjs and I didn't use a module like strip-it.ts to take ast analysis function but directly uses regular expressions to judge. Will this be a problem?

@Brian-McBride
Copy link
Contributor

I can't comment on your code as you didn't link your git repository.

@jincandev
Copy link
Author

jincandev commented Dec 13, 2021

I can't comment on your code as you didn't link your git repository.

Ah, I just created the GIT repository. Before that, I only created gitee. Here is my link:
https://github.com/jcindex/esbuild-plugin-typescript-decorators

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