-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
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.
chenzhutian and jcalz
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript