Closed
Description
Directly show my code, the text description may not be clear.
From the callback function used in the parameters
TypeScript Version: 2.6.2
Code
interface MapType {
a: {
w: number;
h: number;
}
b: {
s: string;
n: boolean;
}
q: {
s: string;
n: boolean;
}
}
type NS<T, P extends keyof T> = {
[U in keyof T[P]]: T[P][U]
}
let n: NS<MapType, 'a' | 'b'>
n.s //Property 's' does not exist on type 'NS<M, "a" | "b">'.
let m: NS<MapType, 'a'>
m.h // (property) h: number
Expected behavior:
let n: NS<MapType, 'a' | 'b'>
n.s // string
n.n // boolean
n.w // number
n.h // number
Actual behavior:
let n: NS<MapType, 'a' | 'b'>
n.s //Property 's' does not exist on type 'NS<M, "a" | "b">'.
Playground Link:
Related Issues:
I think this is very helpful to me,But did not solve my problem.
17930