microsoft / microsoft/TypeScript

Display signature help or completions for tuples with labels

Offen
#53,197 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Experience Enhancement Help Wanted Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Durchsicht der Beispiele für labeled tuples und der beiden vorgeschlagenen Verhaltensweisen: signature help während der Destrukturierung von tuples und completions für tuple labels. Lege fest, welche Verhaltensweise unterstützt werden sollte und wie sie für unions oder truncated tuple types funktionieren sollte, und ermittle anschließend die relevanten TypeScript language-service entry points und Tests. Als abgeschlossen gilt die Aufgabe, wenn die gewählte Interaktion nützliche label-Informationen liefert, ohne die runtime-Ausgabe zu ändern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
developer-experience
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.