microsoft / microsoft/TypeScript
rewriteRelativeImportExtensions: tsc doesn't rewrite extensions in emitted declaration files
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
### 🔎 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!
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề với index.ts và một tsconfig.json bật rewriteRelativeImportExtensions và declaration, sau đó lần theo đường dẫn phát hành declaration của tsc cho tùy chọn này. Hoàn tất khi .d.ts được phát hành viết lại './file.ts' thành './file.js' nhất quán với đầu ra JavaScript, với kiểm thử bao phủ trường hợp được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- compilers
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 55/100