I have a function that nests objects based on the length of an input array. E.g.:
fn(['a']) -> Record<string, string>
fn(['a', 'b']) -> Record<Record<string, string>>
I'm defining the return type as:
type Ret = {
[k: string]: string | Ret;
}
However, this doesn't know the depth of the object. If the input as a TS tuple, then in theory it should be possible to know the depth of the return type. Is this currently possible?
Rettype would need a "depth" parameter that is reduced. So you'd haveRet<0> = stringandRet<n> = {[k: string]: Ret<n-1>}, obviously this syntax is made up. Maybe this article, or this one may help giving you some ideas