microsoft / microsoft/TypeScript

Allow mapped tuples to have behaviour based on index

Aperta
#29,920 3 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

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.

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

La issue non indica file, test o punti di ingresso, quindi esamina innanzitutto il comportamento attuale delle tuple mappate e il modo in cui TypeScript rappresenta le posizioni delle tuple. Chiarisci le regole previste per l’optionalità in base al primo e all’ultimo indice prima di proporre l’implementazione e i test; per considerare il lavoro completato sarebbero necessari un design concordato e un comportamento del compilatore validato.

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.