This package provides predefined,
opinionated TypeScript configurations to be
applied to the extends
property in tsconfig.json
.
Install the typescript
and @rainstormy/presets-typescript
packages with the package manager of your choice:
npm install --save-dev typescript @rainstormy/presets-typescript
pnpm add --save-dev typescript @rainstormy/presets-typescript
yarn add --dev typescript @rainstormy/presets-typescript
Create a tsconfig.json
file and
extend @rainstormy/presets-typescript/base
to enable type-checking in general.
In addition to this, you can extend some of the following configurations to refine the TypeScript settings for your project:
Configuration | Description |
---|---|
@rainstormy/presets-typescript/es2023 |
Targets browser apps, full-stack apps, and npm libraries. |
@rainstormy/presets-typescript/es2023-node |
Targets Node.js apps. |
@rainstormy/presets-typescript/dts+js |
Generates js and d.ts files. |
@rainstormy/presets-typescript/dts |
Generates d.ts files only. |
You can override the predefined settings by specifying the desired options like
compilerOptions
and include
as usual.
For example:
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": [
"@rainstormy/presets-typescript/base",
"@rainstormy/presets-typescript/es2023",
"@rainstormy/presets-typescript/dts+js"
],
"compilerOptions": {
"baseUrl": "./",
"incremental": true,
"noEmitOnError": false,
"outDir": "dist",
"sourceMap": true
},
"include": ["./src/**/*.ts", "./*.config.js", "./*.config.ts"]
}
Copy the relevant parts of
the preset source files
and insert them directly into the tsconfig.json
file. Make adjustments as
needed.