lukeautry / tsoa

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

Set importsNotUsedAsValues to error #1044

Closed quarhodron closed 1 year ago

quarhodron commented 3 years ago

After I generated routes.ts I get the error: image

I think it's safe to set "importsNotUsedAsValues": "error" in tsoa tsconfig since it wouldn't affect current user configs while it will help those who just like me have it set it to error in my own tsconfig.

Sorting

Expected Behavior

routes.ts

import type * as KoaRouter from '@koa/router';

Current Behavior

routes.ts

import * as KoaRouter from '@koa/router';

Possible Solution

changing this line https://github.com/lukeautry/tsoa/blob/7c05b4d3f67c313752d38e0efc6826f64b4f27fe/packages/cli/src/routeGeneration/templates/koa.hbs#L22 and setting "importsNotUsedAsValues": "error" in tsconfig.json

Steps to Reproduce

set "importsNotUsedAsValues": "error" in tsconfig.json

Breaking change?

no

panwauu commented 1 year ago

Having the same problem with import * as express from 'express'; instead of import type * as express from 'express';. Would be very happy for this easy update

panwauu commented 1 year ago

Another fix would be to add // @ts-ignore before the import

WoH commented 1 year ago

Having the same problem with import * as express from 'express'; instead of import type * as express from 'express';. Would be very happy for this easy update

Would you like to open a PR?

panwauu commented 1 year ago

I have not contributed to tsoa up to now so I would need some pointers on where to adapt this behvaior. (I could not find it within some seconds).

WoH commented 1 year ago

https://github.com/lukeautry/tsoa/tree/master/packages/cli/src/routeGeneration/templates

panwauu commented 1 year ago

Dayum. How could I miss this 🙄 PR is set