Closed
Description
TypeScript Version: typescript@3.3.0-dev.20181122
Search Terms:
TS2536 Record Map vuex
Code
interface ITest {
expectedStr: string;
expectedN: number;
}
interface MapAccessor<Getters> {
<T = Getters, Map extends Record<string, keyof T> = Record<string, keyof T>>(
map: Map
): { [K in keyof Map]: (() => T[Map[K]]) };
}
interface TestAccess {
str: "expectedStr";
}
const t: MapAccessor<ITest> = {} as any;
const str = t({
str: "expectedStr"
}).str;
Expected behavior:
No compile issue, is working using typescript@3.0.1, checked the breaking changes and found nothing in regards to this.
Intellisense still works as expected giving error if you change expectedStr
to an invalid value.
Actual behavior:
Not giving error: index.ts:9:33 - error TS2536: Type 'Map[K]' cannot be used to index type 'T'.
Playground Link:
playground