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.