Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved hints/autocomplete for union literal types #45269

Closed
alisd23 opened this issue Mar 8, 2018 · 1 comment
Closed

Improved hints/autocomplete for union literal types #45269

alisd23 opened this issue Mar 8, 2018 · 1 comment
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) javascript JavaScript support issues

Comments

@alisd23
Copy link

alisd23 commented Mar 8, 2018

Currently, the hints for union literal type parameters is OK, but it could be better.
Given this example union string literal type (taken directly from the typescript docs: https://basarat.gitbooks.io/typescript/docs/types/literal-types.html):

type CardinalDirection = 'North' | 'East' | 'South' | 'West';

function move(distance: number, direction: CardinalDirection) {
    // ...
}

Note
For the following, I'm not sure about the terminology you guys use for the hints, but when I say hints I mean the list that displays after pressing . after objects/class instances, which can be navigated with keyboard controls and selected by clicking or pressing enter.

It would be nice to display this selectable list of possible values for the direction parameter at the point of typing move(1, ':cursor:'). Currently this does kind of work, where the hint list shows only after pressing a trigger character like ., which is kind of hacky and probably hard to notice unless it is explicitly explained to the user.

I know that some libraries utilize union literal string types for their API's (with much bigger sets of possible string literals), so it would great to display possible literal values for these.

The most recent example I have seen is for the end-to-end testing library Cypress.

Thanks

Edit
I guess this would also apply to boolean and number literals, and mixtures of these (which may be more of a stretch).

@mjbvz mjbvz self-assigned this Mar 8, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Mar 8, 2018

Duplicate of #25034

You can also trigger suggestions manually after the ' by pressing ctrl+space

@mjbvz mjbvz closed this as completed Mar 8, 2018
@mjbvz mjbvz added javascript JavaScript support issues *duplicate Issue identified as a duplicate of another issue(s) labels Mar 8, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

2 participants