Skip to content

Commit a2fef7b

Browse files
committed
feat(*): add /types subpath export to SDK packages
Why: Developers currently need to install @clerk/types as a separate package to access Clerk types. This adds friction and can cause version mismatches between the types package and SDK. What changed: Added /types subpath export to 11 SDK packages that re-exports types from @clerk/shared/types along with SDK-specific types. Developers can now import types directly from their SDK: import type { UserResource } from '@clerk/react/types' Packages updated: - @clerk/react - @clerk/nextjs - @clerk/tanstack-react-start - @clerk/react-router - @clerk/express - @clerk/fastify - @clerk/astro - @clerk/nuxt - @clerk/vue - @clerk/expo - @clerk/chrome-extension
1 parent d72955e commit a2fef7b

33 files changed

Lines changed: 316 additions & 27 deletions

File tree

.changeset/types-subpath-export.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@clerk/react': minor
3+
'@clerk/nextjs': minor
4+
'@clerk/tanstack-react-start': minor
5+
'@clerk/react-router': minor
6+
'@clerk/express': minor
7+
'@clerk/fastify': minor
8+
'@clerk/astro': minor
9+
'@clerk/nuxt': minor
10+
'@clerk/vue': minor
11+
'@clerk/expo': minor
12+
'@clerk/chrome-extension': minor
13+
---
14+
15+
Add `/types` subpath export to re-export types from `@clerk/shared/types` along with SDK-specific types. This allows importing Clerk types directly from the SDK package (e.g., `import type { UserResource } from '@clerk/react/types'`) without needing to install `@clerk/types` as a separate dependency.

packages/astro/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
"types": "./dist/webhooks.d.ts",
6060
"default": "./dist/webhooks.js"
6161
},
62+
"./types": {
63+
"types": "./dist/types/index.d.ts",
64+
"default": "./dist/types/index.js"
65+
},
6266
"./env": "./env.d.ts",
6367
"./components": "./components/index.ts",
6468
"./package.json": "./package.json"

packages/astro/src/types/index.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Re-export all shared types
3+
*/
4+
export type * from '@clerk/shared/types';
5+
6+
/**
7+
* Astro-specific types
8+
*/
9+
export type {
10+
AstroClerkUpdateOptions,
11+
AstroClerkIntegrationParams,
12+
AstroClerkCreateInstanceParams,
13+
HeadlessBrowserClerk,
14+
BrowserClerk,
15+
ProtectParams,
16+
ProtectProps,
17+
ShowProps,
18+
ButtonProps,
19+
InternalUIComponentId,
20+
} from '../types';
21+
22+
/**
23+
* Astro server types
24+
*/
25+
export type {
26+
AstroMiddleware,
27+
AstroMiddlewareContextParam,
28+
AstroMiddlewareNextParam,
29+
AstroMiddlewareReturn,
30+
SessionAuthObjectWithRedirect,
31+
AuthFn,
32+
} from '../server/types';
33+
34+
/**
35+
* Astro React types
36+
*/
37+
export type { SignInButtonProps, SignUpButtonProps } from '../react/types';

packages/astro/tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig(() => {
1515
'./src/async-local-storage.client.ts',
1616
'./src/async-local-storage.server.ts',
1717
'./src/webhooks.ts',
18+
'./src/types/index.ts',
1819
],
1920
dts: true,
2021
minify: false,

packages/chrome-extension/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"background",
3030
"dist",
3131
"internal",
32-
"react"
32+
"react",
33+
"types"
3334
],
3435
"scripts": {
3536
"build": "tsup",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Re-export all shared types from @clerk/shared/types
3+
*/
4+
export type * from '@clerk/shared/types';
5+
6+
/**
7+
* Chrome Extension-specific types
8+
*/
9+
10+
// Core types from src/types.ts
11+
export type { Scope, ClerkClientExtensionFeatures } from '../types';
12+
13+
// Storage types
14+
export type { StorageCache } from '../internal/utils/storage';
15+
16+
// Internal Clerk client options
17+
export type { CreateClerkClientOptions } from '../internal/clerk';

packages/chrome-extension/tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineConfig(overrideOptions => {
99
const shouldPublish = !!overrideOptions.env?.publish;
1010

1111
const common: Options = {
12-
entry: ['./src/index.ts', './src/background/index.ts', './src/react/index.ts'],
12+
entry: ['./src/index.ts', './src/background/index.ts', './src/react/index.ts', './src/types/index.ts'],
1313
bundle: true,
1414
clean: true,
1515
minify: false,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"main": "../dist/cjs/types/index.js",
3+
"module": "../dist/esm/types/index.js",
4+
"types": "../dist/types/types/index.d.ts"
5+
}

packages/expo/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
"types": "./dist/legacy.d.ts",
6161
"default": "./dist/legacy.js"
6262
},
63+
"./types": {
64+
"types": "./dist/types/index.d.ts",
65+
"default": "./dist/types/index.js"
66+
},
6367
"./app.plugin.js": "./app.plugin.js"
6468
},
6569
"main": "./dist/index.js",

packages/expo/src/types/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Re-export all types from @clerk/shared/types
2+
export type * from '@clerk/shared/types';
3+
4+
// Expo-specific types
5+
export type { ClerkProviderProps } from '../provider/ClerkProvider';
6+
export type { TokenCache, ResourceCache, ResourceCacheInitOptions } from '../cache/types';
7+
export type { IStorage, BuildClerkOptions } from '../provider/singleton/types';
8+
9+
// OAuth/SSO hook types
10+
export type { UseOAuthFlowParams, StartOAuthFlowParams, StartOAuthFlowReturnType } from '../hooks/useOAuth';
11+
export type { StartSSOFlowParams, StartSSOFlowReturnType } from '../hooks/useSSO';
12+
13+
// Google Sign-In types
14+
export type {
15+
StartGoogleAuthenticationFlowParams,
16+
StartGoogleAuthenticationFlowReturnType,
17+
} from '../hooks/useSignInWithGoogle.types';
18+
19+
// Google One Tap types
20+
export type {
21+
ConfigureParams,
22+
SignInParams,
23+
CreateAccountParams,
24+
ExplicitSignInParams,
25+
GoogleUser,
26+
OneTapSuccessResponse,
27+
CancelledResponse,
28+
NoSavedCredentialFound,
29+
OneTapResponse,
30+
GoogleSignInErrorCode,
31+
GoogleSignInError,
32+
} from '../google-one-tap/types';

0 commit comments

Comments
 (0)