-
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
Description
TypeScript Version:
nightly (1.9.0-dev.20160323)
Code
let numbers: number[] =
[1, '2', 3, '4'].filter(x => typeof x !== 'string');
declare function isNumber(arg: any): arg is number;
let numbers2: number[] = [1, '2', 3, '4'].filter(isNumber);
Expected behavior:
.filter with a type guard returns an array of the specified type. This would be especially useful with --strictNullChecks
, so we could do something like foo.map(maybeReturnsNull).filter(x => x != null)....
Actual behavior:
.filter returns an array of the same type, and the two let
s above are errors.
bcherny, michaelmesser, PanayotCankov, shrfarzk, OliverJAsh and 32 more
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