-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
rewriteRelativeImportExtensions: tsc doesn't rewrite extensions in emitted declaration files #61037
Comments
This seems to be intentional, or at least not considered a bug: #59767 (comment) |
Reading the Ryan Cavanaugh's comment and the rest of this thread let me think it's not really intentional but a form of "it's OK for TS, so there's no real problem with that". He only says what is clearly and intentionally not supported is the aliases resolving and rewriting, but it's not the problem here. I can't find any tests about this behavior in the linked PR, and the documentation doesn't mention it at all, it just says "output files", not "output files, excluding declaration files":
I really think generated .d.ts files were simply forgotten by this feature. |
Can you clarify what usages in particular? This isn't very concrete and there's no way for me to verify what you're referencing. |
The usage problem that I encountered is precisely the one mentioned here : #59767 (comment). What this comment doesn't say, is it occurs in PhpStorm/WebStorm. I don't know for other IDEs or tools, I can only presume that the support is uneven, but at least Jetbrains IDEs fail to resolve relative So what the problem behind that? It's really simple: finding public libraries with Since the introduction of the So Ryan, as you are one the deciders of the Typescript team, if
Thank you for your time! |
🔎 Search Terms
"rewriteRelativeImportExtensions", "extensions", "declaration", ".d.ts"
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
In an index.ts file:
then build it with
tsc
and"rewriteRelativeImportExtensions": true
&"declaration": true
in thecompilerOptions
of yourtsconfig.json
🙁 Actual behavior
Built files content:
In the JS file,
index.js
, the extension is rewritten to .js:In the declaration file,
index.d.ts
, the extension is not rewritten to .js:🙂 Expected behavior
In the declaration file, the extension should be rewritten to .js too:
Additional information about the issue
It occurs in the current TS 5.7.3 and in the next version (5.8.0-dev.20250123 at this time). Even if TS correctly interprets
.d.ts
files with.ts
extensions inimport
/export
, it's not the case of the IDE I use, PhpStorm. It can't provide a real code assistance with these declaration files.In fact, I don't really know if it's a feature, a bug or an oversight in
tsc
, or ifrewriteRelativeImportExtensions
is just too new to be completely supported by all IDEs! Let me know!The text was updated successfully, but these errors were encountered: