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
It would be really nice if certain boolean-returning functions could be inferred to be type predicates. For example, in RxJS one of the signatures for the filter method is
functionfilter<T,SextendsT>(this: Observable<T>,predicate: (value: T,index: number)=>value is S,thisArg?: any): Observable<S>;
It's very useful to filter on an observable and thereby have the resulting observable's type be refined:
however this won't work because the lambda action => action.type === 'FOO' is not inferred to have the type (action: Action) => action is { type: 'FOO'; fooField: number }, even though the compiler should know this is true.
The text was updated successfully, but these errors were encountered:
Duplicate of #5101, #14891. Please see #5101 (comment) for more details. if you do have a proposal in mind on how this can be accomplished for the general case feel free to post it to #5101.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.4.2
It would be really nice if certain boolean-returning functions could be inferred to be type predicates. For example, in RxJS one of the signatures for the
filter
method isIt's very useful to filter on an observable and thereby have the resulting observable's type be refined:
however this won't work because the lambda
action => action.type === 'FOO'
is not inferred to have the type(action: Action) => action is { type: 'FOO'; fooField: number }
, even though the compiler should know this is true.The text was updated successfully, but these errors were encountered: