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
{{ message }}
Repository navigation
given x : T, bool should be a subtype of x is T #19557
If x : T is already known, any bool implies/is evidence for x is T.
This should help type inference for e.g.
function f<T, R extends T>(x: T[], p: (x: T) => x is R): R | undefined {
for (const v of x) {
if(p(v)){return v}
}
}
// doesn't work
f([2,3,4], (x) => x > 3)
// works
f([2,3,4], (x): x is number => x > 3)
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
[-]given `x : T`, `bool` should be a subtype of `x is T`[/-][+]given x : T, bool should be a subtype of x is T[/+]aluanhaddad commentedon Oct 30, 2017
This looks like a duplicate of #10734typescript-bot commentedon Nov 14, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.