microsoft / microsoft/TypeScript
rewriteRelativeImportExtensions: tsc doesn't rewrite extensions in emitted declaration files
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
### 🔎 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:
```ts
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:
```ts
export * from './file.js';
```
In the declaration file, `index.d.ts`, the extension is not rewritten to .js:
```ts
export * from './file.ts';
```
### 🙂 Expected behavior
In the declaration file, the extension should be rewritten to .js too:
```ts
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!
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el problema con index.ts y un tsconfig.json que habilite rewriteRelativeImportExtensions y declaration; después, sigue la ruta de emisión de declaraciones de tsc para esta opción. Se considera terminado cuando el .d.ts generado reescriba './file.ts' a './file.js' de forma coherente con la salida de JavaScript, con cobertura para el caso reportado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 55/100