microsoft / microsoft/TypeScript
Display signature help or completions for tuples with labels
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the labeled-tuple examples and the two proposed behaviors: signature help during tuple destructuring and completions for tuple labels. Define which behavior should be supported and how it should work for unions or truncated tuple types, then identify the relevant TypeScript language-service entry points and tests. Done means the chosen interaction provides useful label information without changing runtime output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100