microsoft / microsoft/TypeScript
rewriteRelativeImportExtensions: tsc doesn't rewrite extensions in emitted declaration files
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
🔎 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!
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema con index.ts e un tsconfig.json che abiliti rewriteRelativeImportExtensions e declaration, quindi traccia il percorso di emissione delle dichiarazioni di tsc per questa opzione. Il lavoro è completato quando il .d.ts emesso riscrive './file.ts' in './file.js' in modo coerente con l'output JavaScript, con una copertura per il caso segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 55/100