You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two kinds of type, while using the Record, typescript is giving circular reference error. But when I do the same with a dynamic object, no error pops. Why typescript show two completely contrasting behaviours?
The expected output should be error on both or on none.
type ScopeItem =
| string
| {
all: string;
team: string;
};
type ScopesTree = Record<string, ScopeItem | Record<string, ScopesTree>>; // error: Type alias 'ScopesTree' circular references itself
type ScopesTree2 = Record<string, ScopeItem | { [key: string]: ScopesTree2 }>; // no error
Is it something to do with the computation of the typescript type in both the cases? Please enlighten.
Thanks.
The text was updated successfully, but these errors were encountered:
I have two kinds of type, while using the Record, typescript is giving circular reference error. But when I do the same with a dynamic object, no error pops. Why typescript show two completely contrasting behaviours?
The expected output should be error on both or on none.
Is it something to do with the computation of the typescript type in both the cases? Please enlighten.
Thanks.
The text was updated successfully, but these errors were encountered: