microsoft / microsoft/TypeScript

TSC should not error on valid subpath specifier syntax (TS2877)

Đang mở
#63,129 14 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Awaiting More Feedback Suggestion
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

TS2877

### 🕗 Version & Regression Information

This changed between versions 5.6 and 5.7 (best guess; 5.7 introduced `rewriteRelativeImportExtensions`).

### ⏯ Playground Link

https://www.typescriptlang.org/play/?rewriteRelativeImportExtensions=true&resolvePackageJsonExports=true&resolvePackageJsonImports=true&noUncheckedSideEffectImports=true&allowArbitraryExtensions=true&allowImportingTsExtensions=true#code/PTAEEkFsAcHsCcAuBnUAbAlgawKakQBY7J4DGAhgK4mgAqAygEwAcA7KwDQBQIoA7kQB2oDMIBm5UonxF4OAOSpBsQqIDm-eLEEbyAI1iVphHJAB0XHmAACKALQ4AHtBxSH8LfABcMjKj6GaAAmoHIAjpQYcqDkoNCSWORqOGYAVsja+LChxLBoAG44XBgwCNIARADE5JikKSjlANxcQA

### 💻 Code

```ts
// Imports like these cause TS2877,
// when in fact there's nothing wrong about them.
import "#alice.ts";
```

### 🙁 Actual behavior

```txt
error TS2877: This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path.
```

### 🙂 Expected behavior

Don't error.

### Additional information about the issue

Specifiers aren't paths. Especially subpath imports and exports allow for almost arbitrary string rewriting. The compiler is blatantly wrong about this.

Edit: I've created a [repro repo](https://github.com/valler/repro-repo-for-ms-typescript-issue-63129).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với bản tái hiện được liên kết trên Playground và repository repro, sử dụng các tùy chọn compiler được liệt kê và chẩn đoán TS2877 làm điểm bắt đầu. Truy tìm lý do import subpath '#alice.ts' bị coi là một tệp đầu vào không thể ghi lại. Được xem là hoàn tất khi specifier hợp lệ này không còn tạo ra TS2877, trong khi hành vi đối với đường dẫn tương đối được báo cáo vẫn được giữ nguyên.

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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
64/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.