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
Expected behavior:
The compiler either accepts it (so that new SelfReference() has the type SelfReference<SelfReference<string>>) or rejects it (by explicitly disallowing a circular reference in default type parameters).
Actual behavior:
The compiler goes into an infinite loop that exceeds the recursion limit:
RangeError: Maximum call stack size exceeded
at resolveNameHelper (typescript\lib\typescript.js:26480:35)
at resolveName (typescript\lib\typescript.js:26478:20)
at resolveEntityName (typescript\lib\typescript.js:27128:26)
at getTypeFromTypeReference (typescript\lib\typescript.js:31874:54)
at getTypeFromTypeNode (typescript\lib\typescript.js:32724:28)
at getDefaultFromTypeParameter (typescript\lib\typescript.js:31032:66)
⋮
The text was updated successfully, but these errors were encountered:
Thinking about it more, I'd say the expected behavior is that
classSelfReference<T=SelfReference<string>>{}
should be accepted. Whatever is parsing SelfReference<string> should not care about resolving the default type parameter value, since the type is explicitly given as string.
On the other hand
classSelfReference<T=SelfReference>{}
should probably be rejected, since it seems to require the existence of the infinite type SelfReference<SelfReference<SelfReference<…>>>.
TypeScript Version: 2.3 and up
Code
Expected behavior:
The compiler either accepts it (so that
new SelfReference()
has the typeSelfReference<SelfReference<string>>
) or rejects it (by explicitly disallowing a circular reference in default type parameters).Actual behavior:
The compiler goes into an infinite loop that exceeds the recursion limit:
The text was updated successfully, but these errors were encountered: