Skip to content

Instantly share code, notes, and snippets.

@susisu
Last active February 23, 2019 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susisu/a8196dd83ee554c08bc4964c7446b430 to your computer and use it in GitHub Desktop.
Save susisu/a8196dd83ee554c08bc4964c7446b430 to your computer and use it in GitHub Desktop.
const apply = <T, U>(f: (x: T) => U) => (x: T) => f(x);
const foo = <T extends { foo: number }>(x: T) => x.foo;
const foo2 = apply(foo); // : (x: {}) => number;
foo({ foo: 1, bar: 2 }); // OK
foo({}); // error
foo2({ foo: 1, bar: 2 }); // OK
foo2({}); // OK???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment