microsoft / microsoft/TypeScript
Display signature help or completions for tuples with labels
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Suggestion
🔍 Search Terms
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
✅ Viability 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, new syntax sugar for JS, etc.)
- [x This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
📃 Motivating Example
declare const coords: [x: number, y: number]
const [/**/] = coords
The problem: having no idea what a name to type as you don't know what the type of it.
I'm using it with my plugin and it looks very simple (and useful IMO):
Of course, you can hover of the variable to fiture it out, but what about the following example:
const a: {
coords: [x: number, y: number] | string | { x: number; y: number }/* | even more types */
} = {
coords: [/**/], // the type with x, y tuples can be even truncated, so you can only guess names of labels
}
I understand that labeled tuples introduced in ts4.0 were designed primarily for parameters usage, but I've seen them used for shorter static data declarations as well.
However, if you think that usage signature help is redundant and incorrect, what about having completions for tuple labels at least? There is already completions when acessing such symbols via dot property access. For example for first example it would be keyword completion with label x and [0]: number detail.
💻 Use Cases
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando gli esempi di labeled tuples e i due comportamenti proposti: signature help durante la destrutturazione di tuple e completions per tuple labels. Definisci quale comportamento dovrebbe essere supportato e come dovrebbe funzionare per unions o truncated tuple types, quindi individua i relativi entry points e test di TypeScript language-service. Il lavoro è completato quando l’interazione scelta fornisce informazioni utili sulle label senza modificare l’output di runtime.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- developer-experience
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100