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

Update pinejs-client-core to add support for using model specific typings #23

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

Page-
Copy link
Contributor

@Page- Page- commented Jun 14, 2024

Update pinejs-client-core from 6.14.13 to 6.15.0

Change-type: minor

@Page- Page- requested a review from a team June 17, 2024 16:50
@Page- Page- marked this pull request as ready for review June 17, 2024 16:50
@flowzone-app flowzone-app bot enabled auto-merge June 17, 2024 16:53
@Page- Page- requested a review from thgreasi June 19, 2024 10:00
…ings

Update pinejs-client-core from 6.14.13 to 6.15.2

Change-type: minor
Comment on lines +311 to +313
) as PromiseResult<
ResolvableReturnType<PinejsClientCore<unknown, Model>['delete']>
>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) as PromiseResult<
ResolvableReturnType<PinejsClientCore<unknown, Model>['delete']>
>;
) as PromiseResult<void>;

Copy link
Contributor Author

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;

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 :)

Copy link
Contributor Author

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

Comment on lines +32 to +34
: U['$expand'] extends { [key in StringKeyOf<T>]?: any }
? StringKeyOf<U['$expand']>
: never;

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?

Copy link
Contributor Author

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)

@Page- Page- requested review from fisehara and a team June 19, 2024 13:08
@flowzone-app flowzone-app bot merged commit 4f8eb6f into master Jun 19, 2024
48 checks passed
@flowzone-app flowzone-app bot deleted the model-based-typings branch June 19, 2024 13:36
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

Successfully merging this pull request may close these issues.

2 participants