-
Notifications
You must be signed in to change notification settings - Fork 401
feat(shared,types): Migrate @clerk/types to @clerk/shared/types #7022
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
base: main
Are you sure you want to change the base?
Changes from all commits
c29586b
15551ec
c98b464
083ef3d
31dd221
4e9cdf0
73e31d0
a5e40af
053c07e
5d75555
40c4118
caf27cc
65cf7f6
72d97d2
0c72edb
42fce5e
99d20a4
8b82759
f00a0f0
3c50200
b21da21
20276ca
55c4907
955dce8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| '@clerk/types': minor | ||
| '@clerk/shared': minor | ||
| '@clerk/astro': patch | ||
| '@clerk/backend': patch | ||
| '@clerk/chrome-extension': patch | ||
| '@clerk/clerk-js': patch | ||
| '@clerk/elements': patch | ||
| '@clerk/themes': patch | ||
| '@clerk/vue': patch | ||
| --- | ||
|
|
||
| Deprecate `@clerk/types` in favor of `@clerk/shared/types` | ||
|
|
||
| The `@clerk/types` package is now deprecated. All type definitions have been consolidated and moved to `@clerk/shared/types` to improve consistency across the Clerk ecosystem. | ||
|
|
||
| **Backward Compatibility:** | ||
|
|
||
| The `@clerk/types` package will remain available and will continue to re-export all types from `@clerk/shared/types` to ensure backward compatibility. Existing applications will continue to work without any immediate breaking changes. However, we strongly recommend migrating to `@clerk/shared/types` as new type definitions and updates will only be added to `@clerk/shared/types` starting with the next major release. | ||
|
|
||
| **Migration Steps:** | ||
|
|
||
| Please update your imports from `@clerk/types` to `@clerk/shared/types`: | ||
|
|
||
| ```typescript | ||
| // Before | ||
| import type { ClerkResource, UserResource } from '@clerk/types'; | ||
|
|
||
| // After | ||
| import type { ClerkResource, UserResource } from '@clerk/shared/types'; | ||
| ``` | ||
|
|
||
| **What Changed:** | ||
|
|
||
| All type definitions including: | ||
| - Resource types (User, Organization, Session, etc.) | ||
| - API response types | ||
| - Configuration types | ||
| - Authentication types | ||
| - Error types | ||
| - And all other shared types | ||
|
|
||
| Have been moved from `packages/types/src` to `packages/shared/src/types` and are now exported via `@clerk/shared/types`. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,6 @@ describe('Typedoc output', () => { | |
| "clerk-react", | ||
| "nextjs", | ||
| "shared", | ||
| "types", | ||
| ] | ||
| `); | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,11 @@ import type { SdkAdapter } from '../lib/types'; | |
| * For more details, take a look at the LangChain docs https://js.langchain.com/docs/how_to/custom_tools | ||
| */ | ||
| export const adapter: SdkAdapter<StructuredTool> = (clerkClient, context, clerkTool) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add explicit return type annotation. The function is missing an explicit return type. Public APIs should have explicit return types for clarity and type safety. Apply this diff: -export const adapter: SdkAdapter<StructuredTool> = (clerkClient, context, clerkTool) => {
+export const adapter: SdkAdapter<StructuredTool> = (clerkClient, context, clerkTool): StructuredTool => {As per coding guidelines. 🤖 Prompt for AI Agents |
||
| return tool(clerkTool.bindExecute(clerkClient, context), { | ||
| const executeFn = clerkTool.bindExecute(clerkClient, context as any) as any; | ||
| const toolConfig = { | ||
| name: clerkTool.name, | ||
| description: clerkTool.description, | ||
| schema: clerkTool.parameters, | ||
| }); | ||
| } as any; | ||
| return tool(executeFn, toolConfig) as StructuredTool; | ||
|
Comment on lines
+11
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainReplace excessive The code uses multiple Instead of forcing types with
Run the following script to inspect the type definitions: As per coding guidelines. 🏁 Script executed: #!/bin/bash
# Find ClerkTool interface/type definition to understand bindExecute signature
ast-grep --pattern 'interface ClerkTool {
$$$
bindExecute($$$) $$$
$$$
}'
ast-grep --pattern 'type ClerkTool = {
$$$
bindExecute($$$) $$$
$$$
}'
# Find the tool function signature from langchain
rg -n -A 5 "export.*function tool" --type=ts
# Look for type definitions in the lib/types file
cat packages/agent-toolkit/src/lib/types.tsLength of output: 1989 I need to search for the ClerkTool definition and examine the adapter.ts file more closely. 🏁 Script executed: #!/bin/bash
# Find and read clerk-tool file
find . -name "clerk-tool*" -type f | head -5
# Look at adapter.ts full context
cat packages/agent-toolkit/src/langchain/adapter.tsLength of output: 738 🏁 Script executed: #!/bin/bash
# Read the ClerkTool definition file
cat packages/agent-toolkit/src/lib/clerk-tool.tsLength of output: 2130 Remove unnecessary The code contains problematic
Replace with properly typed assignments. Since const executeFn = clerkTool.bindExecute(clerkClient, context);
const toolConfig = {
name: clerkTool.name,
description: clerkTool.description,
schema: clerkTool.parameters,
};
return tool(executeFn, toolConfig) as StructuredTool;🤖 Prompt for AI Agents |
||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| import { deriveState } from '@clerk/shared/deriveState'; | ||||||
| import { eventMethodCalled } from '@clerk/shared/telemetry'; | ||||||
| import type { SignedInSessionResource } from '@clerk/types'; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainLeftover import from @clerk/types—migrate to @clerk/shared/types This file still pulls -import type { SignedInSessionResource } from '@clerk/types';
+import type { SignedInSessionResource } from '@clerk/shared/types';🏁 Script executed: #!/usr/bin/env bash
# Audit repo for lingering @clerk/types imports
rg -nP --type=ts --type=tsx --type=js --type=jsx -g '!**/node_modules/**' "\@clerk/types"Length of output: 27 Length of output: 68479 🏁 Script executed: #!/bin/bash
# Verify the specific file mentioned in the review
cat packages/astro/src/stores/external.tsLength of output: 5381 🏁 Script executed: #!/bin/bash
# Check if @clerk/shared/types exists and what it exports
find . -path '*/node_modules' -prune -o -type f -name 'index.ts' -o -name 'types.ts' | grep -i "clerk/shared"Length of output: 0 🏁 Script executed: #!/bin/bash
# Find the @clerk/shared package structure
find packages/shared -type f -name "*.ts" -o -name "*.tsx" | head -20Length of output: 992 🏁 Script executed: #!/bin/bash
# Check package.json exports for @clerk/shared
cat packages/shared/package.json 2>/dev/null | grep -A 20 '"exports"'Length of output: 512 🏁 Script executed: #!/bin/bash
# Search for SignedInSessionResource export in @clerk/shared
rg -n "SignedInSessionResource" packages/shared --type ts --type tsxLength of output: 27 🏁 Script executed: #!/bin/bash
# Search for SignedInSessionResource in packages/shared (corrected syntax)
rg -n "SignedInSessionResource" packages/shared --type tsLength of output: 1544 🏁 Script executed: #!/bin/bash
# Check packages/types to see where SignedInSessionResource is defined
rg -n "SignedInSessionResource" packages/types/src --type ts -A 2Length of output: 0 🏁 Script executed: #!/bin/bash
# List top-level source files in packages/shared
ls -la packages/shared/src/*.ts 2>/dev/null | head -30Length of output: 2575 🏁 Script executed: #!/bin/bash
# Check if packages/shared has a types.ts or similar
find packages/shared/src -maxdepth 1 -name "*types*" -o -name "*index*"Length of output: 54 🏁 Script executed: #!/bin/bash
# Verify packages/types re-exports from @clerk/shared
cat packages/types/src/index.d.ts 2>/dev/null | head -30Length of output: 313 🏁 Script executed: #!/bin/bash
# Check if other astro files still use @clerk/types for comparison
rg -n "@clerk/types" packages/astro/src --type tsLength of output: 1984 Migrate import to @clerk/shared/types for consistency with package deprecation The review comment is correct. The -import type { SignedInSessionResource } from '@clerk/types';
+import type { SignedInSessionResource } from '@clerk/shared/types';📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| import { batched, computed, onMount, type Store } from 'nanostores'; | ||||||
|
|
||||||
| import { $clerk, $csrState, $initialState } from './internal'; | ||||||
|
|
@@ -51,7 +52,7 @@ export const $userStore = computed([$authStore], auth => auth.user); | |||||
| * @example | ||||||
| * $sessionStore.subscribe((session) => console.log(session.id)) | ||||||
| */ | ||||||
| export const $sessionStore = computed([$authStore], auth => auth.session); | ||||||
| export const $sessionStore = computed([$authStore], auth => auth.session as SignedInSessionResource | null | undefined); | ||||||
|
|
||||||
| /** | ||||||
| * A client side store that is populated after clerk-js has loaded. | ||||||
|
|
||||||
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.
🧩 Analysis chain
Verify the new build tooling is properly configured across all packages.
Two new build tools have been added as dev dependencies:
rolldown(line 138) - a Rust-based bundlertsdown(line 142) - a TypeScript declaration bundlerSince this is part of the migration from
tsuptotsdown/rolldown, ensure that:tsdown.config.mts)Run the following to verify the build tooling setup:
🏁 Script executed:
Length of output: 986
I need to verify if this partial migration is intentional and check the build scripts in packages that still use tsup.
Let me check the build scripts to see which tools are being used in the packages:
Let me examine the actual build scripts in the packages to understand the state better:
🏁 Script executed:
Length of output: 2357
Build tooling migration is incomplete—only 1 of ~20 packages has been migrated to tsdown.
The verification confirms the review comment's concern: the migration from
tsuptotsdown/rolldownis not yet complete across all packages.Current state:
packages/sharedhastsdown.config.mtsand usestsdownin build scriptstsup.config.tsfiles andtsupcommands in build scripts (agent-toolkit,astro,backend,chrome-extension,elements,expo,expo-passkeys,express,fastify,localizations,nextjs,nuxt,react,react-router,remix,tanstack-react-start,testing,themes,vue)Both tooling versions remain in the pnpm workspace catalog (
tsup: 8.5.0,tsdown: 0.15.7,rolldown: 1.0.0-beta.43).Either complete the migration across remaining packages or document why the partial migration is intentional.
🤖 Prompt for AI Agents