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
This is working as intended. We infer the more specific Statement type for TIn because it satisfies both occurrences of TIn (the co-variant occurrence in the first parameter and the contra-variant occurrence in the second parameter), and we infer ClassLike for TOut based on the return type of isClassLike. TOut then fails its extends TIn constraint check because ClassLike doesn't extend Statement, so we default to the constraint, Statement. You need an extra type parameter to make this all work out:
Bug Report
π Search Terms
strictFunctionTypes inferred type parameter too narrow branded types
π Version & Regression Information
β― Playground Link
Playground Link
π» Code
This is basically what I see in the TS repo.
π Actual behavior
The second type parameter to
tryCast
is inferred to beStatement
, which is too narrow.π Expected behavior
The inferred type should be
Node
. This helper is used in the TS repo, but can't be used in some conditions because inference is wrong.The text was updated successfully, but these errors were encountered: