}); // $ExpectError string. This type is incompatible with number timesNums = times(5, function(i: number) { return JSON.stringify(i); }); // lodash.flatMap for collections and objects // this arrow function needs a type annotation due to a bug in flow // https://github.com/facebook/flow/issues/1948 flatMap([1, 2, 3], (n): number[] => [n, n]); flatMap({ a: 1, b: 2 }, n => [n, n]); /** * _.noop */ noop(); noop(1); noop("a", 2, [], null); (noop: string => void); (noop: (number, string) => void); // $ExpectError functions are contravariant in return types (noop: string => string); /** * _.memoize */ var memoized: (a: number) => string = memoize((a: number) => "foo"); // $ExpectError memoize retains type information memoized = memoize(() => {}); /**
string = defaultTo('str', true); num = tap(1, function(n) { return false; }); bool = thru(1, function(n) { return false; }); var timesNums: number[]; timesNums = times(5); // $ExpectError string. This type is incompatible with number var strings : string[] = times(5); timesNums = times(5, function(i: number) { return i + 1; }); // $ExpectError string. This type is incompatible with number timesNums = times(5, function(i: number) { return JSON.stringify(i); }); // lodash.flatMap for collections and objects // this arrow function needs a type annotation due to a bug in flow // https://github.com/facebook/flow/issues/1948 flatMap([1, 2, 3], (n): number[] => [n, n]); flatMap({a: 1, b: 2}, n => [n, n]); /** * _.noop */ noop(); noop(1); noop('a', 2, [], null); (noop: (string) => void); (noop: (number, string) => void); // $ExpectError functions are contravariant in return types (noop: (string) => string);