microsoft / microsoft/TypeScript

rewriteRelativeImportExtensions does not rewrite the extension for an import expressions unless the file is detected to be a module

Open
#60,599 6 comments 0 reactions 1 assignee View on GitHub

@andrewbranch is already working on this.

Since Nov 28, 2024.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

🔎 Search Terms

rewriteRelativeImportExtensions, import expression

🕗 Version & Regression Information
  • This changed between versions 5.7
⏯ Playground Link

https://www.typescriptlang.org/play/?rewriteRelativeImportExtensions=true#code/PTAEEsFsAcHsCcAuoDkA6YAzWs2IM4oDcAsAFBRxIAU6WOehAlOUA

💻 Code

Test One

import('./foo.ts')

Test Two

import './foo.ts';
import('./foo.ts')
🙁 Actual behavior

JS Output

Test One

import('./foo.ts') // ❌

Test Two

import './foo.js'; // ✅
import('./foo.js') // ✅
🙂 Expected behavior

JS Output

Test One

import('./foo.js') // ✅

Test Two

import './foo.js'; // ✅
import('./foo.js') // ✅
Additional information about the issue

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.