Skip to content

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

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

Conversation

dragomirtitian
Copy link
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
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
@@ -20,7 +20,10 @@
////new callAndConstruct<callAndConstruct</*callAndConstruct*/

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

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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic auto-completion missing primitive types
5 participants