Closed
Description
Bug
I'm trying to use an object's key to index an intersection into a partial of an object and another object, but I'm getting an error.
Note: this error only shows up in a generic class. Using plain types I was not able to replicate it.
TypeScript Version:
2.7.1-insiders.20180127 (playground)
2.3.1 (visual studio tools)
2.7.2 (command line)
Search Terms:
Keyof, intersection, union, Partial, index, merge.
Code
interface Rum {
"ho hum": string;
}
interface Color {
"blue": number;
}
class Thingy<T> {
mything: Rum & Partial<T>;
log(param: keyof T) {
console.log(this.mything[param]); //ERROR!
}
}
Expected behavior:
No errors.
Actual behavior:
test.ts(13,25): error TS2536: Type 'keyof T' cannot be used to index type 'Rum & Partial'.