How To Install TypeScript
Prerequisites
Step 1 — Install TypeScript
First, install TypeScript as a development dependency:
pnpm install --save-dev typescript
You’ll see output similar to:
+ typescript@<version>
added 10 packages from 5 contributors and audited 20 packages in 2s
found 0 vulnerabilities
Step 2 — Configure Typescript
To configure TypeScript, create a tsconfig.json
file at the root of your project:
Browser Configuration using Remix
{
"extends": "@kurocado-studio/style-guide/tsconfig/remix",
"include": ["app/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Packages written in React
{
"extends": "@kurocado-studio/style-guide/tsconfig/react",
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Node.js Configuration using NestJS
{
"extends": "@kurocado-studio/style-guide/tsconfig/nestjs",
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Step 3 — Integrate TypeScript with Your Code Editor
Visual Studio Code
Install the TypeScript Extension:
Open VS Code
Go to the Extensions view by clicking the square icon in the sidebar or pressing CTRL+SHIFT+X
Search for “TypeScript” and install the extension
Configure VS Code to Use TypeScript: •
Open your VS Code settings (CTRL+,)
Ensure the following settings are configured
{
"typescript.tsdk": "node_modules/typescript/lib"
}
Last modified: 27 November 2024