-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update pinejs-client-core to add support for using model specific typings #23
Conversation
dd28897
to
ac58588
Compare
…ings Update pinejs-client-core from 6.14.13 to 6.15.2 Change-type: minor
ac58588
to
f4679c3
Compare
) as PromiseResult< | ||
ResolvableReturnType<PinejsClientCore<unknown, Model>['delete']> | ||
>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) as PromiseResult< | |
ResolvableReturnType<PinejsClientCore<unknown, Model>['delete']> | |
>; | |
) as PromiseResult<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of the result comes from the return type of PinejsClientCore<unknown, Model>['delete']
so the current form is accurate to what it will actually be, yes we expect that to resolve to PromiseResult<void>
but if it does not for some reason (eg pinejs-client-core changes the return type) then typescript would flag it up as an error so we'd get a compile time warning with the current version but not with the as PromiseResult<void>
version
@@ -181,7 +345,7 @@ export class PineTest extends PinejsClientCore<unknown> { | |||
}: { | |||
method: supportedMethod; | |||
url: string; | |||
body: Params['body']; | |||
body: AnyObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for understanding:
- this changes from Partial<T['Write']> to
AnyObject
- which comes from
export type AnyResource = {
Read: AnyObject;
Write: AnyObject;
};
So it's the same :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the same, but more notably the pinejs-client-core typings for this actually specify body: AnyObject
so this version matches that, but I've now updated it to directly take the typings from the parent class outside of the user
extension
: U['$expand'] extends { [key in StringKeyOf<T>]?: any } | ||
? StringKeyOf<U['$expand']> | ||
: never; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't in this case expand always an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is the case where $expand
did not match any type from which we can infer the expanded keys so it is a never
case - it should not happen and we type it like this to let typescript know that (and if it does happen because someone has gone outside of the typings or similar then typescript will error)
Update pinejs-client-core from 6.14.13 to 6.15.0
Change-type: minor