-
Notifications
You must be signed in to change notification settings - Fork 253
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
refactor(clerk-js,nextjs,types): Add Autocomplete generic [SDK-900] #2132
Conversation
🦋 Changeset detectedLatest commit: 54171c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
39bf95a
to
54171c2
Compare
@@ -805,7 +805,7 @@ type PrimitiveKeys<T> = { | |||
[K in keyof T]: T[K] extends string | boolean | number | null ? K : never; | |||
}[keyof T]; | |||
|
|||
type LooseExtractedParams<T extends string> = `:${T}` | (string & NonNullable<unknown>); |
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.
Is NonNullable<unknown>
the same as Record<never, 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.
It ultimately produces the same result.
if (!res?.response) { | ||
return { | ||
total_count: 0, | ||
data: [], | ||
}; | ||
} | ||
|
||
// TODO: Fix typing | ||
const { data: suggestions, total_count } = | ||
res?.response as unknown as ClerkPaginatedResponse<OrganizationMembershipJSON>; | ||
res.response as unknown as ClerkPaginatedResponse<OrganizationMembershipJSON>; |
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.
How come this is a necessary change ? I believe you are using this logic in more places, shall we update the rest as well ?
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.
@panteliselef I was running into build issues, per typing. The _fetch
returns (and its generic extends) ClerkResourceJSON | DeletedObjectJSON | null
which doesn't fit the desired ClerkPaginatedResponse<OrganizationMembershipJSON>
type.
We might want to expand upon this, however, I didn't feel this was the PR to do it.
|
||
if (!json?.response) { | ||
return this.fromJSON(null); | ||
} | ||
|
||
// TODO: Fix typing | ||
const currentMembership = (json.response as unknown as OrganizationMembershipJSON[]).find( |
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.
ditto
Description
Adds Autocomplete Typescript generic util.
SDK-900
Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change
Packages affected
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/clerk-expo
@clerk/fastify
gatsby-plugin-clerk
@clerk/localizations
@clerk/nextjs
@clerk/clerk-react
@clerk/remix
@clerk/clerk-sdk-node
@clerk/shared
@clerk/themes
@clerk/types
build/tooling/chore