brian-assistant / tests

0 stars 0 forks source link

Add typescript #4

Closed brian-assistant closed 1 year ago

brian-assistant commented 1 year ago

Add typescript to the project tsconfig.build.json, add typescript to package.json. Use tsconfig with nest recommended configuration.

go:
brian-ai-assistant[bot] commented 1 year ago

Working branch

feature-4-typescript

Pull request

Implement task #4 - Add typescript

To implement the task and add TypeScript to the project, we need to perform the following steps:

  1. Add TypeScript as a dependency in the package.json file:

    "devDependencies": {
     "typescript": "^4.0.3"
    }
  2. 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"]
    }
  3. Update the tsconfig.json file to include the "baseUrl", "outDir", and "paths" options:

    {
     "compilerOptions": {
       "baseUrl": "./src",
       "outDir": "./dist",
       "paths": {
         "*": [
           "./node_modules/*",
           "./src/*"
         ]
       }
     }
    }
  4. 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"
    }
  5. 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