@zayne-labs/tsconfig package provides proper TypeScript configuration presets for most project types. Choose the right config based on your build tool and runtime environment.
Features
Multiple Presets
Configs for apps, libraries, and monorepos
Environment Support
Separate configs for DOM and non-DOM environments
Build Tool Variants
TSC and bundler-specific configurations
Framework Configs
Special presets for Next.js and more
Installation
Usage
- Choose which
tsconfig.jsonyou need from the list below - Add it to your
tsconfig.json:
tsconfig.json
List of TSConfigs
The key question: Are you usingtsc to turn your .ts files into .js files?
- Using TSC
- Using Bundler
Framework-Specific Configs
Next.js
For Next.js applications:tsconfig.json
More framework-specific configurations will be added in future releases based on demand.
Config Types Explained
App vs Library vs Library-Monorepo
App
App
Use for applications that are deployed and run, not published as packages.
- Includes all necessary DOM types
- Optimized for bundler output
- Suitable for web apps, CLIs, servers
Library
Library
Use for standalone libraries published to npm or other registries.
- Configured for package distribution
- Proper declaration file generation
- Module resolution for consumers
Library-Monorepo
Library-Monorepo
Use for libraries within a monorepo that are consumed by other packages in the same repo.
- Optimized for workspace references
- Faster builds with project references
- Shared type checking across packages
DOM vs Non-DOM
- DOM
- Non-DOM
Use when your code runs in a browser environment:
- Includes DOM type definitions
document,window,HTMLElement, etc.- Web APIs like
fetch,localStorage
- React applications
- Vue applications
- Browser extensions
- Client-side libraries
TSC vs Bundler
- TSC
- Bundler
Use when TypeScript’s
tsc compiler is your build tool:module: "ESNext"or"CommonJS"- Proper module resolution
- Declaration file generation
- Publishing libraries without a bundler
- Node.js projects using
tscdirectly - When you need full TypeScript emit control
Customizing Configs
Extend the base config and override specific options:tsconfig.json
Common Customizations
Path Aliases
tsconfig.json
Strict Type-Checking
tsconfig.json
Monorepo with Project References
tsconfig.json
Examples by Project Type
React Application (Vite)
tsconfig.json
Next.js Application
tsconfig.json
Node.js CLI Tool
tsconfig.json
Published Library (with Bundler)
tsconfig.json
Base Configuration
All presets extend a base configuration with sensible defaults. To use only the base:tsconfig.json
Decision Tree
Use this flowchart to choose the right config:FAQ
Which config should I use for a React app with Vite?
Which config should I use for a React app with Vite?
Use
@zayne-labs/tsconfig/bundler/dom/app since Vite is a bundler and React runs in the DOM.What's the difference between library and library-monorepo?
What's the difference between library and library-monorepo?
library-monorepo is optimized for packages within a monorepo using project references, while library is for standalone packages.Can I use multiple configs in one project?
Can I use multiple configs in one project?
Yes! Create separate
tsconfig.json files for different parts of your project (e.g., tsconfig.node.json for build scripts).Do I need to install TypeScript separately?
Do I need to install TypeScript separately?
Yes, this package only provides configuration presets. Install TypeScript as a dev dependency:
pnpm add -D typescript