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

Provide auto-complete candidates for TypeScript string literal type when double quote is typed #25034

Closed
cnshenj opened this issue Apr 19, 2017 · 6 comments
Assignees
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@cnshenj
Copy link

cnshenj commented Apr 19, 2017

  • VSCode Version: 1.11.2
  • OS Version: Windows 10

Steps to Reproduce:

type Color = "Red" | "Green" | "Blue";
let color: Color = " <-- No auto-complete until I press Ctrl+Space

When I type the double quote, the auto-complete popup should be showed. It should work like when I type the dot after an object name, the auto-complete popup is showed without Ctrl+Space.

@mjbvz mjbvz self-assigned this Apr 19, 2017
@mjbvz mjbvz added feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues labels Apr 20, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 25, 2017

We do also provide intellisense once you start typing a letter. To enable this, make sure to turn on editor.quickSuggestions inside of strings by setting:

"editor.quickSuggestions": {
        "other": true,
        "comments": false,
        "strings": true
    }

As for actually showing the suggestions when you first type ", this is a more difficult problem that I don't think we can solve using the current vscode APIs. We can currently only register a completion trigger character such as . or ", but in cases where you are typing " for a normal string, we do not want to automatically trigger suggestions.

@jrieken Any thoughts on context-aware completion triggering besides just listening to keypresses? #21543 tracks a very similar problem

@jrieken
Copy link
Member

jrieken commented Apr 25, 2017

I don't think context aware triggered can be done in the main side with information from the ext host side. The rule is that IntelliSense gets triggered often and in ways the extension cannot control and therefore the extension is free to return undefined/null when it cannot completion with anything meaningful. Exposing more information to the provider, like the trigger character (which is already in the document anyways), is tracked here: #752

@zackschuster
Copy link

Part of the problem might be how type information is exposed here:

interface Meta {
	color: 'Red' | 'Green' | 'Blue';
}

const meta: Meta = { color: 'Red' };  // property typed as string

type Color = 'Red' | 'Green' | 'Blue';
interface Meta2 {
	color: Color;
}

const meta2: Meta = { color: 'Red' }; // property typed as Color

From my understanding, both of these should be typed as 'Red' | 'Green' | 'Blue' by IntelliSense, yet it seems IS's insight is being limited here.

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 9, 2018

Depends on microsoft/TypeScript#21012

@ghost
Copy link

ghost commented Apr 17, 2018

@zackschuster Looks like that issue may have been fixed in the last year -- in both of those cases color is a string literal union and we give you only those 3 completions inside of either string literal.

@mjbvz mjbvz modified the milestones: Backlog, May 2018 Apr 17, 2018
@zackschuster
Copy link

can confirm, my test case is working as expected. thanks for the heads-up!

@mjbvz mjbvz added the verification-needed Verification of issue is requested label Apr 30, 2018
@mjbvz mjbvz closed this as completed in ffb8d04 Apr 30, 2018
@RMacfarlane RMacfarlane added the verified Verification succeeded label May 29, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants