Skip to content

Support TypeScript 5.7 "rewriteRelativeImportExtensions" option #1714

@Azlond

Description

@Azlond

TypeScript 5.7 will support a new compilerOption called "rewriteRelativeImportExtensions", which allows importing .ts extensions for relative paths.

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

Allow for a config option in tsoa.json to have tsoa output .ts imports in routes.ts.

// should create the following import in routes.ts when rewriteRelativeImportExtensions is enabled
import { UserController } from './../src/controllers/userController.ts';

Current Behavior

npx tsoa spec-and-routes creates the following routes.ts:

import { UserController } from './../src/controllers/userController.js';
--------------------------------^
// This relative import path is unsafe to rewrite because it looks like a file name, but actually resolves to "../src/controllers/userController.ts".

Possible Solution

Allow for a rewriteRelativeImportExtensions-tsoa-config option, which would not rewrite the .ts-extensions to .js.

Or read the tsconfig.json used in the project and determine the rewriteRelativeImportExtensions setting.

Steps to Reproduce

  1. Install TypeScript 5.7 beta
  2. enable rewriteRelativeImportExtensions in tsconfig.json compilerOptions
  3. use tsoa

Context (Environment)

Version of the library: tsoa@6.2.1
Version of NodeJS: 20

  • Confirm you were using yarn not npm: [X]

Detailed Description

Allow for a config option e.g. called rewriteRelativeImportExtensions, which supports the new TypeScript 5.7 feature rewriteRelativeImportExtensions

Breaking change?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions