In TypeScript, some types are defined using extends keyof or in keyof. I have tried to understand what they mean, but so far I didn't succeed.
What I got is that keyof alone returns a union type which has all the names as possible values that are existent as property names on the type that you specify after keyof.
type T = keyof string;
T therefor is equivalent to startsWith | endsWith | trim | substring | ....
Is this correct?
Now, if I try to think about what extends keyof and in keyof mean, my gut feeling says the following:
extends keyofis any type that derives fromT, i.e. it has all these possible values, but maybe more.in keyofis any type that takes values fromT, but not necessarily all of them (it's possible, but maybe less).
So, from this POV extends keyof would describe a >= relation, in keyof would describe a <= relation. Is this correct? If not, what would be correct?