oawad
oawad

Reputation: 71

Getting typescript TS1135: Argument expression expected. with routing-controllers @Req

I am using NodeJS Express routing-controllers with TypeScript, the following code doesn't compile when I added the @Req()/@Res() decorators, if I remove them it compiles fine.

@Service()
@JsonController()
export default class FlightsController {

    constructor(
        @Inject('flightsService') private flightsService : FlightsService)
    {}

    @Get('/flights')
    getFlights = async (@Req() req: Request, @Res() res: Response) => {
        Logger.debug(`Entering getFlights...`);

        try {
            const flightsList = await this.flightsService.getFlights();
            res.send(flightsList);
        } catch (error) {
            res.status(500).send(error);
        }
    }
}

How can I fix this issue...

this is my tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "esnext",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "sourceMap": true,
    "outDir": "dist",
    "allowJs": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es6"
    ],
    "baseUrl": "./src",
    "paths": {
      "@/*": [
        "./*"
      ]
    }
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "include": [
    "src/**/*.ts",
    "tests/**/*.test.ts"
  ],
  "files": [
    "src/index.ts"
  ]
}

Upvotes: 1

Views: 220

Answers (0)

Related Questions