microsoft / microsoft/TypeScript
rewriteRelativeImportExtensions: tsc doesn't rewrite extensions in emitted declaration files
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
🔎 Search Terms
"rewriteRelativeImportExtensions", "extensions", "declaration", ".d.ts"
🕗 Version & Regression Information
- This is the behavior in every version I tried (even in the next 5.8.0), and I reviewed the FAQ for entries about "rewriteRelativeImportExtensions"
⏯ Playground Link
No response
💻 Code
In an index.ts file:
export * from './file.ts';
then build it with tsc and "rewriteRelativeImportExtensions": true & "declaration": true in the compilerOptions of your tsconfig.json
🙁 Actual behavior
Built files content:
In the JS file, index.js, the extension is rewritten to .js:
export * from './file.js';
In the declaration file, index.d.ts, the extension is not rewritten to .js:
export * from './file.ts';
🙂 Expected behavior
In the declaration file, the extension should be rewritten to .js too:
export * from './file.js';
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 in import/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 if rewriteRelativeImportExtensions is just too new to be completely supported by all IDEs! Let me know!
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Problem mit index.ts und einer tsconfig.json, die rewriteRelativeImportExtensions und declaration aktiviert, und verfolge anschließend den Declaration-Emit-Pfad von tsc für diese Option. Als abgeschlossen gilt die Aufgabe, wenn der erzeugte .d.ts-Verweis './file.ts' konsistent mit der JavaScript-Ausgabe in './file.js' umgeschrieben wird und der gemeldete Fall durch Tests abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100