Skip to content

fix: resolve non-portable types and enable verbatimModuleSyntax#180

Merged
halvaradop merged 4 commits into
masterfrom
fix/resolve-unportable-types
Jun 5, 2026
Merged

fix: resolve non-portable types and enable verbatimModuleSyntax#180
halvaradop merged 4 commits into
masterfrom
fix/resolve-unportable-types

Conversation

@halvaradop
Copy link
Copy Markdown
Member

@halvaradop halvaradop commented Jun 5, 2026

Description

This pull request fixes non-portable types across the auth packages, including @aura-stack/react-router and @aura-stack/express.

These packages were causing TypeScript errors when consuming the api object returned by createAuth, as some exported types could not be properly named or referenced in generated declaration files.

Additionally, this PR enables the TypeScript verbatimModuleSyntax compiler option. This enforces explicit type-only imports and exports by requiring the type keyword when importing or exporting types, resulting in clearer module boundaries and improved type portability.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
auth Skipped Skipped Jun 5, 2026 9:03pm

@halvaradop halvaradop added the fix Bug fixes that correct incorrect or unexpected behavior. label Jun 5, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes.

Review Change Stack

Warning

Review limit reached

@halvaradop, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 18 minutes. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db67b093-84ab-431d-8a92-86d36b2264bf

📥 Commits

Reviewing files that changed from the base of the PR and between 3497ff6 and 835beb0.

📒 Files selected for processing (29)
  • configs/tsconfig/tsconfig.base.json
  • packages/core/package.json
  • packages/core/tsconfig.json
  • packages/device/package.json
  • packages/device/src/providers/index.ts
  • packages/device/test/providers.test.ts
  • packages/elysia/package.json
  • packages/elysia/tsconfig.json
  • packages/express/package.json
  • packages/express/src/@types/index.ts
  • packages/express/tsconfig.json
  • packages/hono/package.json
  • packages/hono/tsconfig.json
  • packages/integration/package.json
  • packages/integration/src/createAuth.ts
  • packages/integration/tsconfig.json
  • packages/jose/package.json
  • packages/jose/tsconfig.json
  • packages/next/package.json
  • packages/next/src/context.tsx
  • packages/next/test/pages-router/handler.test.ts
  • packages/rate-limiter/package.json
  • packages/rate-limiter/tsconfig.json
  • packages/react-router/package.json
  • packages/react-router/src/@types/core.ts
  • packages/react-router/src/@types/index.ts
  • packages/react-router/tsconfig.json
  • packages/react/package.json
  • packages/react/tsconfig.json
📝 Walkthrough

Walkthrough

This PR removes explicit AuthInstance type annotations from five app auth modules, standardizes type-only imports across the core package, introduces Express and React Router integration type contracts (ExpressInstance, ReactRouterAPI, ReactRouterInstance), refactors React Router client exports, and updates TypeScript compiler options and build scripts across multiple packages for consistency.

Changes

Type System Cleanup and App Auth Module Updates

Layer / File(s) Summary
App Auth Modules - Remove Explicit AuthInstance Typing
apps/bun/src/lib/auth.ts, apps/cloudflare/src/auth.ts, apps/deno/src/auth.ts, apps/oak/src/auth.ts, apps/supabase/functions/_shared/auth.ts
Removes : AuthInstance type annotation from the exported { handlers, jose, api } destructuring, relying instead on inferred typing from createAuth(...).
Type-Only Import Standardization in Core Package
packages/core/src/shared/assert.ts, packages/core/src/shared/crypto.ts, packages/core/src/shared/logger.ts, packages/jose/src/encrypt.ts
Switches type-only imports (ZodObject, ZodTypeAny, BaseSchema, ObjectSchema, GenerateKeyPairOptions, Identities, JWTPayload) to explicit import type to ensure runtime erasure.
Import Statement Reordering Across Modules
packages/core/src/actions/signIn/authorization-url.ts, packages/core/src/actions/signIn/authorization.ts, packages/core/src/router/context.ts, packages/core/src/validator/registry.ts, packages/core/test/actions/callback/userinfo.test.ts, packages/core/test/identity.test.ts, packages/core/test/oauth.test.ts, packages/core/test/types.test-d.ts
Reorganizes import declarations for consistency by moving type-only imports, regrouping runtime vs. type imports, and adjusting declaration order.

Express and React Router Integration Type Contracts

Layer / File(s) Summary
Express Integration Type Definition
packages/express/src/@types/index.ts, packages/express/src/createAuth.ts
Defines ExpressInstance<Identity> type combining AuthInstance with Express helpers (toHandler, withAuth); updates createAuth to explicitly return this type.
React Router API Type Contracts
packages/react-router/src/@types/api.ts
Introduces ReactRouterAPI interface and conditional type aliases (ReactRouterSignInReturn, ReactRouterSignOutReturn, etc.) that branch on redirect option and handle request/response conversion.
React Router Instance Type and Re-exports
packages/react-router/src/@types/core.ts, packages/react-router/src/@types/index.ts
Defines ReactRouterInstance<Identity> interface; updates module re-exports to source types from @/@types/* instead of @aura-stack/react.
React Router Implementation and Client Refactoring
packages/react-router/src/client.tsx, packages/react-router/src/createAuth.ts, packages/react-router/src/index.ts, packages/react-router/src/lib/api.ts, packages/react-router/test/context/provider.test.tsx, packages/react-router/test/context/redirect.test.tsx
Updates createAuth to return ReactRouterInstance<Identity>; adds satisfies ReactRouterAPI<DefaultUser> constraint on returned API; moves client exports to new client.tsx barrel; updates test import paths.

Build Configuration and TypeScript Compiler Options

Layer / File(s) Summary
TypeScript Configuration Updates
packages/core/tsconfig.json, packages/jose/tsconfig.json, packages/react-router/tsconfig.json, packages/react/tsconfig.json
Enables verbatimModuleSyntax: true in core, jose, and react-router; adds allowImportingTsExtensions: true to core and react; reorders compiler options.
Build Script Updates in package.json
packages/device/package.json, packages/elysia/package.json, packages/express/package.json, packages/hono/package.json, packages/integration/package.json, packages/rate-limiter/package.json, packages/react-router/package.json, packages/react/package.json, packages/next/package.json
Changes clean:cts scripts from conditional dist directory checks to unconditional find dist ... -delete invocations; adjusts end-of-file formatting.
Bundling Configuration and Import Path Standardization
packages/react/tsdown.config.ts, packages/react-router/tsdown.config.ts, packages/react/src/context.tsx, packages/react/src/hooks.ts, packages/jose/src/deriveKey.ts
Adds neverBundle for react and react-dom in React bundling; sets browser platform for React Router; changes React context re-export to type-only; standardizes import paths to aliases.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • aura-stack-ts/auth#141: Removes explicit AuthInstance type annotation on createAuth(...) destructured exports in app auth modules, directly aligned with this PR's type annotation removals.
  • aura-stack-ts/auth#115: Introduces changes to the AuthInstance shape and handlers contract that relate to the type inference changes in this PR.
  • aura-stack-ts/auth#101: Removes explicit AuthInstance return typing from createAuth in core, matching the same type-contract adjustment pattern as this PR.

Suggested Labels

refactor, chore

Poem

🐰 Types flow cleaner now, no explicit casting,
Express and Router get their contracts lasting,
Type-only imports erase what won't run,
Build scripts simplified—the cleanup is done! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the changeset: removing explicit type annotations (AuthInstance) from exported destructurings and enabling verbatimModuleSyntax in tsconfigs across multiple packages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/resolve-unportable-types

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (1)
packages/express/src/@types/index.ts (1)

1-3: ⚡ Quick win

Use type-only imports in this type-only declaration module.

On Line [1]–Line [3], these imports are only used in type positions. With verbatimModuleSyntax, keeping them as value imports can preserve unnecessary runtime imports.

Suggested diff
-import { LocalsWithSession } from "`@/lib/with-auth.ts`"
-import { AuthInstance } from "`@aura-stack/auth`"
-import { FromShapeToObject, Identities } from "`@aura-stack/auth/identity`"
+import type { LocalsWithSession } from "`@/lib/with-auth.ts`"
+import type { AuthInstance } from "`@aura-stack/auth`"
+import type { FromShapeToObject, Identities } from "`@aura-stack/auth/identity`"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/express/src/`@types/index.ts around lines 1 - 3, The current imports
(LocalsWithSession, AuthInstance, FromShapeToObject, Identities) in this
type-only declaration module are imported as value imports; change them to
type-only imports by using `import type` for the symbols LocalsWithSession,
AuthInstance, FromShapeToObject, and Identities so the compiler/transformer
won’t emit unnecessary runtime imports—update the import statements that
reference "`@/lib/with-auth.ts`" and "`@aura-stack/auth`" /
"`@aura-stack/auth/identity`" accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/device/package.json`:
- Around line 18-19: The "clean:cts" npm script fails when the dist directory is
missing which breaks "prepublishOnly"; update the "clean:cts" script (referenced
by the package.json script keys "clean:cts" and "prepublishOnly") to be no-op
when dist is absent — e.g., guard the find command with a directory existence
check or append safe-fail handling so the command exits successfully if dist
doesn't exist before running build.

In `@packages/elysia/package.json`:
- Line 19: The package.json script "clean:cts" currently fails when dist/ is
absent; update the "clean:cts" script so it becomes no-op instead of exiting
non-zero when dist is missing — for example, make it check that dist exists
before running find, or use a find invocation that tolerates no matches (or
append a fallback `|| true`), or switch to an rm -f style pattern that safely
ignores missing files; modify the "clean:cts" script entry accordingly.

In `@packages/express/package.json`:
- Line 19: The npm script "clean:cts" in package.json currently runs find on
dist and will fail if dist is missing; update the "clean:cts" script so it first
checks for the existence of the dist directory (or otherwise swallows a
missing-directory error) before invoking find — e.g., make the script
conditional on [ -d dist ] && find ... or append a no-fail fallback (|| true) so
the cleanup is a no-op when dist/ is absent; update the "clean:cts" entry
accordingly in package.json.

In `@packages/hono/package.json`:
- Line 19: The "clean:cts" npm script currently runs find on dist and fails when
dist is missing; update the "clean:cts" entry in package.json so it first checks
for the existence of the dist directory (e.g., using a directory-existence test
like test -d or [ -d ]) and only runs the find ... -delete when dist exists,
making the script a no-op and idempotent when dist/ is absent.

In `@packages/integration/package.json`:
- Around line 19-20: The prepublishOnly script currently invokes the clean:cts
script unguarded which fails when dist doesn't exist; update the package.json so
clean:cts is safe to run when dist is missing (e.g., make clean:cts check for
the existence of the dist directory before running the find/delete command) or
reorder prepublishOnly to run the build before calling clean:cts; adjust the
"clean:cts" and/or "prepublishOnly" script entries accordingly so pnpm publish
does not exit non‑zero when dist is absent.

In `@packages/rate-limiter/package.json`:
- Line 19: The "clean:cts" npm script fails when the dist directory is missing;
update the package.json scripts entry "clean:cts" so it no-ops harmlessly when
dist doesn't exist (e.g., guard the find invocation with a directory-exists
check or suppress the missing-directory error and return success) so running
pnpm clean:cts on a fresh clone does not fail.

In `@packages/react-router/package.json`:
- Line 19: The "clean:cts" npm script in package.json can fail when the dist
directory is missing; update the "clean:cts" script to avoid a non-zero exit by
either (A) guarding the find command with a directory existence check (only run
find if dist exists) or (B) making the command tolerant of no-matches by
swallowing a non-zero exit (e.g., append a no-op success). Modify the script
entry named "clean:cts" accordingly so CI/scripts do not fail when dist/ is
absent.

In `@packages/react-router/src/`@types/core.ts:
- Line 1: The file currently does a runtime re-export with `export * from
"`@aura-stack/react/types`"` which will try to emit JS for a types-only module;
change it to a type-only re-export so no runtime import is emitted (e.g. replace
the export with a type-only re-export such as using TypeScript's type-only
export form for the module) and ensure the module path in
`packages/react-router/src/@types/core.ts` refers to the types entry
(`"`@aura-stack/react/types`"`) as a type-only export to avoid runtime resolution
errors.

In `@packages/react/package.json`:
- Line 19: The "clean:cts" npm script currently runs find against "dist" without
checking if the directory exists, causing failures when "dist" is absent; update
the "clean:cts" script entry in package.json so it first checks that the "dist"
directory exists and only then runs the find delete command (i.e., add a guard
that tests for the existence of "dist" before invoking find) to restore the
previous resilient behavior.

---

Nitpick comments:
In `@packages/express/src/`@types/index.ts:
- Around line 1-3: The current imports (LocalsWithSession, AuthInstance,
FromShapeToObject, Identities) in this type-only declaration module are imported
as value imports; change them to type-only imports by using `import type` for
the symbols LocalsWithSession, AuthInstance, FromShapeToObject, and Identities
so the compiler/transformer won’t emit unnecessary runtime imports—update the
import statements that reference "`@/lib/with-auth.ts`" and "`@aura-stack/auth`" /
"`@aura-stack/auth/identity`" accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27686bc8-8f94-46a6-82d6-62407da014e9

📥 Commits

Reviewing files that changed from the base of the PR and between 4df3a3e and 3497ff6.

📒 Files selected for processing (47)
  • apps/bun/src/lib/auth.ts
  • apps/cloudflare/src/auth.ts
  • apps/deno/src/auth.ts
  • apps/oak/src/auth.ts
  • apps/supabase/functions/_shared/auth.ts
  • packages/core/src/actions/signIn/authorization-url.ts
  • packages/core/src/actions/signIn/authorization.ts
  • packages/core/src/router/context.ts
  • packages/core/src/shared/assert.ts
  • packages/core/src/shared/crypto.ts
  • packages/core/src/shared/logger.ts
  • packages/core/src/validator/registry.ts
  • packages/core/test/actions/callback/userinfo.test.ts
  • packages/core/test/identity.test.ts
  • packages/core/test/oauth.test.ts
  • packages/core/test/types.test-d.ts
  • packages/core/tsconfig.json
  • packages/device/package.json
  • packages/elysia/package.json
  • packages/express/package.json
  • packages/express/src/@types/index.ts
  • packages/express/src/createAuth.ts
  • packages/hono/package.json
  • packages/integration/package.json
  • packages/jose/src/deriveKey.ts
  • packages/jose/src/encrypt.ts
  • packages/jose/tsconfig.json
  • packages/next/package.json
  • packages/rate-limiter/package.json
  • packages/react-router/package.json
  • packages/react-router/src/@types/api.ts
  • packages/react-router/src/@types/core.ts
  • packages/react-router/src/@types/index.ts
  • packages/react-router/src/client.ts
  • packages/react-router/src/client.tsx
  • packages/react-router/src/createAuth.ts
  • packages/react-router/src/index.ts
  • packages/react-router/src/lib/api.ts
  • packages/react-router/test/context/provider.test.tsx
  • packages/react-router/test/context/redirect.test.tsx
  • packages/react-router/tsconfig.json
  • packages/react-router/tsdown.config.ts
  • packages/react/package.json
  • packages/react/src/context.tsx
  • packages/react/src/hooks.ts
  • packages/react/tsconfig.json
  • packages/react/tsdown.config.ts
💤 Files with no reviewable changes (1)
  • packages/react-router/src/client.ts

Comment thread packages/device/package.json Outdated
Comment thread packages/elysia/package.json Outdated
Comment thread packages/express/package.json Outdated
Comment thread packages/hono/package.json Outdated
Comment thread packages/integration/package.json Outdated
Comment thread packages/rate-limiter/package.json Outdated
Comment thread packages/react-router/package.json Outdated
Comment thread packages/react-router/src/@types/core.ts Outdated
Comment thread packages/react/package.json Outdated
@halvaradop halvaradop merged commit a54e654 into master Jun 5, 2026
7 checks passed
@halvaradop halvaradop deleted the fix/resolve-unportable-types branch June 5, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes that correct incorrect or unexpected behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant