-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Lazy base types #2813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy base types #2813
Conversation
|
I hope to make similar changes for indexers and return types of call and construct signatures. |
src/compiler/checker.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have ObjectType and ResolvedObjectType. Should we have InterfaceType and ResolvedInterfaceType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do the cast 4 times. Can you just cast once to a local, and then use that from then on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can use a local. The problem with ResolvedInterfaceType is that it implies that the type elements (members, call signatures, etc) are resolved, and that is not in fact the case.
|
👍 |
The spec section 3.9 does not say that interface / class types depend on their base types. And they shouldn't. However, the compiler eagerly resolves the base types of classes and interfaces, so if a class / interface is referenced by a type alias, it might lead to a circular reference error.
The issue can be seen in #1936.
The fix is to make collection of base types lazy, so that base type computation is done on demand when base types are needed.