TypeScript Version: 2.6.2
Code
typeRect={width: number|undefined;}classHasARect<TextendsRect>{rect: T;get<KextendskeyofT>(prop: K): T[K]{returnthis.rect[prop];}getWidth(r: T): number{returnthis.get("width")||0;// Type 'undefined' is not assignable to type 'number'.}}Expected behavior:
This is not a type error.
Actual behavior:
Type 'T["width"]' is not assignable to type 'number'.
Type 'number | undefined' is not assignable to type 'number'.
Type 'undefined' is not assignable to type 'number'.
TypeScript Version: 2.6.2
Code
Expected behavior:
This is not a type error.
Actual behavior: