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
| [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.
Is NonNullable<unknown> the same as Record<never, never> ?
There was a problem hiding this comment.
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.
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.
@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( |
Description
Adds Autocomplete Typescript generic util.
SDK-900
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/backend@clerk/chrome-extension@clerk/clerk-js@clerk/clerk-expo@clerk/fastifygatsby-plugin-clerk@clerk/localizations@clerk/nextjs@clerk/clerk-react@clerk/remix@clerk/clerk-sdk-node@clerk/shared@clerk/themes@clerk/typesbuild/tooling/chore