Skip to content

Intellisense does not work with [P in keyof T] #13701

Open

Description

TypeScript Version: 2.1.5

Code

//Operators available for the object fields
export type Operators<T> = {
    $elementMatch?: T | Operators<T>;
    $in?: T[];
}

//Filter declaration. 
export type Filter<T> = {
    //field, you can assign a value, or an operator.
    [P in keyof T]: Operators<T[P]> | T[P];
}

function query<T>(filter: Filter<T>) {  }

//Sample class
class Sample {
    foo: string;
    bar: number;
}

query<Sample>({
    //We want to put on the "foo" operator "$in"
    value: {
        //Intellisense then no output
    }
});

Expected behavior:
Intellisense should display all available options.
For example:
$elementMatch
$in

Actual behavior:
Intellisense does not offer anything.
If the "[P in key of T]" is replaced by "[key: string]", then the Intellisense for operators begins to work, but in this case we lose the test fields.

Activity

  1. changed the title [-]Intellisense does not work with [P in key of T][/-] [+]Intellisense does not work with [P in keyof T][/+] on Jan 26, 2017
  2. added
    Needs Investigation
    on May 24, 2017
  3. added
    Experience Enhancement
    Suggestion
    and removed
    Needs Investigation
    on Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Experience EnhancementSuggestion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions