-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
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
martaver, gkalpak, lacolaco, jscheiny, topaxi and 3 moretopaxi
Metadata
Metadata
Assignees
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript