Closed
Description
TypeScript Version: 2.9.2
Search Terms:
Code
With strict mode disabled:
declare function pipe<V0, T1, T2, T3>(
fn0: (x: V0) => T1,
fn1: (x: T1) => T2,
fn2: (x: T2) => T3,
): (x: V0) => T3;
type Option<T> = { t: T }
declare function optionOf<T>(value: T | null | undefined): Option<T>
declare function get(name: "set-cookie"): string[] | undefined;
declare function get(name: string): string | undefined;
// $ExpectType (x: {}) => Option<string>
// but got (x: {}) => Option<{}>
// Note: with strict mode enabled, we get the expected type.
const fn = pipe(
({}: {}) => 'foo',
string => get(string),
// Workaround: pass the function directly, instead of wrapping:
// get,
optionOf,
);
Related Issues:
This is similar to—but not exactly the same as—other issues I've filed when trying to use pipe
: