microsoft / microsoft/TypeScript

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

Abierto
#28,800 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Awaiting More Feedback Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza analizando los ejemplos propuestos de IShape, IShapeType e IShapeTSType para aclarar la semántica prevista de las restricciones genéricas y la herencia. Define qué sintaxis debería aceptarse y verifica que evita restricciones duplicadas sin cambiar la salida de JavaScript; el issue no menciona archivos de implementación ni pruebas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.