-
Notifications
You must be signed in to change notification settings - Fork 169
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
Uncaught TypeInfo not known for function Bar(foo) #29
Comments
Do you have the following in your "compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
} |
@Xapphire13 Yes
|
You have an |
@Xapphire13 Yes, otherwize it would be |
No I haven't tried that yet. The error about polyfill is relatively new and you never specified the version you're using, I just wanted to cover all bases. |
I just created a react-app using I then did some digging and this is because decorators are explicitly disabled for In order to use decorators you must eject your app first. |
@Xapphire13 They support decorators for typescript
Works just fine. |
The next thing would be the babel config that For some reason all the type info is stripped. I personally use |
Ok. I think it will be solved with this facebook/create-react-app#6388 |
If you stumble upon this issue outside of React, be sure that the service you're resolving has a |
hmmm... getting this in a jest test...
it's complaining at
I'm sure I've done something wrong... but this feels like a red herring, like where is the thing that's really wrong? |
I ended up walking through my "resolutions" until I found the ones, failing, they needed an could we reopen this for better exceptions? |
I opened a new issue #70 |
Anyone stumbling over this issue, check if you imported the class via I had other types imported from a file when I auto-imported the class from it (which added it to the Maybe this specific problem could be solved with an eslint rule or something. |
For those struggling with this error in create-react-app typescript, the issue doesn't appear to be resolved against the latest version. As noted above, CRA supports ts decorators (test here) and emitting decorator metadata. The issue is that babel still strips this metadata out, where babel is used in the web bundle and jest by CRA. See these issues for context: I solved this in my case without ejecting by using craco to configure babel to use babel-plugin-transform-typescript-metadata |
I had this same issue with Expo, this solution worked for me: inversify/InversifyJS#1007 (comment) |
Had this issue on React Native. I had some decorated classes that depended on objects outside the class. Refactoring those fixed the issue. |
I have this same issue with Vite3, is this library not compatible with Vite? |
Vite uses esbuild under the hood which doesn't emit decorator metadata. There are a few options to work around this in practice, all involving transpiling modules with something other than esbuild like babel or swc. In my case, I didn't want to drag in any additional dependencies so I wrote a custom vite plugin that transpiles modules that use decorators with the vanilla typescript compiler via the programmatic API. |
If you're running into this issue with Jest, ensure you have the following plugins:
|
I created a react app with --typescript
install tsyringe and reflect-metadata and got this error
The text was updated successfully, but these errors were encountered: