-
Couldn't load subscription status.
- Fork 13.1k
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 instanceofor 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 objectmartaver, 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