8000 feat(core): add `ModuleId` to `ResolvedTypeId` by arendjr · Pull Request #5809 · biomejs/biome · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(core): add ModuleId to ResolvedTypeId #5809

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

Merged
merged 2 commits into from
Apr 29, 2025

Conversation

arendjr
Copy link
Contributor
@arendjr arendjr commented Apr 29, 2025

Summary

I'm trying to avoid another huge PR, so I'm taking some smaller steps here :)

The main change in this PR is that ResolvedTypeId can now contain a ModuleId in addition to a TypeId. Such a ModuleId would only be used in combination with TypeResolverLevel::Module, but with a catch: The types stored in the module graph would not contain these module IDs, because it brings all kinds of complexity if a module needs to know its own ID. So the idea for now is that the AdHocTypeResolver will attach these module IDs at resolution time in order to keep track of which modules given types came from. I'm not yet sure it will be as easy as this, but that's the direction I'm going in.

Other changes are:

  • JsResolvedPath and JsImportSymbol have been moved from biome_module_graph to biome_js_type_info. This allows us to store the information from where to resolve a given type reference directly into TypeReference itself. The JsModuleInfoCollector now converts ResolvedTypeIds of TypeResolverLevel::Project into such TypeReference::Imported variants.
  • To make the above possible, we need to interpret the type ID stored in a ResolvedTypeId with TypeResolverLevel::Project as binding ID. It feels a little bit hacky, but it still feels better than introducing another TypeData variant for such a temporary purpose, because then it would leak into the rest of the type system.
  • Because of this, biome_module_graph now has its own BindingId instead of using the BindingId from biome_js_semantic. This BindingId has a From<TypeId> implementation, and vice versa.
  • I cleaned up a little bit of info we were tracking in the semantic data inside biome_module_graph that we weren't actually using.

Test Plan

CI should remain green.

@arendjr arendjr requested review from a team April 29, 2025 10:33
@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Apr 29, 2025
@arendjr arendjr moved this to In review in Type Inference Apr 29, 2025
Copy link
codspeed-hq bot commented Apr 29, 2025

CodSpeed Performance Report

Merging #5809 will not alter performance

Comparing arendjr:add-module-ids (130273a) with main (107d632)

Summary

✅ 95 untouched benchmarks

Copy link
Member
@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left some comments but feel free to merge it whenever

/// Only the two least significant bits may be set in order to let the type
/// fit into `ResolvedTypeId`. If more bits become necessary, we may need to
/// rebalance the layout of `ResolvedTypeId`.
pub const fn from_u2(bits: u32) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_u32

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually named it like that on purpose, to make people conscious of the size restraint, even if we don't have a real u2 type :)

@arendjr arendjr merged commit 1af2395 into biomejs:main Apr 29, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Type Inference Apr 29, 2025
@arendjr arendjr deleted the add-module-ids branch April 30, 2025 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants
0