lukeautry / tsoa

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

Support verbatimModuleSyntax (tsconfig) #1628

Closed jakke-korpelainen closed 1 month ago

jakke-korpelainen commented 1 month ago

Sorting

Expected Behavior

// `routes.ts` 
// compilation should produce compatible imports with verbatimModuleSyntax
import { fetchMiddlewares, ExpressTemplateService } from '@tsoa/runtime';
import type { TsoaRoute } from '@tsoa/runtime';

Current Behavior

// `routes.ts` 
// doesn't separate type imports and is incompatible with verbatimModuleSyntax
import { TsoaRoute, fetchMiddlewares, ExpressTemplateService } from '@tsoa/runtime';

Error: 'TsoaRoute' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.ts(1484)

Possible Solution

Could consider respecting the verbatimModuleSyntax compilation flag and adding the runtime import according to it.

Steps to Reproduce

  1. Enable verbatimModuleSyntax in tsconfig.json.
  2. Compile tsoa using cli or programmatically
  3. Compile your project using the tsoa compiled routes
  4. routes.ts will cause a compilation error: 'TsoaRoute' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

Context (Environment)

Version of the library: tsoa@6.2.0 Version of NodeJS: v20.11.0

github-actions[bot] commented 1 month ago

Hello there jakke-korpelainen šŸ‘‹

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

We will try to get back to you as soon as we can.šŸ‘€

jakke-korpelainen commented 1 month ago

Duplicate of https://github.com/lukeautry/tsoa/issues/1418 but it is stale