Closed
Description
If a function returns a type guard, either the result of an instanceof
or the return value of another type guard function, it could be inferred as being a type guard itself. However, it is simply inferred as a boolean
.
This change would allow the following code to work:
// The interface below should probably be merged into lib.d.ts and friends.
interface Array<T> {
filter<O extends T>(callbackfn: (value: T, index: number, array: T[]) => value is O, thisArg?: any): O[];
}
declare class Foo { bar: number }
declare var blah: Object[];
blah.filter(object => object instanceof Foo)[0].bar // Property bar does not exist on type object