Skip to content

Commit a04bb02

Browse files
fix(jsr): drop slow types from next/react adapters; remove --allow-slow-types
JSR's slow-type analyzer flagged the two adapter factory functions (createAhizeComponent, createUseAhize) as missing explicit return types — both inferred their return through deeply generic React component / hook signatures. Add explicit type aliases: - NextAhizeComponent: the generic React component returned by createAhizeComponent(React, nextNav). - AhizeReactHook (now declared up-front instead of via ReturnType<>): the useAhize hook returned by createUseAhize(React). With both fixed, `npx jsr publish --dry-run` no longer reports any slow types, so we drop the --allow-slow-types flag from the release workflow. This also lifts the JSR score (slow-types was a Missing category) and restores the score's "automatic .d.ts generation" benefit for Node.js consumers who pull the package via JSR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 072bf7b commit a04bb02

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5353

5454
- name: 🦕 Publish to JSR (OIDC)
55-
run: npx jsr publish --allow-slow-types
55+
run: npx jsr publish
5656

5757
- name: 📝 Generate changelog
5858
run: pnpm dlx changelogithub

src/adapters/next.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ export interface NextAhizeOptions<T extends LoadOptions> {
4949
autoPageView?: boolean
5050
}
5151

52-
export function createAhizeComponent(React: ReactLike, nextNav?: NextAppRouterHooks) {
53-
return function Ahize<T extends LoadOptions>(props: NextAhizeOptions<T>) {
52+
export type NextAhizeComponent = <T extends LoadOptions>(props: NextAhizeOptions<T>) => null
53+
54+
export function createAhizeComponent(
55+
React: ReactLike,
56+
nextNav?: NextAppRouterHooks,
57+
): NextAhizeComponent {
58+
return function Ahize<T extends LoadOptions>(props: NextAhizeOptions<T>): null {
5459
React.useEffect(() => {
5560
let mounted = true
5661
props.provider.load(props.options).then(() => {

src/adapters/react.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export interface UseAhizeReturn {
4040
pageView: AhizeProvider["pageView"]
4141
}
4242

43-
export function createUseAhize(React: ReactLike) {
43+
export type AhizeReactHook = <T extends LoadOptions>(opts: UseAhizeOptions<T>) => UseAhizeReturn
44+
45+
export function createUseAhize(React: ReactLike): AhizeReactHook {
4446
return function useAhize<T extends LoadOptions>(opts: UseAhizeOptions<T>): UseAhizeReturn {
4547
const { provider, options, destroyOnUnmount = false } = opts
4648
const [identity, setIdentity] = React.useState<IdentityState>(provider.getIdentity())
@@ -75,5 +77,3 @@ export function createUseAhize(React: ReactLike) {
7577
}
7678
}
7779
}
78-
79-
export type AhizeReactHook = ReturnType<typeof createUseAhize>

0 commit comments

Comments
 (0)