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 — Don't have type annotations on suggested object literal methods by gabritto · Pull Request #48607 · microsoft/TypeScript

Conversation

@gabritto

@gabritto Gabriela Araujo Britto (gabritto) commented Apr 8, 2022

Copy link
Copy Markdown
Member

Fixes #48606.

This is what it will look like without the type annotations:
image
image
The label details look less pretty now IMO, but I think still good enough to distinguish between non-snippet and snippet completion entries?

Sorry, something went wrong.

Uh oh!

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

All reactions
@gabritto
don't have type annotations on suggested object literal methods
f319771
@typescript-bot TypeScript Bot (typescript-bot) assigned Gabriela Araujo Britto (gabritto) Apr 8, 2022
@typescript-bot TypeScript Bot (typescript-bot) added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Apr 8, 2022
@gabritto
Gabriela Araujo Britto (gabritto) requested review from Daniel Rosenwasser (DanielRosenwasser), Andrew Casey (amcasey) and Andrew Branch (andrewbranch) April 8, 2022 00:47
andrewbranch
Andrew Branch (andrewbranch) approved these changes Apr 8, 2022
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.

Huh, didn’t even think about the fact that this makes us not have to do auto-imports on them either.

We could keep the type annotations in the label (but no the insertText) if we think that makes it more clear or useful, but I think this is probably best.

Sorry, something went wrong.

Uh oh!

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

gabritto and DanielRosenwasser reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@gabritto

Gabriela Araujo Britto (gabritto) commented Apr 8, 2022

Copy link
Copy Markdown
Member Author

We could keep the type annotations in the label (but no the insertText) if we think that makes it more clear or useful, but I think this is probably best.

Yeah, I considered that, but seems rather confusing. But I don't know, given how I didn't even noticed we could do without the type annotations, I could be very wrong.

All reactions

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Apr 8, 2022

Copy link
Copy Markdown
Member

For really basic signatures I would probably prefer the type annotations displayed; I can see more complex signatures appearing as noise that obscure the parameter names (which would be even worse for JS users).

I can go either way on this to be honest, and hearing from users about it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@amcasey

Andrew Casey (amcasey) commented Apr 11, 2022

Copy link
Copy Markdown
Member

Does anyone else find it confusing seeing both bar and bar(x) in the completion list? To me, the way the parameter list is grayed out makes it look like informative context, rather than text that will be inserted.

All reactions

Sorry, something went wrong.

Uh oh!

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

amcasey
Andrew Casey (amcasey) approved these changes Apr 11, 2022
View reviewed changes

@amcasey Andrew Casey (amcasey) 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.

Code looks correct. My personal opinion is that it makes the code more readable and the completion item less readable.

Sorry, something went wrong.

Uh oh!

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

All reactions
@gabritto
Gabriela Araujo Britto (gabritto) merged commit dfb9f2f into main Apr 11, 2022
@gabritto
Gabriela Araujo Britto (gabritto) deleted the gabritto/removeTypesObjMethod branch April 11, 2022 18:33
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Apr 11, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

To me, the way the parameter list is grayed out makes it look like informative context, rather than text that will be inserted.

Could we do something crazy where the type annotations are grayed out and the rest of the text is the usual color? I guess we'd need to return display parts (CC Matt Bierner (@mjbvz))

All reactions

Sorry, something went wrong.

Uh oh!

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

@andrewbranch

Andrew Branch (andrewbranch) commented Apr 11, 2022

Copy link
Copy Markdown
Member

That sounds cool, but N.B. I don’t think the LSP spec supports display parts: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemLabelDetails

All reactions

Sorry, something went wrong.

Uh oh!

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

@MariaSolOs

Maria Solano (MariaSolOs) commented Apr 11, 2022

Copy link
Copy Markdown
Contributor

Does anyone else find it confusing seeing both bar and bar(x) in the completion list? To me, the way the parameter list is grayed out makes it look like informative context, rather than text that will be inserted.

(I was invoked to give my 2 cents here) I completely agree with Andrew's comment. Without any context or previous knowledge of this discussion, I would find it quite confusing as a TS user to see these different entries in my completion list, and I would have no idea of which one is which. Although it would be more verbose and make the list uglier, I would prefer options like:

bar(x)
bar(x: number)
All reactions

Sorry, something went wrong.

Uh oh!

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

@amcasey

Andrew Casey (amcasey) commented Apr 11, 2022

Copy link
Copy Markdown
Member

Does anyone else find it confusing seeing both bar and bar(x) in the completion list? To me, the way the parameter list is grayed out makes it look like informative context, rather than text that will be inserted.

(I was invoked to give my 2 cents here) I completely agree with Andrew's comment. Without any context or previous knowledge of this discussion, I would find it quite confusing as a TS user to see these different entries in my completion list, and I would have no idea of which one is which. Although it would be more verbose and make the list uglier, I would prefer options like:

bar(x)
bar(x: number)

Maria Solano (@MariaSolOs) Thanks! One of the things that can be inserted is the bar name (i.e. bar) and the other is a whole method (bar(x) { }). Does that affect how you would like to see them presented?

All reactions

Sorry, something went wrong.

Uh oh!

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

@MariaSolOs

Maria Solano (MariaSolOs) commented Apr 11, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Does anyone else find it confusing seeing both bar and bar(x) in the completion list? To me, the way the parameter list is grayed out makes it look like informative context, rather than text that will be inserted.

(I was invoked to give my 2 cents here) I completely agree with Andrew's comment. Without any context or previous knowledge of this discussion, I would find it quite confusing as a TS user to see these different entries in my completion list, and I would have no idea of which one is which. Although it would be more verbose and make the list uglier, I would prefer options like:

bar(x)
bar(x: number)

Maria Solano (@MariaSolOs) Thanks! One of the things that can be inserted is the bar name (i.e. bar) and the other is a whole method (bar(x) { }). Does that affect how you would like to see them presented?

Ohhhh now I understand. I thought that the different completion options were both for methods (having types in the method signatures versus not). Now I understand.

In that case I again agree with Andrew Casey (@amcasey) about the different color around the parameter list making it seem like an informative label and not part of the snippet. Personally I would also add the curly braces to better represent the snippet's behavior.

All reactions

Sorry, something went wrong.

Uh oh!

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

Jack Works (Jack-Works) pushed a commit to Jack-Works/TypeScript that referenced this pull request Apr 22, 2022
@gabritto @Jack-Works
don't have type annotations on suggested object literal methods (micr…
b2e9645
…osoft#48607)
@magic-akari magic-akari mentioned this pull request Sep 16, 2022
Object literal method completions include ? for optional parameters #50796
Closed
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@andrewbranch Andrew Branch (andrewbranch) andrewbranch approved these changes
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Awaiting requested review from DanielRosenwasser
+1 more reviewer
@amcasey Andrew Casey (amcasey) amcasey approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@gabritto Gabriela Araujo Britto (gabritto)

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Object method snippet completions should not include parameter type annotations

Uh oh!

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

6 participants

@gabritto @DanielRosenwasser @amcasey @andrewbranch @MariaSolOs @typescript-bot
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.