Closed brian-assistant closed 1 year ago
feature-4-typescript
Implement task #4 - Add typescript
To implement the task and add TypeScript to the project, we need to perform the following steps:
Add TypeScript as a dependency in the package.json file:
"devDependencies": {
"typescript": "^4.0.3"
}
Create a tsconfig.build.json file with the recommended TypeScript configuration for Nest.js:
{
"extends": "./tsconfig.json",
"include": ["src", "test"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Update the tsconfig.json file to include the "baseUrl", "outDir", and "paths" options:
{
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist",
"paths": {
"*": [
"./node_modules/*",
"./src/*"
]
}
}
}
Update the package.json file to add the scripts for building and running the TypeScript code:
"scripts": {
"start": "node dist/main.js",
"build": "rimraf dist && tsc -p tsconfig.build.json",
"dev": "ts-node-dev --transpile-only --ignore-watch node_modules src/main.ts"
}
Update the app.module.ts file to use the .ts extension:
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Commit Message: Added TypeScript support to the project
Add typescript to the project
tsconfig.build.json
, add typescript to package.json. Use tsconfig with nest recommended configuration.