Typescript: No completions on meta-properties

Created on 11 Apr 2018  路  5Comments  路  Source: microsoft/TypeScript

class C {
  constructor() {
    new./**/
  }
}

Expected: Completion for the target keyword at the /**/ marker.
Actual: No completions.

Bug Completion Lists Fixed good first issue help wanted

Most helpful comment

I'm saying that when you have the text new. in your file and a user requests completions, you should provide the "target" as one of the suggestion items, because the user intends to write new.target.

Also does this /**/ marker have a special meaning should know about

In fourslash tests, we have functionality for emulating the way a user would type code. You type in code preceded by four slashes, and the testing infrastructure interprets that as a file. The testing infrastructure also knows that within those four slashes, /**/ is what's called a "marker comment".

You can then call functions to work with the file, and jump to those markers. For example, here's how I'd write a test for new.target in tests/cases/fourslash/completionsNewTarget.ts

/// <reference path="fourslash.ts" />

////class C {
////    constructor() {
////        if (C === new./**/)
////    }
////}

goTo.marker("");
verify.completionListContains("target");
verify.completionListCount(1);

All 5 comments

Ideally, any work here will make it easy to add completion support for import.meta.

Yayy first issue 馃榾馃榾 with some support I would like to tackle this issue
https://github.com/Microsoft/TypeScript/blob/a004571d3ebb7da6a7d0915465829dee9874e495/src/services/completions.ts#L2113
would this be the right place to edit
@DanielRosenwasser

Hey @Gregjarvez, awesome! I would actually look closer into:

https://github.com/Microsoft/TypeScript/blob/a004571d3ebb7da6a7d0915465829dee9874e495/src/services/completions.ts#L1012

In that function, I'd check if node is a meta-property.

https://github.com/Microsoft/TypeScript/blob/0feefab765214f080e5d8db37bde42830a1c8884/src/compiler/utilities.ts#L5050

Then, if the the meta-property keyword is new, I'd serve up a single completion for the text target.

Tests can be written in tests/cases/fourslash, and you can take inspiration from other completions-related tests.

Pardon me for the questions and many more to come , I am new here

with regards to this statement I'd serve up a single completion for the text target.
what is the text target

Also does this /**/ marker have a special meaning should know about

Thank you :)

I'm saying that when you have the text new. in your file and a user requests completions, you should provide the "target" as one of the suggestion items, because the user intends to write new.target.

Also does this /**/ marker have a special meaning should know about

In fourslash tests, we have functionality for emulating the way a user would type code. You type in code preceded by four slashes, and the testing infrastructure interprets that as a file. The testing infrastructure also knows that within those four slashes, /**/ is what's called a "marker comment".

You can then call functions to work with the file, and jump to those markers. For example, here's how I'd write a test for new.target in tests/cases/fourslash/completionsNewTarget.ts

/// <reference path="fourslash.ts" />

////class C {
////    constructor() {
////        if (C === new./**/)
////    }
////}

goTo.marker("");
verify.completionListContains("target");
verify.completionListCount(1);

Was this page helpful?
0 / 5 - 0 ratings