GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add inlay hints support by Kingwl · Pull Request #42089 · microsoft/TypeScript

Conversation

@Kingwl

@Kingwl Wenlu Wang (Kingwl) commented Dec 23, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #42073

Features:

  • Parameter name hint for arguments
  • Type hint for parameter
  • Type hint for variable
  • Type hint for field
  • Type hint for return type
  • Type hint for call chains
  • Value hint for numerical enums
  • Control to show parameter name hint for non-literal arguments or not
  • Control to show type hints for require assigned variable.
  • Control to show parameter name if arguments is the same as parameter name

Something need to consider:

  • Truncated: For now. I have truncate the hints with hard code 30.
  • Preference: We have many options to specified the behavior. Currently we pass them by UserPreferences.
  • Complex types: Many types may very very long after serialization (function like, complex object, etc.). Should we handle them?
  • Type Parameter: The root cause is we could inference type from type node or type. Which one should we take? I think type is better.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

0xycvv, calebboyd, mjbvz, mooman219, Shinigami92, tonivj5, worstpractice, varHarrie, vshab, ghiscoding, and 32 more reacted with thumbs up emoji ghiscoding, rokinsky, iagobruno, lizraeli, btoo, amitbeck, leonardssh, dotansimha, alexpaluzzi, Wazbat, and 2 more reacted with heart emoji amitbeck, leonardssh, fabb, dotansimha, chuckdries, and so1ve reacted with rocket emoji
All reactions
  • 👍 42 reactions
  • ❤️ 12 reactions
  • 🚀 6 reactions
@Kingwl
Add signature arguments label support
cd99389
@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 23, 2020

Copy link
Copy Markdown
Contributor

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping Sheetal Nandi (@sheetalkamat), Andrew Casey (@amcasey), Matt Bierner (@mjbvz), Mine Starks (@minestarks) for you. Feel free to loop in other consumers/maintainers if necessary

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 23, 2020
@Kingwl

Wenlu Wang (Kingwl) commented Dec 23, 2020

Copy link
Copy Markdown
Contributor Author

Matt Bierner (@mjbvz)
Please take a look about protocol or naming.
Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Wenlu Wang (Kingwl) added 3 commits December 24, 2020 14:25
@Kingwl
Support rest parameters and destruction
ab3c937
@Kingwl
make lint
d91b2f7
@Kingwl
Fix tuple rest parameters
8388add
@Kingwl

Wenlu Wang (Kingwl) commented Dec 24, 2020

Copy link
Copy Markdown
Contributor Author

image

Basically work like this.

ishantheperson, eczn, simeyla, epidemian, leonardssh, Wazbat, and stakx reacted with hooray emoji
All reactions
  • 🎉 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Wenlu Wang (Kingwl) added 8 commits December 25, 2020 00:37
@Kingwl
Adjust name styles
1058fdd
@Kingwl
Rename to inline hints
1517b1f
@Kingwl
Partition inline hints
fd9b09f
@Kingwl
Adjust range pred
23afce2
@Kingwl
Add function expression like hints
ee6527e
@Kingwl
Support configure inline hints
679b58d
@Kingwl
Display hints in single line
446bee4
@Kingwl
Add test suits and tests
d2fbd1e
@Kingwl

Wenlu Wang (Kingwl) commented Dec 27, 2020

Copy link
Copy Markdown
Contributor Author

TypeScript Bot (@typescript-bot) pack this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 27, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wenlu Wang (@Kingwl), I've started to run the tarball bundle task on this PR at d2fbd1e. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 27, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Hey Wenlu Wang (@Kingwl), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/92086/artifacts?artifactName=tgz&fileId=5999C09B7BA4F0275D38BC9FCAC3474C22A8EDBA92BDD336E0A2658DE15F7C1B02&fileName=/typescript-4.2.0-insiders.20201227.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kingwl
Add range tests
c4abb87
@Kingwl Wenlu Wang (Kingwl) changed the title [WIP] Add signature arguments label support Add signature arguments label support Dec 28, 2020
@Kingwl
Wenlu Wang (Kingwl) marked this pull request as ready for review December 28, 2020 08:04
@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 28, 2020

Copy link
Copy Markdown
Contributor

The TypeScript team hasn't accepted the linked issue #42073. If you can get it accepted, this PR will have a better chance of being reviewed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kingwl Wenlu Wang (Kingwl) changed the title Add signature arguments label support Add inline hints support Dec 28, 2020
@Kingwl
Wenlu Wang (Kingwl) marked this pull request as draft December 29, 2020 10:02
Wenlu Wang (Kingwl) added 5 commits December 29, 2020 23:42
@Kingwl
Support more hints
a9e007a
@Kingwl
Add more options
df62a11
@Kingwl
Fix logical
fce2619
@Kingwl
Add more cases
679f066
@Kingwl
Support call chains
eb4b4ad
jessetrinity
Jesse Trinity (jessetrinity) reviewed Jun 24, 2021
View reviewed changes
Comment thread tests/cases/fourslash/inlayHintsShouldWork49.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@andrewbranch

Andrew Branch (andrewbranch) commented Jun 24, 2021

Copy link
Copy Markdown
Member

Should identifier be a literal argument?

Well, let me think about some examples:

f(1);
f(1 + 2);

f("Some String");
f("Some String".toLowerCase());
f(someString);
f(someString.toLowerCase());

f([0, 1, 2]);
f([0, 1, 2].map(processNumber));
f(integers);
f(integers.map(processNumber));

In these cases, I feel like the literal arguments and the expressions made up of literals convey the same amount of semantic information. I don’t think the + 2 or the .toLowerCase() or the .map(processNumber) does anything to negate the value of the parameter name hint.

That said, someString vs. someString.toLowerCase() and integers vs. integers.map(processNumber) also feel like they convey about the same amount of information. I’m fine just doing the same thing as C#, but the ParenthesizedExpression example in the test looked very strange to me. I think it would be appropriate to skipParentheses since we generally recognize that parens have no semantic meaning. But it’s not a big deal. Maybe someone would find it valuable to be able to force a hint to show up by parenthesizing an identifier. It’s not a blocker from me, just curious what the rationale was.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jessetrinity
Jesse Trinity (jessetrinity) reviewed Jun 24, 2021
View reviewed changes
Comment thread tests/cases/fourslash/inlayHintsShouldWork39.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

jessetrinity
Jesse Trinity (jessetrinity) reviewed Jun 24, 2021
View reviewed changes
Comment thread tests/cases/fourslash/inlayHintsShouldWork1.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

jessetrinity
Jesse Trinity (jessetrinity) reviewed Jun 24, 2021
View reviewed changes
Comment thread tests/cases/fourslash/inlayHintsShouldWork10.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Wenlu Wang (Kingwl) added 3 commits June 25, 2021 01:52
@Kingwl
Rename option
d8dc8f1
@Kingwl
Avoid makers
52c9d5c
@Kingwl
Skip parens for argument
7ce7a44
@Kingwl

Wenlu Wang (Kingwl) commented Jun 24, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I've updated followed the comments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jessetrinity
Jesse Trinity (jessetrinity) reviewed Jun 24, 2021
View reviewed changes
Comment thread src/compiler/types.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/server/protocol.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/server/protocol.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Kingwl
Fix CR issues
24e1a4a
@jessetrinity

Jesse Trinity (jessetrinity) commented Jun 24, 2021

Copy link
Copy Markdown
Contributor

I haven't tried this out yet to see how it actually plays. I assume I need vscode insiders?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrewbranch

Andrew Branch (andrewbranch) commented Jun 24, 2021

Copy link
Copy Markdown
Member

Jesse Trinity (@jessetrinity) you need a local build of microsoft/vscode#113412

jessetrinity reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andrewbranch
Andrew Branch (andrewbranch) approved these changes Jun 24, 2021
View reviewed changes

@andrewbranch Andrew Branch (andrewbranch) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bearing with us on the last-minute updates, Wenlu Wang (@Kingwl) 🌟

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jessetrinity
Jesse Trinity (jessetrinity) suggested changes Jun 24, 2021
View reviewed changes

@jessetrinity Jesse Trinity (jessetrinity) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InlayHintKind was changed to

export const enum InlayHintKind {
  Type = "Type",
  Parameter = "Parameter",
  Enum = "Enum",
}

in protocol.ts but nowhere else.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Kingwl reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread src/services/types.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/baselines/reference/api/tsserverlibrary.d.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/baselines/reference/api/typescript.d.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/cases/fourslash/fourslash.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Wenlu Wang (Kingwl) added 2 commits June 25, 2021 11:59
@Kingwl
Fix enums
6b279e7
@Kingwl
Accept baseline
8e9a8d8
jessetrinity
Jesse Trinity (jessetrinity) approved these changes Jun 25, 2021
View reviewed changes
@jessetrinity
Jesse Trinity (jessetrinity) merged commit 66b4ba4 into microsoft:main Jun 25, 2021
@Kingwl
Wenlu Wang (Kingwl) deleted the signature_arguments_labels_support branch June 25, 2021 06:42
@Kingwl

Wenlu Wang (Kingwl) commented Jun 25, 2021

Copy link
Copy Markdown
Contributor Author

Thanks!

andrewbranch, ElianCordoba, CodeStix, and leonardssh reacted with hooray emoji
All reactions
  • 🎉 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kingwl Wenlu Wang (Kingwl) mentioned this pull request Jun 25, 2021
Add ts inline hints microsoft/vscode#113412
Merged
@resolritter João Paulo Silva de Souza (resolritter) mentioned this pull request Jul 5, 2021
Implement inlay hints neoclide/coc-tsserver#300
Closed
@entropitor Jens Claes (entropitor) mentioned this pull request Aug 28, 2021
Support typescript inlay hints? nvim-lua/lsp_extensions.nvim#28
Closed
@entropitor Jens Claes (entropitor) mentioned this pull request Sep 16, 2021
Support inlay hints typescript-language-server/typescript-language-server#258
Closed
@alex-kinokon Alex (alex-kinokon) mentioned this pull request Oct 12, 2021
Parameter Hints shown inline all the time (like IntelliJ) microsoft/vscode#16221
Closed
@shivjm Shiv Jha-Mathur (shivjm) mentioned this pull request Apr 9, 2022
Add support for inlay hints from TypeScript language server emacs-lsp/lsp-mode#3455
Merged
@HolgerJeromin Holger Jeromin (HolgerJeromin) mentioned this pull request Aug 12, 2022
Support inlay hints in Visual Studio (2019/2022) #50285
Open
5 tasks done
@Avishayy

Avishay Matayev (Avishayy) commented Jan 9, 2023

Copy link
Copy Markdown

Thanks for creating such a great feature!

I have a question, why is there a limit on the hint length? Specifically, why is maxHintsLength set to 30? Are there any plans to change it sometime?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) DanielRosenwasser requested changes
@andrewbranch Andrew Branch (andrewbranch) andrewbranch approved these changes
@sheetalkamat Sheetal Nandi (sheetalkamat) Awaiting requested review from sheetalkamat
@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) Awaiting requested review from RyanCavanaugh
+1 more reviewer
@jessetrinity Jesse Trinity (jessetrinity) jessetrinity approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@sheetalkamat Sheetal Nandi (sheetalkamat)

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

PR Backlog
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Support inlay hints

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@Kingwl @typescript-bot @Jack-Works @minestarks @xiaoxiangmoe @DanielRosenwasser @ghiscoding @andrewbranch @jessetrinity @Avishayy @sheetalkamat
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.