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
typeFoo={kind: 'foo'}interfaceBar<T=Any>{kind: 'bar',value: T}typeBaz={kind: 'baz'}typeAny=Foo|Bar|BazfunctionisFoobar(value: unknown): value is Foo|Bar<Foo>{returntypeofvalue==='object'&&((valueasany)?.kind==='foo'||(valueasany)?.kind==='bar')}letvalue={kind: 'baz'}asAnyif(isFoobar(value)){leta=value.kind==='foo'
? value.kind
: value.value.kind}
π Actual behavior & π Expected behavior
isFoobar narrows the type to only Foo but should narrow it to the specified Foo | Bar<Foo>. It seems to be related to the combination of the generic parameter and the circularity because I can not find a way to simplify it further.
The text was updated successfully, but these errors were encountered:
Bug Report
π Search Terms
union type, type predicate
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior & π Expected behavior
isFoobar
narrows the type to onlyFoo
but should narrow it to the specifiedFoo | Bar<Foo>
. It seems to be related to the combination of the generic parameter and the circularity because I can not find a way to simplify it further.The text was updated successfully, but these errors were encountered: