Skip to content

Fixed auto completion after a < token to return types not values.#32382

Merged
DanielRosenwasser merged 1 commit into
microsoft:masterfrom
dragomirtitian:GH-29769-generic-auto-completion-missing-primitives
Jul 15, 2019
Merged

Fixed auto completion after a < token to return types not values.#32382
DanielRosenwasser merged 1 commit into
microsoft:masterfrom
dragomirtitian:GH-29769-generic-auto-completion-missing-primitives

Conversation

@dragomirtitian
Copy link
Copy Markdown
Contributor

Fixes #29769

Right now immediately after the < token the suggestions do not include types. This PR changes isContextTokenTypeLocation to recognize that if the < token is encountered inside a TypeReference, types should be suggested.

Interestingly there is a test that specifically tested that values are included in the suggestions for a type reference. I can't think of a case where this would be valid. This change removes values from completions here. I would say this is an improvement but I am unsure what the original intent was.

const something: C<{| "valueOnly": false |}; // failed here, because of  missing values
const something2: C<C<{| "valueOnly": false |}; // failed here, because of  missing values

@andrewbranch
Copy link
Copy Markdown
Member

This has been on my personal list of annoyances for quite some time—I’m incredibly excited to test this out!

@andrewbranch andrewbranch self-assigned this Jul 12, 2019
for (const marker of test.markers()) {
if (marker.data && marker.data.valueOnly) {
if (marker.data && marker.data.typeOnly) {
verify.completions({ marker, includes: "T", excludes: "x" });
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry for the noob question: does "T" and "x" stand for "Type" and "Value" respectively? I'm trying to understand a little bit of the code by checking some PR's (yours is pretty cool!)

Copy link
Copy Markdown
Contributor Author

@dragomirtitian dragomirtitian Jul 15, 2019

Choose a reason for hiding this comment

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

@diguifi They do not intrinsically stand for type and value. In this test they are used as stand-ins for type and value, but only because they are defined as such above:

////const x = 0;
////type T = number;

@DanielRosenwasser DanielRosenwasser merged commit c7b8b2a into microsoft:master Jul 15, 2019
@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.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic auto-completion missing primitive types

5 participants