lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.42k stars 489 forks source link

Unused imports and parameters in generated hapi routes file #1528

Open leonlaser opened 7 months ago

leonlaser commented 7 months ago

Hello 👋 I am a developor for project PIA and we are currently integrating tsoa into our hapi based services.

We are compiling with noUnusedLocals and noUnusedParameters set to true and stumbled upon the hapi route generator template having both, unused imports and unused parameters.

Sorting

Expected Behavior

The generated routes file for hapi should not trigger errors for unused imports and parameters, when the compilerOptions noUnusedLocals and noUnusedParameters are set to true.

Current Behavior

Errors are thrown when noUnusedLocals and noUnusedParameters are set to true.

Possible Solution

Our solution is to prepend the generated file with // @ts-nocheck. As the hapi.hbs template already has /* tslint:disable */ and /* eslint-disable */ modifiers, // @ts-nocheck could be added, too.

Steps to Reproduce

Setup tsoa.json with:

{
  "routes": {
    "middleware": "hapi",
    "routesDir": "src",
  }
}

Setup tsconfig.json with

{
  "compilerOptions": {
    "noUnusedLocals": true,
    "noUnusedParameters": true,
  }
}

Context (Environment)

Version of the library: 5.1.1 Version of NodeJS: 20.3.0

github-actions[bot] commented 7 months ago

Hello there leonlaser 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

jackey8616 commented 4 months ago

@leonlaser Hello, I would like to confirm the issue is causing by unused imports and parameters in hbs.

We published new version v6.2.0 which refactor hbs, you can give a shot.