Closed
Description
TypeScript Version: 2.9.1
Search Terms:
keyof,optional
Code
export type Map<T = {}> = {
readonly [P in Extract<keyof T, string>]: A<P>;
};
export interface A<TNameType extends string = string> {
test: string;
}
export interface B {
required: string;
optional?: string;
}
export const Test: Map<B> = {
required: 'required',
}
Expected behavior:
No errors should be reported, because an optional property should not be required as a result of keyof
.
Actual behavior:
Type '{ required: string; }' is not assignable to type 'Map<B>'.
Property 'optional' is missing in type '{ required: string; }'.
It was working in 2.8.3, without Extract<>
Playground Link:
Playground Link
Related Issues: