This package helps set proper tsconfig presets for most projects. Inspired by Matt Pocock's TSConfig Cheat Sheet.
- Install:
# Npm
npm install --save-dev @zayne-labs/tsconfig
# Pnpm
pnpm add -D @zayne-labs/tsconfig-
Choose which
tsconfig.jsonyou need from the list below. -
Add it to your
tsconfig.json:
If yes, use this selection of configs:
{
// For code that runs in the DOM:
"extends": "@zayne-labs/tsconfig/tsc/dom/app", // For an app
"extends": "@zayne-labs/tsconfig/tsc/dom/library", // For a library
"extends": "@zayne-labs/tsconfig/tsc/dom/library-monorepo", // For a library in a monorepo
// For code that doesn't run in the DOM (for instance, in Node.js):
"extends": "@zayne-labs/tsconfig/tsc/no-dom/app", // For an app
"extends": "@zayne-labs/tsconfig/tsc/no-dom/library", // For a library
"extends": "@zayne-labs/tsconfig/tsc/no-dom/library-monorepo" // For a library in a monorepo
}If no, you're probably using an external bundler.
{
// For code that runs in the DOM:
"extends": "@zayne-labs/tsconfig/bundler/dom/app", // For an app
"extends": "@zayne-labs/tsconfig/bundler/dom/library", // For a library
"extends": "@zayne-labs/tsconfig/bundler/dom/library-monorepo", // For a library in a monorepo
// For code that doesn't run in the DOM (for instance, in Node.js):
"extends": "@zayne-labs/tsconfig/bundler/no-dom/app", // For an app
"extends": "@zayne-labs/tsconfig/bundler/no-dom/library", // For a library
"extends": "@zayne-labs/tsconfig/bundler/no-dom/library-monorepo" // For a library in a monorepo
}The following are currently supported framework-specific options, will add more if needed in future:
{
// For a nextjs app
"extends": "@zayne-labs/tsconfig/bundler/dom/next"
}
{ // For building an app that runs in the DOM with an external bundler "extends": "@zayne-labs/tsconfig/bundler/dom/app" }