-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 the type of id
on type BaseItem
, to be type unknown
, not string
#9054
base: main
Are you sure you want to change the base?
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7956a1b:
|
@@ -442,7 +442,7 @@ export async function checkUniqueItemExists ( | |||
throw missingItem(operation, uniqueInput) | |||
} | |||
|
|||
return { id: item.id.toString() } | |||
return { id: item.id } |
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.
Removing this toString
will break if you have a bigint since a bigint wouldn't be accepted by the ID
type
@@ -14,7 +14,7 @@ export type BaseListTypeInfo<Session = any> = { | |||
create: GraphQLInput | |||
update: GraphQLInput | |||
where: GraphQLInput | |||
uniqueWhere: { readonly id?: string | number | null } & GraphQLInput | |||
uniqueWhere: { readonly id?: unknown } & GraphQLInput |
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.
string | number | null
covers all that the input ID
GraphQL type could be, what does widening this help?
data: { listKey, itemId: item.id.toString() }, | ||
data: { | ||
listKey, | ||
itemId: item.id |
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.
If you had a bigint id, this would fail since JSON.stringify
with a bigint throws
This pull request updates the type of
id
on typeBaseItem
to be of typeunknown
instead ofstring
. This helps reduce a number of type errors wherestring | number | null
is possible, but onlystring
was accepted by theBaseItem
.This is not strictly related to #8846, but will likely be required as part of fixing that problem in any event.