Skip to content

chore(shared,types,clerk-react,vue): Share hook return types - #4583

Merged
wobsoriano merged 3 commits into
mainfrom
rob/eco-231-share-react-hook-types
Nov 18, 2024
Merged

chore(shared,types,clerk-react,vue): Share hook return types#4583
wobsoriano merged 3 commits into
mainfrom
rob/eco-231-share-react-hook-types

Conversation

@wobsoriano

@wobsoriano wobsoriano commented Nov 15, 2024

Copy link
Copy Markdown
Member

Description

This PR moves the hook return types from @clerk/clerk-react and @clerk/shared to @clerk/types to be used with @clerk/vue's composables.

See PR comment for reference.

Note: The useOrganization() and useOrganizationList() hook return types are not included since pagination is not yet implemented in @clerk/vue.

Resolves ECO-231

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented Nov 15, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fca77a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-react Patch
@clerk/shared Patch
@clerk/types Patch
@clerk/vue Patch
@clerk/chrome-extension Patch
@clerk/elements Patch
@clerk/clerk-expo Patch
@clerk/nextjs Patch
@clerk/remix Patch
@clerk/tanstack-start Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/clerk-js Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nuxt Patch
@clerk/clerk-sdk-node Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/localizations Patch
@clerk/themes Patch

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

@wobsoriano
wobsoriano marked this pull request as ready for review November 15, 2024 17:09
@wobsoriano wobsoriano changed the title chore(types,clerk-react,vue): Share hook return types chore(shared,types,clerk-react,vue): Share hook return types Nov 15, 2024
@panteliselef

Copy link
Copy Markdown
Contributor

In same cases we might need to only edit only types for react and not vue. For example, adding experimental features, which usually are only implemented for the react hooks. Do you think this PR will make that process harder ? If not this move is reasonable.

@wobsoriano

wobsoriano commented Nov 15, 2024

Copy link
Copy Markdown
Member Author

In same cases we might need to only edit only types for react and not vue. For example, adding experimental features, which usually are only implemented for the react hooks. Do you think this PR will make that process harder ? If not this move is reasonable.

Good question! I think we have 2 approaches in case of experimental features:

  1. Say an experimental property in the UseSessionListReturn hook for example:
export type UseSessionListReturn =
  | {
      isLoaded: false;
      sessions: undefined;
      setActive: undefined;
      __experimental_test: undefined
    }
  | {
      isLoaded: true;
      sessions: SessionResource[];
      setActive: SetActive;
      __experimental_test: true
    };

We can keep this in @clerk/types, then in @clerk/vue we can use the utility type we have that omits without union flattening

import type { Without } from '@clerk/types'

type type VueUseSessionListReturn = Without<UseSessionListReturn, '__experimental'>

The only problem I can see with this is that @clerk/vue will also need to be updated when adding @clerk/clerk-react experimental features

  1. If it can't be done with number 1, then probably rewrite the hook return type in @clerk/clerk-react with the experimental flag for example 🤷

What do you think?

@wobsoriano
wobsoriano requested a review from LekoArts November 16, 2024 23:32
@panteliselef

Copy link
Copy Markdown
Contributor

Probably i'd just expands the types for react only

@wobsoriano

Copy link
Copy Markdown
Member Author

Probably i'd just expands the types for react only

sounds good to me

@wobsoriano
wobsoriano merged commit e47eb58 into main Nov 18, 2024
@wobsoriano
wobsoriano deleted the rob/eco-231-share-react-hook-types branch November 18, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants