Multiple build errors when using skipLibCheck: false #728

Closed
opened 2026-03-13 08:01:50 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Klemah on GitHub (Feb 23, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Set up a nextjs project with create-next-app or other
  2. Set skipLibCheck to false
  3. Add better-auth to the project
  4. Run yarn build

Current vs. Expected behavior

It should build, but it errors for multiple reasons. I've attempted fixing them one by one, but was unable to fix the last for now. It is likely that there are more errors after this one.


First error: missing type-fest dependency used in better-fetch, which better-auth depends on if my understanding is correct.

yarn build
   ▲ Next.js 15.1.7
   - Environments: .env


./node_modules/@better-fetch/fetch/dist/index.d.ts:3:31
Type error: Cannot find module 'type-fest' or its corresponding type declarations.

  1 | import * as zod from 'zod';
  2 | import { ZodSchema, z } from 'zod';
> 3 | import { IsEmptyObject } from 'type-fest';
    |                               ^
  4 |
  5 | type RetryCondition = (response: Response | null) => boolean | Promise<boolean>;
Next.js build worker exited with code: 1 and signal: null

Second error: also better-fetch, Timer is not defined. I think this is an issue with newer versions of node.

yarn build
   ▲ Next.js 15.1.7
   - Environments: .env

./node_modules/@better-fetch/fetch/dist/index.d.ts:620:19
Type error: Cannot find name 'Timer'.

  618 | declare function getMethod(url: string, options?: BetterFetchOption): string;
  619 | declare function getTimeout(options?: BetterFetchOption, controller?: AbortController): {
> 620 |     abortTimeout: Timer | undefined;
      |                   ^
  621 |     clearTimeout: () => void;
  622 | };
  623 | declare function bodyParser(data: any, responseType: ResponseType): any;
Next.js build worker exited with code: 1 and signal: null

Third error: missing better-sqlite3 dependency in better-auth.

yarn build
   ▲ Next.js 15.1.7
   - Environments: .env


./node_modules/better-auth/dist/auth-BBnJHOLM.d.ts:8:26
Type error: Cannot find module 'better-sqlite3' or its corresponding type declarations.

   6 | import { d as LiteralUnion, L as LiteralString, D as DeepPartial, U as UnionToIntersection, S as StripEmptyObjects, O as OmitId, P as PrettifyDeep, b as Prettify, E as Expand } from './helper-Bi8FQwDD.js';
   7 | import { O as OAuthProvider, S as SocialProviders, b as SocialProviderList } from './index-Y--3ocl8.js';
>  8 | import { Database } from 'better-sqlite3';
     |                          ^
   9 |
  10 | type BetterAuthDbSchema = Record<string, {
Next.js build worker exited with code: 1 and signal: null

Fourth error: the file node_modules/better-auth/dist/auth-BBnJHOLM.d.ts is broken, and it seems the errors in that file are also present in other files in the same folder.

yarn build
   ▲ Next.js 15.1.7
   - Environments: .env

   Linting and checking validity of types  ..Failed to compile.

./node_modules/better-auth/dist/auth-BBnJHOLM.d.ts:204:72
Type error: Type 'key' cannot be used to index type 'InferBody<Opts, Opts["body"] & (undefined extends InferUseOptions<Opts>["body"] ? {} : InferUseOptions<Opts>["body"])> & ... 4 more ... & ContextTools'.

  202 |         params?: Record<string, string>;
  203 |         query?: Record<string, string>;
> 204 |     } & better_call.ContextTools extends infer T ? { [key in keyof T]: (better_call.InferBody<Opts, Opts["body"] & (undefined extends better_call.InferUseOptions<Opts>["body"] ? {} : better_call.InferUseOptions<Opts>["body"])> & {  
      |                                                                        ^
  205 |         context: AuthContext & {
  206 |             returned?: APIError | Response | Record<string, any>;
  207 |             endpoint: Endpoint;
Next.js build worker exited with code: 1 and signal: null

This error occurs multiple times in this file. Though I've been able to fix the other errors by either adding dependencies or adding .d.ts files, this last one is a bit more tricky.

What version of Better Auth are you using?

1.1.18

Provide environment information

- OS: Windows 10
- Node version: `20.9.0`
- Yarn version: `4.6.0`

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

Types

Auth config (if applicable)


Additional context

No response

Originally created by @Klemah on GitHub (Feb 23, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Set up a nextjs project with `create-next-app` or other 2. Set `skipLibCheck` to `false` 3. Add `better-auth` to the project 4. Run `yarn build` ### Current vs. Expected behavior It should build, but it errors for multiple reasons. I've attempted fixing them one by one, but was unable to fix the last for now. It is likely that there are more errors after this one. --- First error: missing `type-fest` dependency used in `better-fetch`, which `better-auth` depends on if my understanding is correct. ``` yarn build ▲ Next.js 15.1.7 - Environments: .env ./node_modules/@better-fetch/fetch/dist/index.d.ts:3:31 Type error: Cannot find module 'type-fest' or its corresponding type declarations. 1 | import * as zod from 'zod'; 2 | import { ZodSchema, z } from 'zod'; > 3 | import { IsEmptyObject } from 'type-fest'; | ^ 4 | 5 | type RetryCondition = (response: Response | null) => boolean | Promise<boolean>; Next.js build worker exited with code: 1 and signal: null ``` --- Second error: also `better-fetch`, `Timer` is not defined. I think this is an issue with newer versions of node. ``` yarn build ▲ Next.js 15.1.7 - Environments: .env ./node_modules/@better-fetch/fetch/dist/index.d.ts:620:19 Type error: Cannot find name 'Timer'. 618 | declare function getMethod(url: string, options?: BetterFetchOption): string; 619 | declare function getTimeout(options?: BetterFetchOption, controller?: AbortController): { > 620 | abortTimeout: Timer | undefined; | ^ 621 | clearTimeout: () => void; 622 | }; 623 | declare function bodyParser(data: any, responseType: ResponseType): any; Next.js build worker exited with code: 1 and signal: null ``` --- Third error: missing `better-sqlite3` dependency in `better-auth`. ``` yarn build ▲ Next.js 15.1.7 - Environments: .env ./node_modules/better-auth/dist/auth-BBnJHOLM.d.ts:8:26 Type error: Cannot find module 'better-sqlite3' or its corresponding type declarations. 6 | import { d as LiteralUnion, L as LiteralString, D as DeepPartial, U as UnionToIntersection, S as StripEmptyObjects, O as OmitId, P as PrettifyDeep, b as Prettify, E as Expand } from './helper-Bi8FQwDD.js'; 7 | import { O as OAuthProvider, S as SocialProviders, b as SocialProviderList } from './index-Y--3ocl8.js'; > 8 | import { Database } from 'better-sqlite3'; | ^ 9 | 10 | type BetterAuthDbSchema = Record<string, { Next.js build worker exited with code: 1 and signal: null ``` --- Fourth error: the file `node_modules/better-auth/dist/auth-BBnJHOLM.d.ts` is broken, and it seems the errors in that file are also present in other files in the same folder. ``` yarn build ▲ Next.js 15.1.7 - Environments: .env Linting and checking validity of types ..Failed to compile. ./node_modules/better-auth/dist/auth-BBnJHOLM.d.ts:204:72 Type error: Type 'key' cannot be used to index type 'InferBody<Opts, Opts["body"] & (undefined extends InferUseOptions<Opts>["body"] ? {} : InferUseOptions<Opts>["body"])> & ... 4 more ... & ContextTools'. 202 | params?: Record<string, string>; 203 | query?: Record<string, string>; > 204 | } & better_call.ContextTools extends infer T ? { [key in keyof T]: (better_call.InferBody<Opts, Opts["body"] & (undefined extends better_call.InferUseOptions<Opts>["body"] ? {} : better_call.InferUseOptions<Opts>["body"])> & { | ^ 205 | context: AuthContext & { 206 | returned?: APIError | Response | Record<string, any>; 207 | endpoint: Endpoint; Next.js build worker exited with code: 1 and signal: null ``` This error occurs multiple times in this file. Though I've been able to fix the other errors by either adding dependencies or adding `.d.ts` files, this last one is a bit more tricky. ### What version of Better Auth are you using? 1.1.18 ### Provide environment information ```bash - OS: Windows 10 - Node version: `20.9.0` - Yarn version: `4.6.0` ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:01:50 -05:00
Author
Owner

@Klemah commented on GitHub (Jun 16, 2025):

@Kinfe123 Hello, why was the issue marked as closed? I just tested, and it is not fixed. Example output below. Thanks

   ▲ Next.js 15.2.3
   - Environments: .env.production

   Linting and checking validity of types  .Failed to compile.

./node_modules/better-auth/dist/client/plugins/index.d.ts:26:10
Type error: Module '"@simplewebauthn/server"' has no exported member 'global'.

  24 | import { oneTimeToken } from '../../plugins/one-time-token/index.js';
  25 | export * from '@simplewebauthn/server';
> 26 | export { global } from '@simplewebauthn/server';
     |          ^
  27 | import 'zod';
  28 | import 'better-call';
  29 | import '../../plugins/organization/access/index.js';
Next.js build worker exited with code: 1 and signal: null
@Klemah commented on GitHub (Jun 16, 2025): @Kinfe123 Hello, why was the issue marked as closed? I just tested, and it is not fixed. Example output below. Thanks ```yarn build ▲ Next.js 15.2.3 - Environments: .env.production Linting and checking validity of types .Failed to compile. ./node_modules/better-auth/dist/client/plugins/index.d.ts:26:10 Type error: Module '"@simplewebauthn/server"' has no exported member 'global'. 24 | import { oneTimeToken } from '../../plugins/one-time-token/index.js'; 25 | export * from '@simplewebauthn/server'; > 26 | export { global } from '@simplewebauthn/server'; | ^ 27 | import 'zod'; 28 | import 'better-call'; 29 | import '../../plugins/organization/access/index.js'; Next.js build worker exited with code: 1 and signal: null ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#728