A Rollup plugin that flattens TypeScript .d.ts declaration files into a single bundle, generating a merged type definition file. Current stable version 2.9.0 supports Rollup 2.79.1–5.0 and TypeScript 4.8.4–5.8. It differs from other .d.ts bundlers by flattening instead of merging, which imposes strict constraints: all exports are public (use @internal to mark internals), default exports only at top level, and no renamed re-exports. Ideal for libraries that want a single type file and can adhere to its limitations. Released roughly twice a year, tracking TypeScript minor versions.
npm install rollup-plugin-flat-dtsVerified import paths — ran on the pinned version, not inferred.
Rollup config producing a single .js and flattened .d.ts. Demonstrates typical setup with TypeScript plugin and the flatDts output plugin.
Avoid default exports in nested modules; use named exports and re-export in index.
Rename duplicate exports to be globally unique.
Use direct exports or alias via separate declaration: `const Bar = Foo; export { Bar };`Add `@internal` JSDoc tag to internal exports, or use `internal` option with glob patterns.
Avoid importing JSON modules in your source; or use a different output format.
Do not set `verbatimModuleSyntax` in tsconfig; plugin overrides it.
Move flatDts() to `output.plugins` array in rollup.config.js.
Ensure tsconfig compilerOptions does not force a different module system that conflicts; plugin overrides as needed.
Install: `npm install --save-dev rollup-plugin-flat-dts`. Ensure rollup.config is ESM or use dynamic import.