Rollup plugin that compiles TypeScript and reports its type errors
open sourceMITfree
rollup-plugin-typescript2 is a Rollup plugin that compiles TypeScript with the TypeScript compiler itself and prints its syntactic and semantic diagnostics during the build, which the original rollup-plugin-typescript didn't. It's a rewrite of that plugin, a little slower, and takes its compiler options and file list from tsconfig.json, with options to point at another tsconfig or override settings. It writes declaration files and declaration maps, keeps a cache between builds, and can run beside a transpiling plugin such as Babel, esbuild or SWC to do only type-checking and declarations.
Problems it solves
- see TypeScript type errors when I bundle my library with Rollup
- build a TypeScript library with Rollup and get .d.ts declaration files
- my Rollup TypeScript build passes even though the code has type errors
Features
- Prints TypeScript's syntactic and semantic errors during a Rollup build
- Uses the compiler options and files from tsconfig.json, with overrides
- Emits declaration files and declaration maps
- Caches compilation between builds
- Can type-check and emit declarations while another plugin transpiles
- Works in Rollup's watch mode
Limitations
Alternatives
The same job
These do what rollup-plugin-typescript2 does.
- rollup-plugin-dts Bundle TypeScript .d.ts declaration files with Rollup
- tsdown Library bundler for TypeScript and JavaScript, built on Rolldown
- unplugin-dts Generate .d.ts declaration files from TypeScript or Vue sources in your bundler
- tsup Zero-config bundler for TypeScript libraries, powered by esbuild
- Rollup ES module bundler for JavaScript libraries and apps, with tree shaking
- ts-loader The TypeScript loader for webpack: compile .ts and .tsx files as part of a webpack build
