Skip to content

Instantly share code, notes, and snippets.

@willfrew
Last active September 6, 2017 15:53
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 willfrew/d6036d257e3c444305b6ff71ef487c08 to your computer and use it in GitHub Desktop.
Save willfrew/d6036d257e3c444305b6ff71ef487c08 to your computer and use it in GitHub Desktop.
Typescript 2.4.0+ Stack overflow
export interface Foo<T> {
(bar: Bar<T>): void;
}
export interface Bar<T> {
(foo: Foo<T>): Foo<T>;
}
function createBar<T>(): Bar<T> {
return (f) => f;
}
function foo<T>(
bar: Bar<T>,
): void {}
// Operator '===' cannot be applied to types 'Foo<{}>' and 'string'.
createBar()(foo) === '1';
// Operator '===' cannot be applied to types '<T>(bar?: Bar<T>) => void' and 'number'
foo === 1;
// Stack overflow
createBar()(foo) === foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment