Closed
Description
interface S {
hello: any;
}
interface R {
[i: string]: S | undefined;
}
function f<K extends keyof R>(p: K) {
let r: R = {};
if (r[p]) {
r[p].hello // Error: hello does not exists on type R[K]
}
}
Removing the type undefined
from S | undefined
fixes the error and also the if
check is no longer required.