microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.29k stars 12.39k forks source link

is it possible to make VScode's parameter suggestions more readable? #52512

Open mikemaccana opened 1 year ago

mikemaccana commented 1 year ago

This may be a question rather than a feature request (I imagine it's a fairly common problem) but I can't seem to find anything re: configuring this.

Currently VScode shows type hints on very, very wide lines: enter image description here

It's hard for me to work out what value I am setting or each of the long list of parameters. Instead of:

getOrCreateAssociatedTokenAccount(connection: Connection, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, commitment?: Commitment, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey): Promise<...>

It would nicer to have something like:

getOrCreateAssociatedTokenAccount(
  connection: Connection, 
  payer: Signer, 
  mint: PublicKey, 
  owner: PublicKey, 
  allowOwnerOffCurve?: boolean, 
  commitment?: Commitment, 
  confirmOptions?: ConfirmOptions, 
  programId?: PublicKey, 
  associatedTokenProgramId?: PublicKey
):  Promise<...>

How can I make VScode's type suggestions more readable? I'm hoping for something I can tweak in IntelliSense settings etc.

Forlini91 commented 1 year ago

Also, it would be great to know something more about that Promise<...> as well (it fits with the request "make it more readable"). Maybe a "click here to show the full type" button which expands those 3 dots?

mikemaccana commented 1 year ago

Another option would be to combine the top and bottom parameter lists, which would:

getOrCreateAssociatedTokenAccount() Retrieve the associated token account, or create it if it doesn't exist

@param connection: Connection — Connection to use @param payer: Signer — Payer of the transaction and initialization fees @param mint:PublicKey — Mint associated with the account to set or verify @param owner:PublicKey — Owner of the account to set or verify @param allowOwnerOffCurve?: boolean — Allow the owner account to be a PDA (Program Derived Address) @param commitment?: Commitment — Desired level of commitment for querying the state @param confirmOptions?: ConfirmOptions — Options for confirming the transaction @param programId?: PublicKey — SPL Token program account @param associatedTokenProgramId?: PublicKey — SPL Associated Token program account

@return Promise<PublicKey> — Address of the new associated token account

mikemaccana commented 1 year ago

Another part of the issue is the bottom area doesn't always appear (I think it needs docstrings or similar):

image hence I don't look for it.

If there was just a single readable area, showing parameter, type, and docstring if it exists, that would help me read the parameters quicker.

RyanCavanaugh commented 1 year ago

@mjbvz a mini-spec about what should change here would be helpful

mjbvz commented 1 year ago

@RyanCavanaugh Not sure. VS Code should already highlight the currently active parameter:

Screenshot 2023-02-07 at 11 12 41 AM

Maybe it would help if we also supported syntax highlighting, like normal hovers do? https://github.com/microsoft/vscode/issues/55044

In the first example though, expanding the types to multiple lines would potentially make it more readable but also push down documentation so that you have to scroll to see it

Maybe this needs some design work on the TS side to figure out what would be most helpful /cc @DanielRosenwasser

mikemaccana commented 1 year ago

Not sure if you saw my comments / proposal earlier @mjbvz - combining the types and the documentation would make types more readable and save space - there would be less scrolling / vertical space than the current UI requires.

Regarding highlighting currently active parameter that's not happening here in current stable 1.75.0:

image
mjbvz commented 1 year ago

@mikemaccana Good ideas but needs more thought. We still need to show the function documentation and docs for the individual parameters may be long, which will then force any additional parameters off screen

Also the active parameter highlighting is specific to the parameter hints / signature help UI. You won't see it in a normal hover like your screenshot shows

mikemaccana commented 1 year ago

@mjbvz Thanks!

For very long documentation for an individual parameter, we can wrap, have an expandable UI (eg for function parameters), or use ellipses. The current UI has the same issues regarding individual parameters that are very long, with the added clutter of a very long parameter being inlined in the middle of a paragraph about its sibling parameters.

Regarding:

Also the active parameter highlighting is specific to the parameter hints / signature help UI. You won't see it in a normal hover like your screenshot shows

How do I get the parameter hints / signature help UI? All I know is the hover.

fatcerberus commented 1 year ago

@mikemaccana It’s late but, press ctrl+shift+space while the cursor is inside the argument list.

chriskuech commented 1 year ago

Similarly there doesn't seem to be a way to navigate through the docs for other matching overloads