I am generating TypeScript code that contains errors. In order to generate the right code, I need to understand what is going on in the following examples:
What is the reason that the following code snippet results in a 'circular reference' error:
type Dict<T> = { [key:string]: T }
export namespace X {
export type A<T> =
| ['em', X.B<T>] //<-- error on this line
export type B<T> = Dict<X.A<T>> //<-- and error on this line
}
but if I remove the reference to the namespace, there's no problem:
type Dict<T> = { [key:string]: T }
export namespace Y {
export type A<T> =
| ['em', B<T>] //<----
export type B<T> = Dict<X.A<T>>
}
and also if I remove the type parameter there is no issue:
type Dict<T> = { [key:string]: T }
export namespace Z {
export type A =
| ['em', Z.B]
export type B = Dict<Z.A>
}