microsoft / microsoft/TypeScript
Generic Type constraint from base classes, interfaces (Pass through)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
The ability to allow extends type constraint to be an abstract specification of base class, interface.
This also prevent duplication, by having to define the type constraint twice, reduces the need for unnecessary intermediate interfaces.
type ID = string
interface IShape<TID extends ID, Neasted>{
__ID: TID;
__Neasted : Neasted
}
interface ITSShape<T, ID>
{
__tsType: T;
__ID: ID;
}
interface IShapeType extends IShape<'T', boolean | number | null>
{
}
Not possible
interface IShapeTSType<T extends ['__Neasted']> extends IShapeType
{
__tsType : T;
}
interface IShapeTSType<T extends ['__Neasted']> extends IShape<'T', boolean | number | string>
{
__tsType : T;
}
interface IShapeTSType<T extends this['__Neasted']> extends IShapeType
{
__tsType : T;
}
interface IShapeTSType<T extends TShape['__Neasted'], TShape extends IShapeType> extends TShape
{
__tsType : T;
}
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Analyse der vorgeschlagenen Beispiele für IShape, IShapeType und IShapeTSType, um die beabsichtigte Semantik generischer Einschränkungen und Vererbung zu klären. Definiere, welche Syntax akzeptiert werden sollte, und stelle sicher, dass sie doppelte Einschränkungen vermeidet, ohne die JavaScript-Ausgabe zu ändern; das Issue nennt weder Implementierungsdateien noch Tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100