Closed yogiduzit closed 1 year ago
Type predicates are not automatically inferred. You need to explicitly declare isBird
as returning animal is Bird
.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
This was marked as a duplicate of #10734, which was closed by #57465. But that PR only let "identifier" type predicates flow, not assertion predicates. The example in this issue is still broken.
This specific issue would be fixed by #58495, see playground.
Bug Report
π Search Terms
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The call to
getWingspan
shows an error sayingArgument of type 'Animal' is not assignable to parameter of type 'Bird'
.π Expected behavior
The function
isAnimalOfType
already asserts that the Animal will be of type T. So, why doesisBird
not automatically assert that?