microsoft / microsoft/TypeScript

`typeof class`

Abierto
#41,581 2 comentarios 43 reacciones 2 asignados Ver en GitHub

@ahejlsberg ya está trabajando en esto.

Desde el 18/11/2020.

Awaiting More Feedback Needs Proposal Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

@ahejlsberg has had a few experiments to try to make it easier to describe the type of a class. Specifically:

  • avoiding the awkward static/instance pattern that users need to write on anonymous object types/interface types

    var Thing: {
      new () => {
        instanceField: number;
      }
      staticField: string;
    }
    
  • allowing users to describe types with class-specific characteristics (e.g. abstract)

The idea is to allow typeof to be followed by a class expression.

var Thing: typeof class Thing {
  static staticField: string;

  instanceField: number;
  constructor() {}
}

There are definitely some subtleties here. For example, handling loops and whether this syntax is allowed in JSDoc with a TypeScript-annotated class:

/** @type { typeof class C<T> { x: T } } */
//                        ^^^    ^^^
// TypeScript type parameters and annotations
// Are these allowed?
var Thing;

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.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.