microsoft / microsoft/TypeScript
Property is not assignable to the same property in generic base type
- 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
Property is not assignable to the same property in generic base type
### 🕗 Version & Regression Information
-This is the behavior in every version I tried, and I reviewed
### ⏯ Playground Link
https://www.typescriptlang.org/zh/play/?ts=5.8.3#code/IYIwzgLgTsDGEAJYBthjAgSgCwPYIG8AoBBUSGeBABwEsATAc1oDswAeAMQH0BRBAKYAPCAJb0MLAK4BbEAKgAaBDwBSAPgAUIKFLABHKQMgAuFd1UIAPud4BKM2uu2A3EQC+RFGgwAhZFIAZoEKgiJiElh4hCQ0DMxsXHxhouKSsvJK5hraugZGptnOPPaOFsXJscSkpFACEFJQLKQ6eobGEG6knp5AA
### 💻 Code
```ts
abstract class Rho {
abstract pidgins(brusquest: F_J | F_E): F_J | F_E;
}
class Bluffer extends Rho {
pidgins(brusquest: F_J | F_E): F_J | F_E
{
return brusquest;
}
}
```
### 🙁 Actual behavior
Property 'pidgins' in type 'Bluffer' is not assignable to the same property in base type 'Rho'.
Type '(brusquest: F_E | F_J) => F_E | F_J' is not assignable to type '(brusquest: F_E | F_J) => F_E | F_J'. Two different types with this name exist, but they are unrelated.
Type 'number | F_E | F_J' is not assignable to type 'F_E | F_J'.
Type 'number' is not assignable to type 'F_E | F_J'.(2416)
### 🙂 Expected behavior
No error
### Additional information about the issue
The following works with no error:
```
abstract class Rho {
abstract pidgins(brusquest: F_J | F_E): F_J | F_E;
abstract pidgins(brusquest: F_J | F_E): F_J | F_E;
}
class Bluffer extends Rho {
pidgins(brusquest: F_J | F_E): F_J | F_E
{
return brusquest;
}
}
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện ví dụ từ TypeScript Playground được liên kết và so sánh phương thức generic trong Rho với phần triển khai trong Bluffer. Truy vết đường đi của quá trình kiểm tra kiểu cho tính tương thích của các phương thức generic; được xem là hoàn thành khi bản tái hiện không báo lỗi mà không làm hỏng hành vi có thể gán liên quan.
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
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100