-
Notifications
You must be signed in to change notification settings - Fork 37
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
Type error when using useResource
#48
Comments
Ah! That could be it. Yeah, I'd be happy with any there. It more or less is the same in this case anyway |
does upon closer inspection, it looks like you are passing an array of fields, but the type of the positional params is 0..n fields, which would be invoked as tldr: |
Unfortunately |
I made this demo, of what I thought was the issue, and the type checking passes: #49 Does this help? |
Nope. I'm starting to think maybe it's my side's problem, maybe I need to try in a new ember app instead. |
Lemme know how it goes! |
@NullVoxPopuli I can confirm the types are correct in a new ember app, now I need to figure out the problem of my side. Thank you anyway. |
@NullVoxPopuli I reopen this issue because I found the root cause; I got this error before because I set Since
|
🎉 This issue has been resolved in version 1.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@nightire do you happen to have a reproduction repo? |
@NullVoxPopuli Sorry for the delay, I've got caught up in something else this last month. Here is a reproduction: https://github.com/nightire/ember-resources-type-issue/tree/main#ember-resources-type-issue, hope it can help you. |
## [3.2.1](v3.2.0...v3.2.1) (2021-09-05) ### Bug Fixes * **types:** useResource types now reflect that you *can* make non-reactive resources ([9059c90](9059c90)), closes [#48](#48)
🎉 This issue has been resolved in version 3.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@nightire can you try this latest release?, 3.2.1? |
Unfortunately, the error remains. I can live with |
Does the error in your reproduction go away? |
I have upgraded the ember-resources in my reproduction, and the error remains. This repro is a brand new v3.28.0 ember application with the latest ember-cli-typescript and ember-resources, nothing else. BTW, this small change will solve the error as I mentioned at the beginning of this issue. Is it an acceptable solution? I'm not an expert on typescript, just ask for curiosity. export interface Constructable<T = unknown> {
- new (...args: unknown[]): T;
+ new (...args: any[]): T;
} |
I also just hit this issue after enabling |
You can use
I found this setting is not that important as we thought it would be, according to the official document:
|
fixed via... deprecation 😅 better alternative landed in v4.5 |
First of all, I can not write a failing test because in test cases, we instantiate the resource class directly, but the type error is caused by
useResource
utility function.Then I spend a little time investigating what's going on with
useResource
, here when describing the arguments ofConstructable
, I found:If I change it to
any[]
or more precisely(Positional | Named)[]
, the problem will be solved, at least for my case. I'm not sure if this fix is correct, @NullVoxPopuli how do you think?The text was updated successfully, but these errors were encountered: