d45e422b46
typeMaybeAssignableTo. typeMaybeAssignableTo decomposed unions at the top level of the assigned type but didn't properly handle other unions that arose during assignability checking, e.g., in the constraint of a generic lookup type. Fixes #26130.
11 lines
282 B
TypeScript
11 lines
282 B
TypeScript
// Repro from #26130
|
|
|
|
let mappedObject: {[K in "foo"]: null | {x: string}} = {foo: {x: "hello"}};
|
|
declare function foo<T>(x: T): null | T;
|
|
|
|
function bar<K extends "foo">(key: K) {
|
|
const element = foo(mappedObject[key]);
|
|
if (element == null)
|
|
return;
|
|
const x = element.x;
|
|
}
|