Having this specific shape
const shape = {
foo: () => 'hi',
bar: (arg) => typeof arg === 'string'
// argument is expected to be a string because foo returns a string
}
Is there a way to connect the return type of foo
to the input type of bar
?
I have attempted various versions of conditional types similar to
type Cond<T> = T extends { foo: () => infer A }
? { foo: () => A; bar: (arg: A) => bool }
: never
but so far, no success. Any suggestions?