As a concrete example, if type B was a string
then type A could be anything but a string
I've tried something like
type A = Exclude<any, string>
But the problem is that any
is not an exhaustive list of all possible types. Something like...
const a: A = 'monkey'
... is still valid. But if I did something like:
type C = string | number | boolean | Array<number>
type A = Exclude<C, string>
Then assigning a string to a variable of type A would be invalid.
const a: A = 'monkey' //Invalid, as desired
The problem is defining type C to be all possible types would be practically impossible. I hoped there would maybe be another typescript type that holds all possible types. But can't seem to find anything like that.