-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Infer Type Guard Return Values #5101
Copy link
Copy link
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
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
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 aboolean.This change would allow the following code to work: