Skip to content

Instantly share code, notes, and snippets.

@overminder
Last active April 26, 2016 00:13
Show Gist options
  • Save overminder/b4ea8f38eb46aaa2a9c3d4ce915cb505 to your computer and use it in GitHub Desktop.
Save overminder/b4ea8f38eb46aaa2a9c3d4ce915cb505 to your computer and use it in GitHub Desktop.

TypeScript --noImplicitAny is not enough!

function makeConsumer<A>(): (a: A) => void {
return (a: A) => console.log(a);
}
function dealWithTwoThings<A, B>(a: A, b: B) {
// This function compiles under 1.8.9 since tsc infers `consumer` to be `(a: {}) => void`.
// I feel that it should be an error as I obviously forgot to write the type parameter for
// the invocation of `makeConsumer` here.
const consumer = makeConsumer();
consumer(a);
consumer(b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment