-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.9.0-dev.20180402
Search Terms: partial mapped types index signature enum
Code
enum Fruits {
Mango = 0,
Banana = 1
}
interface IFruitMetadata<T> {
[Fruits.Mango]: T;
[Fruits.Banana]: T;
}
const onSale1: IFruitMetadata<boolean> = {
[Fruits.Mango]: true,
[Fruits.Banana]: false
};
const onSale2: Partial<IFruitMetadata<boolean>> = {
[Fruits.Banana]: true,
};
const onSale3: Pick<IFruitMetadata<boolean>, Fruits.Banana> = {
[Fruits.Banana]: true,
};
onSale1[Fruits.Banana] = true;
onSale2[Fruits.Mango] = true;
onSale3[Fruits.Banana] = true;Expected behavior:
No compile errors. This was the behavior in 2.7.2.
Actual behavior:
With noImplicitAny=true, the Partial and Pick versions of the type triggers error TS7017: Element implicitly has an 'any' type because type 'Partial<IFruitMetadata>' has no index signature.
Playground Link
#22892 looks like it might be related.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue