microsoft / microsoft/TypeScript

Shorten method signatures (aka "type madness")

Open
#14,662 11 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Signature Help Domain: LS: Type Display Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Some of the types that make everything work behind the scenes are ridiculous. For example, from Vue.js:

image

For a Vue developer creating a new Vue instance in JavaScript, they will be exposed to this every time. If they already know what arguments to supply, this does not do a great job as a quick reminder. If they don't know what args to supply, this is probably not very helpful either. We should be able to give users an option to show a concise method signature like the following.

image

In this example, the tildas indicate that there is "type madness" hidden below. If the user really wants to see the types, they can goToDefinition or maybe we could give them a way to expand the signature window.

We would need to pick some arbitrary line when to display type information and when to hide it. My initial thinking is something along the lines of:

  • Hide all generic types, but leave angle brackets in
  • Hide types when there are more than 2 unions or intersections
  • Show string literals if less than 100 characters (roughly 2 lines?)

I would imagine we would also want to give JavaScript users the concise signature by default and TypeScript users the full signature by default, but give both the camps the ability to configure to their preference.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by reviewing the proposed rules for hiding generic types, unions, intersections, and long string literals, along with the requested JavaScript and TypeScript defaults; done means users can configure concise or full signatures and see the intended form.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.