Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TypeScript 5.7 "rewriteRelativeImportExtensions" option #1714

Open
2 of 4 tasks
Azlond opened this issue Nov 5, 2024 · 2 comments
Open
2 of 4 tasks

Support TypeScript 5.7 "rewriteRelativeImportExtensions" option #1714

Azlond opened this issue Nov 5, 2024 · 2 comments

Comments

@Azlond
Copy link

Azlond commented Nov 5, 2024

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: [email protected]
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

Copy link

github-actions bot commented Nov 5, 2024

Hello there Azlond 👋

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

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

@Azlond
Copy link
Author

Azlond commented Nov 19, 2024

I can't see the comment for which I received an email, so I'll just reply to this issue in general.
There's no advantage over esm: true, as it's a different use case. rewriteRelativeImportExtensions allows to import .ts files, so that TypeScript-runtimes without build/transpile-step can correctly handle the file resolution.

You can see an example in the beta announcement I linked in my first message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant