You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceDog{woof:string};interfaceCat{meow:string};typeAnimal=Dog|Cat;interfaceHouse<T>{animal: T;}typeDogHouse=House<Dog>;functionProcessDogHouse(house:DogHouse){};consthouse:House<Animal>={animal: undefinedasany};if('woof'inhouse.animal){// We know the type to be House<Dog> but this still errorsProcessDogHouse(house);// Weirdly this doesn't errorProcessDogHouse({animal: house.animal});}
π Actual behavior
Generic types can't be narrowed by checking their child objects.
π Expected behavior
Should be able to narrow a generic object by the types of its children.
The text was updated successfully, but these errors were encountered:
Bug Report
π Search Terms
type guard generic parent object
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Generic types can't be narrowed by checking their child objects.
π Expected behavior
Should be able to narrow a generic object by the types of its children.
The text was updated successfully, but these errors were encountered: