Skip to content

fix(react): keep "use client" out of type declarations - #561

Open
feledori wants to merge 1 commit into
mainfrom
fix/react-dts-use-client
Open

feledori wants to merge 1 commit into
mainfrom
fix/react-dts-use-client

Conversation

@feledori

Copy link
Copy Markdown
Member

Effect

Projects that import lenis/react and use skipLibCheck: false can type-check again. Since 1.3.20, TypeScript stops with this error:

node_modules/lenis/dist/lenis-react.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts.

Fixes #560.

Cause

The build adds "use client"; to the start of lenis-react.d.ts. A directive is a statement, and a declaration file cannot contain statements.

The old tsup config added the banner only to the JavaScript output. The move to tsdown (8938b18) removed the js key, so the banner went to all outputs.

Change

tsdown.config.ts: the banner is { js: '"use client";' } again. The directive stays in lenis-react.mjs. There is no runtime change.

Test

  1. Run bun run build.
  2. Run npm pack.
  3. In a new project, install the tarball with react@19, @types/react@19 and typescript@6.0.3.
  4. Type-check the repro from lenis/react type declarations start with "use client", which breaks type checking with skipLibCheck: false (TS1036), since 1.3.20 #560 with --skipLibCheck false.

Result: exit code 0. With lenis@1.3.27, the same command fails with TS1036.

The tsdown migration (8938b18) dropped the `js` key from the banner,
so the directive also landed in lenis-react.d.ts and broke type
checking with skipLibCheck: false (TS1036).

Fixes #560
@feledori
feledori requested a review from a team as a code owner October 23, 2026 13:58
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
lenis-playground Ready Ready Preview Oct 23, 2026 1:58pm UTC

This branch was successfully deployed

1 active deployment
Preview — 4ec84d4b Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lenis/react type declarations start with "use client", which breaks type checking with skipLibCheck: false (TS1036), since 1.3.20

1 participant