microsoft / microsoft/TypeScript

Allow mapped tuples to have behaviour based on index

Abierto
#29,920 3 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
1 d 19 h
PR fusionados (30 d)
117

Descripción

Search Terms

mapped tuples index

Suggestion

I want to be able to create a tuple from function parameters and have all elements in the tuple optional other than the firstK

Use Cases

I am trying to create a curry implementation that allows you to curry any number of parameters. The first parameter must be specified but all other params are optional.
Would be good to be able to remove the last param as well.

Examples

something along the lines of

type OptionalExceptFirst<T> = {
    [K in keyof T]:isFirst ? ? T[K] : T[K];
};
type AllExceptLast<T> = {
    [K in keyof T]:isLast ? never : T[K];
};

The syntax will need some work hopefully the intended functionality is clear.

Checklist

My suggestion meets these guidelines:

  • [x ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [ x] This wouldn't change the runtime behavior of existing JavaScript code
  • [ x] This could be implemented without emitting different JS based on the types of the expressions
  • [ x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [ x] 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

El issue no nombra archivos, tests ni puntos de entrada, así que primero revisa cómo se comportan actualmente las tuplas mapeadas y cómo TypeScript representa las posiciones de las tuplas. Aclara las reglas previstas para la opcionalidad basándote en los primeros y últimos índices antes de proponer la implementación y los tests; para darlo por terminado se requerirían un diseño acordado y un comportamiento del compilador validado.

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.