microsoft / microsoft/TypeScript
Property is not assignable to the same property in generic base type
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
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;
}
}
```
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par reproduire l’exemple du TypeScript Playground lié et comparez la méthode générique dans Rho avec l’implémentation dans Bluffer. Suivez le chemin de vérification des types pour la compatibilité des méthodes génériques ; le travail est terminé lorsque la reproduction ne signale aucune erreur sans casser le comportement d’assignabilité associé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100