[GH-ISSUE #7119] The CAPTCHA plugin is reporting non-portable TS types #19365

Closed
opened 2026-04-15 18:22:45 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @SiNONiMiTY on GitHub (Jan 4, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7119

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Export an auth instance with the CAPTCHA plugin

Current vs. Expected behavior

Expected behavior is to have no type errors

What version of Better Auth are you using?

1.4.10

System info

1.4.10

Which area(s) are affected? (Select all that apply)

Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  plugins: [
    captcha({...}),
  ]
});

Additional context

Last working version is 1.4.7

The inferred type of 'authFn' cannot be named without a reference to '../../node_modules/better-auth/dist/plugins/captcha/types.mjs'. This is likely not portable. A type annotation is necessary.
Originally created by @SiNONiMiTY on GitHub (Jan 4, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7119 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Export an auth instance with the CAPTCHA plugin ### Current vs. Expected behavior Expected behavior is to have no type errors ### What version of Better Auth are you using? 1.4.10 ### System info ```bash 1.4.10 ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ plugins: [ captcha({...}), ] }); ``` ### Additional context Last working version is 1.4.7 ``` The inferred type of 'authFn' cannot be named without a reference to '../../node_modules/better-auth/dist/plugins/captcha/types.mjs'. This is likely not portable. A type annotation is necessary. ```
GiteaMirror added the locked label 2026-04-15 18:22:45 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 4, 2026):

It seems you are experiencing a non-portable TypeScript types issue when using the CAPTCHA plugin with Better Auth version 1.4.10. This often arises due to type definitions that require references not easily accessible across different environments.

Here's how you might troubleshoot:

  1. Check Types: Ensure that you have defined any necessary type annotations manually where TypeScript cannot infer types on its own. This could resolve the portability issue mentioned in the error you're seeing.

  2. Compare Versions: Since the last working version was 1.4.7, consider checking the differences in type definitions between these versions to identify any changes that could be causing the issue.

  3. Seek Community Help: If the problem persists, tag Beka and Max (@bekacru, @ping__) in the GitHub issue for more specialized assistance regarding the plugin and the types involved.

Does this help you move forward, or would you like more specific guidance on a particular step?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3707865358 --> @better-auth-agent[bot] commented on GitHub (Jan 4, 2026): It seems you are experiencing a non-portable TypeScript types issue when using the CAPTCHA plugin with Better Auth version 1.4.10. This often arises due to type definitions that require references not easily accessible across different environments. Here's how you might troubleshoot: 1. **Check Types**: Ensure that you have defined any necessary type annotations manually where TypeScript cannot infer types on its own. This could resolve the portability issue mentioned in the error you're seeing. 2. **Compare Versions**: Since the last working version was 1.4.7, consider checking the differences in type definitions between these versions to identify any changes that could be causing the issue. 3. **Seek Community Help**: If the problem persists, tag Beka and Max (@bekacru, @ping__) in the GitHub issue for more specialized assistance regarding the plugin and the types involved. Does this help you move forward, or would you like more specific guidance on a particular step? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Jan 4, 2026):

This TypeScript error is a known issue in Better Auth 1.4.8+ and happens because the inferred type for your auth instance references internal types from the CAPTCHA plugin that aren't exported at the top level, making the type non-portable in declaration files. This regression was introduced by changes to type exports and internalization of helpers between 1.4.7 and 1.4.10 (PR #6479, PR #6513). It affects other plugins too, not just CAPTCHA.

Workarounds:

  • The most reliable fix is to use an explicit type annotation when exporting your auth instance:
    export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth<typeof authConfig>>;
    
  • You can also try disabling declaration and declarationMap in your tsconfig.json if your build system allows it.
  • Setting exactOptionalPropertyTypes: false in your tsconfig can help, but reduces type safety.

This is a systemic limitation with how Better Auth exports and infers types from plugins and adapters, especially in monorepos or strict TypeScript setups. A more robust fix (like a defineConfig helper) is discussed but not yet released. Until then, explicit type annotations are the best way to avoid or suppress the error [reference].

Let me know if you need an example for your specific setup.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3707869822 --> @dosubot[bot] commented on GitHub (Jan 4, 2026): <!-- Answer --> This TypeScript error is a known issue in Better Auth 1.4.8+ and happens because the inferred type for your auth instance references internal types from the CAPTCHA plugin that aren't exported at the top level, making the type non-portable in declaration files. This regression was introduced by changes to type exports and internalization of helpers between 1.4.7 and 1.4.10 ([PR #6479](https://github.com/better-auth/better-auth/pull/6479), [PR #6513](https://github.com/better-auth/better-auth/pull/6513)). It affects other plugins too, not just CAPTCHA. **Workarounds:** - The most reliable fix is to use an explicit type annotation when exporting your auth instance: ```ts export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth<typeof authConfig>>; ``` - You can also try disabling `declaration` and `declarationMap` in your `tsconfig.json` if your build system allows it. - Setting `exactOptionalPropertyTypes: false` in your `tsconfig` can help, but reduces type safety. This is a systemic limitation with how Better Auth exports and infers types from plugins and adapters, especially in monorepos or strict TypeScript setups. A more robust fix (like a `defineConfig` helper) is discussed but not yet released. Until then, explicit type annotations are the best way to avoid or suppress the error [[reference](https://github.com/better-auth/better-auth/issues/5637)]. Let me know if you need an example for your specific setup. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/f3362185-461e-4496-914a-74daadee355d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/f3362185-461e-4496-914a-74daadee355d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/f3362185-461e-4496-914a-74daadee355d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/f3362185-461e-4496-914a-74daadee355d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f3362185-461e-4496-914a-74daadee355d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/f3362185-461e-4496-914a-74daadee355d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f3362185-461e-4496-914a-74daadee355d?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20TypeScript%20error%20is%20a%20known%20issue%20in%20Better%20Auth%201.4.8%2B%20and%20happens%20because%20the%20inferred%20type%20for%20your%20auth%20instance%20references%20internal%20types%20from%20the%20CAPTCHA%20plugin%20that%20aren%27t%20exported%20at%20the%20top%20level%2C%20making%20the%20type%20non-portable%20in%20declaration%20files.%20This%20regression%20was%20introduced%20by%20changes%20to%20type%20exports%20and%20internalization%20of%20helpers%20between%201.4.7%20and%201.4.10%20%28%5BPR%20%236479%5D%28https%3A//github.com/better-auth/better-auth/pull/6479%29%2C%20%5BPR%20%236513%5D%28https%3A//github.com/better-auth/better-auth/pull/6513%29%29.%20It%20affects%20other%20plugins%20too%2C%20not%20just%20CAPTCHA.%0A%0A%2A%2AWorkarounds%3A%2A%2A%0A-%20The%20most%20reliable%20fix%20is%20to%20use%20an%20explicit%20type%20annotation%20when%20exporting%20your%20auth%20instance%3A%0A%20%20%60%60%60ts%0A%20%20export%20const%20auth%20%3D%20betterAuth%28authConfig%29%20as%20ReturnType%3Ctypeof%20betterAuth%3Ctypeof%20authConfig%3E%3E%3B%0A%20%20%60%60%60%0A-%20You%20can%20also%20try%20disabling%20%60declaration%60%20and%20%60declarationMap%60%20in%20your%20%60tsconfig.json%60%20if%20your%20build%20system%20allows%20it.%0A-%20Setting%20%60exactOptionalPropertyTypes%3A%20false%60%20in%20your%20%60tsconfig%60%20can%20help%2C%20but%20reduces%20type%20safety.%0A%0AThis%20is%20a%20systemic%20limitation%20with%20how%20Better%20Auth%20exports%20and%20infers%20types%20from%20plugins%20and%20adapters%2C%20especially%20in%20monorepos%20or%20strict%20TypeScript%20setups.%20A%20more%20robust%20fix%20%28like%20a%20%60defineConfig%60%20helper%29%20is%20discussed%20but%20not%20yet%20released.%20Until%20then%2C%20explicit%20type%20annotations%20are%20the%20best%20way%20to%20avoid%20or%20suppress%20the%20error%20%5B%5Breference%5D%28https%3A//github.com/better-auth/better-auth/issues/5637%29%5D.%0A%0ALet%20me%20know%20if%20you%20need%20an%20example%20for%20your%20specific%20setup.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/7119)
Author
Owner

@sohamingle commented on GitHub (Jan 4, 2026):

I found that the captcha plugin is not exporting its types like the other plugins which causes this issue. I'll open a PR that resolves this issue.

<!-- gh-comment-id:3708222668 --> @sohamingle commented on GitHub (Jan 4, 2026): I found that the captcha plugin is not exporting its types like the other plugins which causes this issue. I'll open a PR that resolves this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19365