This package contains a set of strict shared typescript configs.
Installing
Use the package manager of your choice to install:
npm: npm install --save-dev @cprussin/tsconfig
pnpm: pnpm add -D @cprussin/tsconfig
yarn: yarn add -D @cprussin/tsconfig
These configs do not set the types array, so ambient @types/* packages
(e.g. @types/node, @types/bun, @types/jest) are not loaded by default.
Add the ones you need in your own tsconfig.json, for example:
Add the config you want to extend to your tsconfig.json, for example:
{ "extends": "@cprussin/tsconfig/base.json" }
Note that "noEmit": true is set by configs here. The intention is that most
of the case, you're type checking with typescript and distributed
untranspiled files, or that if you're transpiling then the transpilation
tools you're using will override that setting in their own configs as
needed. For instance, if you're using webpack, you could configure
ts-loader like this:
The base configuration that everything else extends from. Sets a bunch of
strict options such as "strict": true, "allowJs": false,
"noFallthroughCasesInSwitch": true, "noImplicitReturns": true, etc. If
you want to be as strict as I do and you aren't incrementally adding
typescript to a legacy project, you probably don't want to override most of
these options, but it might make sense to override the target or lib
options.
Note that no options are set for JSX or for DOM libraries. If you need any
of that, you'll want to use one of the configs that extends base.json
instead of using it directly.
Adds the nextjs typescript
plugin
to the react.json config, and switches jsx to preserve
along with module/moduleResolution set for bundler-based workflows.
This package contains a set of strict shared typescript configs.
Installing
Use the package manager of your choice to install:
npm install --save-dev @cprussin/tsconfigpnpm add -D @cprussin/tsconfigyarn add -D @cprussin/tsconfigThese configs do not set the
typesarray, so ambient@types/*packages (e.g.@types/node,@types/bun,@types/jest) are not loaded by default. Add the ones you need in your owntsconfig.json, for example:Usage
Add the config you want to extend to your
tsconfig.json, for example:Note that
"noEmit": trueis set by configs here. The intention is that most of the case, you're type checking with typescript and distributed untranspiled files, or that if you're transpiling then the transpilation tools you're using will override that setting in their own configs as needed. For instance, if you're usingwebpack, you could configurets-loaderlike this:Or you could have a
buildscript in yourpackage.jsonthat runstscdirectly:Configurations
base.jsonThe base configuration that everything else extends from. Sets a bunch of strict options such as
"strict": true,"allowJs": false,"noFallthroughCasesInSwitch": true,"noImplicitReturns": true, etc. If you want to be as strict as I do and you aren't incrementally adding typescript to a legacy project, you probably don't want to override most of these options, but it might make sense to override thetargetorliboptions.Note that no options are set for JSX or for DOM libraries. If you need any of that, you'll want to use one of the configs that extends
base.jsoninstead of using it directly.dom.jsonExtends the
base.jsonconfig by adding thedomanddom.iterablelibs.react.jsonAdds the
"jsx": "react-jsx"option to thedom.jsonconfig.nextjs.jsonAdds the nextjs typescript plugin to the
react.jsonconfig, and switchesjsxtopreservealong withmodule/moduleResolutionset for bundler-based workflows.webworker.jsonExtends the
base.jsonconfig by adding thewebworkerlib.