Skip to content

TypeScript

To install:

Terminal window
npm i -D typescript
tsconfig.json
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
/* If transpiling with TypeScript: */
"moduleResolution": "NodeNext",
"module": "NodeNext",
"outDir": "dist",
"sourceMap": true,
/* AND if you're building for a library: */
"declaration": true,
/* AND if you're building for a library in a monorepo: */
"composite": true,
"declarationMap": true,
/* If NOT transpiling with TypeScript:
"moduleResolution": "Bundler",
"module": "ESNext",
*/
"noEmit": true,
/* If your code runs in the DOM: */
"lib": ["es2022", "dom", "dom.iterable"]
/* If your code doesn't run in the DOM:
"lib": ["es2022"]
*/
}
}

Credits: This is shamelessly sourced from Matt Pocock at TotalTypeScript

Here is a script to run the typescript compiler to typecheck a TS project:

Terminal window
# File: package.json
"typecheck": "tsc --noEmit",

See the well crafted documentation and its Cheat Sheet