Skip to content

fix(tsdown-config): export the UserConfig its helpers return - #310

Merged
rqbazan merged 1 commit into
mainfrom
build/tsdown-config-user-config
Nov 8, 2026
Merged

rqbazan merged 1 commit into
mainfrom
build/tsdown-config-user-config

Conversation

@rqbazan

@rqbazan rqbazan commented Nov 8, 2026

Copy link
Copy Markdown
Member

Summary

Under TypeScript 7, rolldown-plugin-dts emits declarations with tsgo for every file of a package's tsconfig.json, tsdown.config.ts included. A consumer's plain export default defineLibConfig() infers tsdown's UserConfig, which TypeScript could only name through .pnpm/tsdown@…/node_modules/tsdown, so the build failed with TS2883. Re-exporting the type gives it a portable name:

 // src/index.ts
 import { defineConfig, type UserConfig } from "tsdown";
+
+export type { UserConfig } from "tsdown";
 // the consumer's emitted tsdown.config.d.ts
-error TS2883: The inferred type of 'default' cannot be named without a reference to 'UserConfig' from '.pnpm/tsdown@…/node_modules/tsdown'.
+declare const _default: import("@rrlab/tsdown-config").UserConfig;
+export default _default;

The package had no tests. It gets a suite ("test": "vitest run", vitest.config.ts, and catalog devDependencies @types/node, tsdown, typescript, vitest; tsdown was only an auto-installed peer before) with one test, test/integration/declaration-emit.test.ts:

beforeAll: pnpm build, pnpm pack, untar
per helper exported by src/index.ts:
  lay the tarball out as pnpm's isolated linker does (real copy under node_modules/.pnpm, tsdown as its sibling peer, a symlink)
  tsdown.config.ts: export default <helper>()
  tsc --noEmit false --declaration --emitDeclarationOnly -p … --outDir … --rootDir … --noCheck   # rolldown-plugin-dts's tsgo arguments
  expect no output, exit 0, and the declaration above

It builds before packing so it also runs alone against the current source. Under pnpm test, turbo has already built.

Evidence

  • Before (re-export removed): both helpers fail.

    × exports defineBinConfig() as is and emits its declaration
    × exports defineLibConfig() as is and emits its declaration
    tsdown.config.ts(3,1): error TS2883: The inferred type of 'default' cannot be named without a reference to 'UserConfig' from '.pnpm/tsdown@0.23.4_…/node_modules/tsdown'. This is likely not portable. A type annotation is necessary.
    Tests  2 failed (2)
    

    After: Tests 2 passed (2), on Node 24 and on the 22.18.0 floor.

  • A consumer package (pnpm, TypeScript 7.0.2, tsdown.config.ts covered by its tsconfig.json, @rrlab/tsdown-config installed from a packed tarball, pnpm exec tsdown):

    @rrlab/tsdown-config tsdown / rolldown-plugin-dts tsdown
    0.2.1 0.23.4 / 0.28.8 exit 1, TS2883
    this branch 0.23.4 / 0.28.8 exit 0
    0.2.1 0.23.7 / 0.30.0 exit 1, TS2883
    this branch 0.23.7 / 0.30.0 exit 0
  • pnpm build passes for every package, including the plugins whose tsdown.config.ts call the helpers. pnpm rr check passes too.

Merge Danger

Door: two-way

It adds one type export and changes no runtime code.

Blast Radius: consumers

  • Consumers can now import UserConfig from @rrlab/tsdown-config. It is tsdown's own type, so it follows the consumer's tsdown version.
  • A consumer that annotated its config by hand (const config: UserConfig = defineLibConfig(…)) keeps working, and can drop the annotation.

🤖 Generated with Claude Code

Under TypeScript 7, rolldown-plugin-dts emits declarations with tsgo
for every file of a package's tsconfig.json, `tsdown.config.ts`
included. A plain `export default defineLibConfig()` then failed with
TS2883: its inferred type, tsdown's `UserConfig`, could only be named
through `.pnpm/tsdown@…/node_modules/tsdown`. Re-exporting the type
lets TypeScript name it through `@rrlab/tsdown-config`.

The package gets its first test. It builds and packs the package, lays
the tarball out as pnpm does, and runs TypeScript 7's tsc with the dts
plugin's tsgo arguments on a `tsdown.config.ts` that exports each
helper as is. Without the re-export both fail with TS2883. tsdown
moves from an auto-installed peer to a catalog devDependency, beside
typescript, vitest and @types/node.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pullfrog

pullfrog Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

No configured credential can serve this run. Your Grok subscription has hit its usage limit. Re-trigger after it resets, or add an API key for this provider, which Pullfrog falls back to automatically.

The providers' responses
GROK_AUTH_JSON: refused with 402

Pick another model →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using grok-4.7

@changeset-bot

changeset-bot Bot commented Nov 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d05279f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@rrlab/tsdown-config Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rqbazan
rqbazan merged commit 55b8828 into main Nov 8, 2026
11 of 12 checks passed
@rqbazan
rqbazan deleted the build/tsdown-config-user-config branch November 8, 2026 21:33
@vland-bot vland-bot Bot mentioned this pull request Nov 8, 2026
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.

1 participant