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

Fix issue in typeSelection.ts when handling nullable non-scalars #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cli/src/runtime/typeSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ export type FieldsSelection<SRC extends Anify<DST> | undefined, DST> = {
: never
__scalar: Handle__scalar<SRC, DST>
never: never
null: null
}[DST extends Nil
? 'never'
: DST extends false | 0
? 'never'
: SRC extends Scalar
? 'scalar'
: SRC extends null
? 'null'
: SRC extends any[]
? 'array'
: SRC extends { __isUnion?: any }
Expand Down Expand Up @@ -73,9 +76,9 @@ type Handle__scalar<SRC extends Anify<DST>, DST> = SRC extends Nil
? never
: Key extends FieldsToRemove
? never
: SRC[Key] extends Scalar
? Key
: Key extends keyof DST
? (DST[Key] extends false ? never : Key)
: SRC[Key] extends Scalar | null
? Key
: never
}[keyof SRC]
Expand All @@ -85,7 +88,7 @@ type Handle__isUnion<SRC extends Anify<DST>, DST> = SRC extends Nil
? never
: Omit<SRC, FieldsToRemove> // just return the union type

type Scalar = string | number | Date | boolean | null | undefined
type Scalar = string | number | Date | boolean | undefined

type Anify<T> = { [P in keyof T]?: any }

Expand Down