Is it possible to have a self-referenced type representation like this?
export type SelfReferenced {
prop: string;
[x: string]: SelfReferenced;
}
It means that all keys will be a reference of this except prop
field
Ex:
const $deep: SelfReference = createProxy();
let lastReference = $deep.a.very.long.nested.deep; //type: SelfReference
lastReference.prop //type: string
Additional requirement is using generic type parameter in prop
:
export type SelfReferenced<T> {
prop: () => T;
[x: string]: SelfReferenced<T>;
}