microsoft / microsoft/TypeScript
Enhance members of literal type like const array type (e.g. string literal types should have literal length property)
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
The const array type, its principle members are also be the constant. When define a const array [number, string, boolean], its length type be 3. Also, when access to special index, the type also points the exact const type.
function const_array(): void
{
let elements: [number, string, false] = [3, "something", false];
let length: 3 = elements.length;
let first: number = elements[0];
let second: string = elements[1];
let third: false = elements[2];
}
However, the literal type is not like the const array. When define a literal type "something", its length be not 9 but number. Also, when access to a special index, the type is not a special literal type but a string type.
function literal(): void
{
let word: "something" = "something" as const;
let length: number = something.length; // not 9 but number
let first: string = word[0]; // not "s" but string
let second: string = word[1]; // not "o" but string
let third: string = word[2]; // not "m" but string
}
What about enhancing the literal type to be like the const array type?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
No se nombran archivos ni pruebas. Empieza localizando las rutas de comprobación de tipos para el acceso a propiedades mediante literales de cadena y el acceso indexado, y luego compara su comportamiento con el manejo de tuplas. Se considera terminado cuando las cadenas literales exponen una longitud literal y tipos de caracteres literales en índices conocidos, con pruebas adecuadas de comprobación de tipos.
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
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100