this correctly type checks and has identical behavior:
let x = 10;
const obj = ((function Y<B>(a:(_:() => B) => () => B): () => B {
function Y1(b: typeof Y2): () => B {
return b(b);
}
function Y2(c: typeof Y2): () => B {
return a(() => c(c)());
}
return Y1(Y2);
})((rec: () => {}) => function() {
if(--x) return rec();
return {};
}))();