microsoft / microsoft/TypeScript

Generic Type constraint from base classes, interfaces (Pass through)

Aperta
#28,800 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia analizzando gli esempi proposti di IShape, IShapeType e IShapeTSType per chiarire la semantica prevista dei vincoli generici e dell’ereditarietà. Definisci quale sintassi dovrebbe essere accettata e verifica che eviti vincoli duplicati senza modificare l’output JavaScript; l’issue non indica file di implementazione né test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.