lukeautry / tsoa

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

Use type import for TsoaRoute to ensure with verbatumModuleSyntax #1676

Closed christiango closed 2 weeks ago

christiango commented 3 weeks ago

All Submissions:

Closing issues

closes #1418

If this is a new feature submission:

Potential Problems With The Approach

We had two options here:

While the inline type imports look cleaner, they are only supported starting in TypeScript 4.5, so I used the syntax that works back to TypeScript 3.8 since that's what's already used in the repo. For my use case, I can use either approach, but I didn't want to impact any other users on Typescript < 4.5

Test plan

I patched my node_modules in my downstream project that uses TSOA and confirmed I no longer get compiler errors due to the correct import!

WoH commented 2 weeks ago

What do you think about keeping it in one line, import { type T, t } from 't'?

christiango commented 2 weeks ago

What do you think about keeping it in one line, import { type T, t } from 't'?

Hey, I included some details in the description as to why I didn't go down that route. While it doesn't impact my project, doing this would possibly change the minimum version requirement for typescript, so I aligned with existing usages to keep this compatible with older typescript versions.

I'm open to either approach personally, but I think this is the one least likely to cause issues for anyone

WoH commented 2 weeks ago

What do you think about keeping it in one line, import { type T, t } from 't'?

Hey, I included some details in the description as to why I didn't go down that route. While it doesn't impact my project, doing this would possibly change the minimum version requirement for typescript, so I aligned with existing usages to keep this compatible with older typescript versions.

I'm open to either approach personally, but I think this is the one least likely to cause issues for anyone

Sorry, I'm blind. In my defense, GH mobile hides it though. We currently need 4.1+ for template literal types, but I agree that pushing it to 4.5 for little difference is probably not worth it.