microsoft / microsoft/TypeScript
Property is not assignable to the same property in generic base type
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- PR merge metrics
- PR metrics pending
Description
### 🔎 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;
}
}
```
Contributor guide
Research direction
Start by reproducing the example from the linked TypeScript Playground and compare the generic method in Rho with the implementation in Bluffer. Trace the type-checking path for generic method compatibility; done means the reproduction reports no error without breaking related assignability behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100