Skip to content

Commit

Permalink
Simplify the custom typings pinejs-client after the Concept type unif…
Browse files Browse the repository at this point in the history
…ication

Change-type: patch
  • Loading branch information
thgreasi committed Oct 25, 2024
1 parent 9f1d46a commit fc41028
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions typings/pinejs-client-core.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { WebResourceFile } from 'balena-request';
import type {
AnyObject,
PropsAssignableWithType,
PropsOfType,
StringKeyof,
Dictionary,
Expand Down Expand Up @@ -37,7 +36,6 @@ export type OptionalNavigationResource<T extends object> =
export type ReverseNavigationResource<T extends object> = T[] | undefined;

export type AssociatedResource<T extends object> =
| ConceptTypeNavigationResource<T>
| NavigationResource<T>
| OptionalNavigationResource<T>
| ReverseNavigationResource<T>;
Expand All @@ -55,18 +53,14 @@ export type SelectableProps<T> =
>; // This is the normal typed case

export type ExpandableProps<T> = PropsOfType<T, AssociatedResource<object>> &
// TODO: Drop me once Pine unifies ConceptTypeNavigationResource with NavigationResource
PropsAssignableWithType<T, [] | [any] | any[]> &
string;

type SelectedProperty<T, K extends keyof T> =
T[K] extends NavigationResource<any>
? PineDeferred
: T[K] extends OptionalNavigationResource<any>
? PineDeferred | null
: T[K] extends ConceptTypeNavigationResource<any>
? Exclude<T[K], any[]>
: T[K];
: T[K];

type SelectResultObject<T, Props extends keyof T> = {
[P in Props]: SelectedProperty<T, P>;
Expand All @@ -92,7 +86,7 @@ type ExpandedProperty<
> =
KOpts extends ODataOptionsWithCount<any>
? number
: T[K] extends NavigationResource<any> | ConceptTypeNavigationResource<any>
: T[K] extends NavigationResource<any>
? [TypedResult<InferAssociatedResourceType<T[K]>, KOpts>]
: T[K] extends OptionalNavigationResource<any>
? [TypedResult<InferAssociatedResourceType<T[K]>, KOpts>] | []
Expand Down

0 comments on commit fc41028

Please sign in to comment.