refactor: module type and type member refactoring #6103
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This introduces the
TypeData::Modulevariant, which I intend to use fordeclare modulestatements in.d.tsfiles.However, the
Moduletype containsTypeMember, which should now be able to hold arbitrary type definitions. I already feltTypeMemberwas implemented a bit awkwardly, causing some unnecessary duplication, so I've taken the opportunity to refactor it. Now all type members (whether they be object members, class members, or module members) refer to registered types, which can be of any kind ofTypeData.This means we don't make an explicit distinction between properties and methods anymore, the difference is simply whether the reference points to a function or not. Optionality is also no longer an explicit field; it's simply a matter of the referenced type being a union with
undefined.Another side-effect is that our snapshots now make it easier to inspect inferred method signatures, since they've become an explicit part of the registered types.
Test Plan
Tests are updated.