Repository navigation
refactor(inference): prepare legacy type removal - #11010
Conversation
|
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
f0a66ee to
01b08c4
Compare
6c15711 to
47f9cb8
Compare
47f9cb8 to
d96d6dd
Compare
01b08c4 to
d4f501a
Compare
WalkthroughThe PR migrates JavaScript and module-graph type inference from resolver-owned representations to raw types and Salsa-backed inferred types. It removes legacy resolver APIs, updates global and local type storage, adds inferred module and namespace members, and narrows public exports. It also adds extensive tests for calls, expressions, promises, generics, module resolution, cycles, CSS, HTML, invalidation, and query selection. Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: π₯ Pre-merge checks | β 4β Passed checks (4 passed)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
π€ Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/biome_module_graph/src/db/type_inference/resolver.rs`:
- Around line 205-280: Update with_namespace_members to collect members from
each relevant TsModuleDeclaration using
SemanticModel::scope(declaration.syntax()).bindings(), rather than filtering
all_bindings by Binding::scope(). Ensure sibling module declarations remain
isolated and aggregate members across all merged namespace declarations instead
of stopping at the first match. Add regression tests covering sibling modules
and merged namespaces.
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 39515778-b36d-40bb-b08d-387917c6227a
π Files selected for processing (1)
crates/biome_module_graph/src/db/type_inference/resolver.rs
d4f501a to
0aee9ad
Compare
Merging this PR will regress 6 benchmarks
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance ChangesTip Investigate this regression by commenting Comparing Footnotes
|
There was a problem hiding this comment.
Actionable comments posted: 5
π§Ή Nitpick comments (7)
crates/biome_module_graph/src/js_module_info/collector.rs (2)
885-887: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueThe limit diagnostic depends on
diagnosticsbeing otherwise empty.
JsModuleInfoDiagnostichas one variant today, so this works. If a second diagnostic kind arrives, the first unrelated diagnostic suppresses the limit report. Check for the variant instead of emptiness.β»οΈ Suggested change
- if diagnostics.is_empty() { + if !diagnostics + .iter() + .any(|diagnostic| matches!(diagnostic, JsModuleInfoDiagnostic::ExceededTypesLimit(_))) + { diagnostics.push(JsModuleInfoDiagnostic::exceeded_types_limit()); }π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/src/js_module_info/collector.rs` around lines 885 - 887, Update the diagnostic insertion logic in the surrounding collector method so it checks whether diagnostics already contains the exceeded-types-limit variant, rather than whether diagnostics is empty. Add JsModuleInfoDiagnostic::exceeded_types_limit() only when that specific diagnostic is absent, preserving unrelated diagnostics.
694-704: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueUpdate the raw-reference rationale. Describe the current
TypeStoreandTypeReference::Resolved(RawTypeId::Local(...))handling instead of referencingas_raw_data()andapply_module_id_to_reference().π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/src/js_module_info/collector.rs` around lines 694 - 704, Update the explanatory comment above the TypeReference::Resolved(RawTypeId::Local(resolved_member)) match to describe the current TypeStore-based raw-reference handling and why local resolved references are safe to use during collection. Remove the outdated references to as_raw_data() and apply_module_id_to_reference().crates/biome_js_type_info/src/globals_ids.rs (1)
70-72: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueUpdate the macro documentation, because roles are no longer expanded.
The doc comment still claims the macro expands roles. The
$rolecolumn is now only matched and then discarded. Either state that the column is reserved, or drop it from the matchers and the 65 manifest rows.β»οΈ Documentation-only adjustment
-/// Expands the manifest into IDs, names, roles, required raw aliases, and the name lookup. +/// Expands the manifest into IDs, names, optional raw aliases, and the name lookup. +/// The `role` column is parsed but not expanded. macro_rules! predefined_globals {π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_js_type_info/src/globals_ids.rs` around lines 70 - 72, Update the documentation for the predefined_globals macro to no longer claim that roles are expanded, since the $role column is matched and discarded. Either describe the column as reserved or remove it from the macro matcher and all manifest rows, preserving the existing generated IDs, names, aliases, and lookup behavior.crates/biome_js_type_info/src/local_inference.rs (2)
1674-1684: π Performance & Scalability | π΅ Trivial | β‘ Quick winAvoid the extra
TypeDataclone on every function parameter.
ty_datais cloned in both branches. It is needed again only at Line 1697, and only when the binding has no name. In the named case the clone is pure overhead, andTypeDatacan carry boxed member and parameter lists. This code runs for every parameter of every function in the file.Register the reference from a borrow instead, and keep
ty_dataintact.β»οΈ Suggested change
// Optional parameters can be called without a value, so include `undefined` in the type let ty = if is_optional { - let ty_ref = collector.reference_to_owned_data(ty_data.clone()); - RawTypeId::Local(collector.optional(ty_ref)).into() + let ty_ref = collector.reference_to_registered_data(&ty_data); + let optional_id = collector.optional(ty_ref); + collector.reference_to_id(optional_id) } else { - collector.reference_to_owned_data(ty_data.clone()) + collector.reference_to_registered_data(&ty_data) };π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_js_type_info/src/local_inference.rs` around lines 1674 - 1684, Update the parameter type construction around ty_data to avoid cloning TypeData in either branch: register the collector reference from a borrow while preserving ty_data for the later unnamed-binding path near line 1697. Keep the optional-parameter undefined wrapping behavior unchanged and ensure the named-parameter path does not perform an unnecessary clone.
2294-2294: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueBuild optional references through
reference_to_idinstead of constructingRawTypeId::Localinline. Three sites hard-codeRawTypeId::Local(collector.optional(ty)), while Lines 2385-2386 use the trait methodreference_to_idfor the same operation. The shared root cause is that these sites bypass theRawTypeCollectorabstraction, so an implementor that overrides reference construction is ignored in three places and honoured in one.
crates/biome_js_type_info/src/local_inference.rs#L2294-L2294: replaceRawTypeId::Local(collector.optional(ty)).into()withcollector.optional(ty)followed bycollector.reference_to_id(id).crates/biome_js_type_info/src/local_inference.rs#L2408-L2408: apply the same replacement infrom_name_and_optional_type.crates/biome_js_type_info/src/local_inference.rs#L1681-L1681: apply the same replacement infrom_binding_with_annotation; the diff in the comment on Lines 1674-1684 already does this.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_js_type_info/src/local_inference.rs` at line 2294, Update crates/biome_js_type_info/src/local_inference.rs at lines 2294, 2408, and 1681 to construct optional references through RawTypeCollector::reference_to_id: obtain the optional type with collector.optional(ty), then pass that ID to collector.reference_to_id instead of constructing RawTypeId::Local inline. Apply this in the surrounding optional-type logic, including from_name_and_optional_type and from_binding_with_annotation.crates/biome_js_type_info/src/type_store.rs (2)
173-195: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueRemove the duplicate and simplify
UnionCollector.
type_store::UnionCollectoris used bybiome_module_graph. Remove the unused duplicate inresolver.rs. Consider returningTypeDatafromfinish; it always returnsCow::Owned.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_js_type_info/src/type_store.rs` around lines 173 - 195, Remove the duplicate UnionCollector definition from resolver.rs and use type_store::UnionCollector in biome_module_graph. Simplify UnionCollector::finish to return TypeData directly, preserving the unknown result for empty collections and the union result otherwise, and update its callers to match.
14-30: ποΈ Data Integrity & Integration | π΅ Trivial | β‘ Quick winDeduplicate equal entries in
TypeStore::from_types.insert_uniquedoes not check equality, so repeated values create multiple lookup entries andfindhas no canonical index. This conflicts with βdeduplicated insertionβ. Guard insertion withtable.find(...), or document thatfrom_typespreserves duplicate positional entries. The global store uses positionalget_by_id, notfind.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_js_type_info/src/type_store.rs` around lines 14 - 30, Update TypeStore::from_types to check table.find for an existing equal TypeData before inserting each index, ensuring repeated values map to one canonical lookup entry while preserving the original types vector and positional get_by_id behavior.
π€ Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/biome_js_type_info/Cargo.toml`:
- Around line 14-18: Update the Cargo package configuration around autotests and
the local_inference [[test]] target: document above autotests = false that every
integration test must be registered manually, then add [[test]] entries for
conditionals, flattening, resolver, and type_data using their corresponding
tests/*.rs paths.
In `@crates/biome_js_type_info/src/globals_ids.rs`:
- Around line 13-14: Add the required salsa::Update implementation to TypeId, or
annotate the TypeId field in GlobalTypeId with #[update(fallback)] so the
existing salsa::Update derive compiles. Preserve GlobalTypeIdβs current wrapper
and derives.
In `@crates/biome_js_type_info/src/type_data.rs`:
- Around line 54-63: Update RawTypeId::new and the affected module_resolver call
sites so Import and Full resolver levels are represented without panicking,
preserving correct ResolvedTypeId behavior. Adjust the representation or
construction path consistently, then add regression coverage for namespace
imports and module-0 mapping.
In `@crates/biome_module_graph/src/db/queries/css.rs`:
- Line 19: Add regression tests for the query behavior changes around the
tracked query declaration and the traversal logic in the affected
importer/parent-node query paths. Verify stable importer and parent-node
outputs, duplicate handling, and traversal order; also add Salsa
reuse/selectivity coverage showing unrelated edits reuse results while
dependency edits recompute them.
In `@crates/biome_module_graph/src/js_module_info/collector.rs`:
- Around line 383-401: Prevent dangling JsOwnExport::Type IDs by updating the
FinalisedModuleTypes construction in
crates/biome_module_graph/src/js_module_info/collector.rs lines 383-401 to skip
type-based export collection when inference_mode is TypeInferenceMode::Disabled,
or retain the raw_types entries referenced by those exports; additionally, in
crates/biome_module_graph/src/db/type_inference/imports.rs line 677, add the
js_info.infer_types guard before reading js_info.exports, matching
collect_namespace_names_in_module.
---
Nitpick comments:
In `@crates/biome_js_type_info/src/globals_ids.rs`:
- Around line 70-72: Update the documentation for the predefined_globals macro
to no longer claim that roles are expanded, since the $role column is matched
and discarded. Either describe the column as reserved or remove it from the
macro matcher and all manifest rows, preserving the existing generated IDs,
names, aliases, and lookup behavior.
In `@crates/biome_js_type_info/src/local_inference.rs`:
- Around line 1674-1684: Update the parameter type construction around ty_data
to avoid cloning TypeData in either branch: register the collector reference
from a borrow while preserving ty_data for the later unnamed-binding path near
line 1697. Keep the optional-parameter undefined wrapping behavior unchanged and
ensure the named-parameter path does not perform an unnecessary clone.
- Line 2294: Update crates/biome_js_type_info/src/local_inference.rs at lines
2294, 2408, and 1681 to construct optional references through
RawTypeCollector::reference_to_id: obtain the optional type with
collector.optional(ty), then pass that ID to collector.reference_to_id instead
of constructing RawTypeId::Local inline. Apply this in the surrounding
optional-type logic, including from_name_and_optional_type and
from_binding_with_annotation.
In `@crates/biome_js_type_info/src/type_store.rs`:
- Around line 173-195: Remove the duplicate UnionCollector definition from
resolver.rs and use type_store::UnionCollector in biome_module_graph. Simplify
UnionCollector::finish to return TypeData directly, preserving the unknown
result for empty collections and the union result otherwise, and update its
callers to match.
- Around line 14-30: Update TypeStore::from_types to check table.find for an
existing equal TypeData before inserting each index, ensuring repeated values
map to one canonical lookup entry while preserving the original types vector and
positional get_by_id behavior.
In `@crates/biome_module_graph/src/js_module_info/collector.rs`:
- Around line 885-887: Update the diagnostic insertion logic in the surrounding
collector method so it checks whether diagnostics already contains the
exceeded-types-limit variant, rather than whether diagnostics is empty. Add
JsModuleInfoDiagnostic::exceeded_types_limit() only when that specific
diagnostic is absent, preserving unrelated diagnostics.
- Around line 694-704: Update the explanatory comment above the
TypeReference::Resolved(RawTypeId::Local(resolved_member)) match to describe the
current TypeStore-based raw-reference handling and why local resolved references
are safe to use during collection. Remove the outdated references to
as_raw_data() and apply_module_id_to_reference().
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 67ab2241-08c5-4348-8644-faff7f6c7a84
β Files ignored due to path filters (11)
Cargo.lockis excluded by!**/*.lockand included by**crates/biome_js_analyze/tests/specs/nursery/useAwaitThenable/thenableInvalid.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useAwaitThenable/thenableValid.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_array.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_async_function.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_binary_expression_eq.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_binary_expression_ne.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_destructured_array_element.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_function_with_destructured_arguments.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_literal.snapis excluded by!**/*.snapand included by**crates/biome_js_type_info/tests/snapshots/infer_type_of_promise_returning_function.snapis excluded by!**/*.snapand included by**
π Files selected for processing (37)
crates/biome_js_analyze/tests/specs/nursery/useAwaitThenable/thenableValid.tscrates/biome_js_type_info/CONTRIBUTING.mdcrates/biome_js_type_info/Cargo.tomlcrates/biome_js_type_info/src/format_inferred_type_info.rscrates/biome_js_type_info/src/format_type_info.rscrates/biome_js_type_info/src/globals.rscrates/biome_js_type_info/src/globals_builder.rscrates/biome_js_type_info/src/globals_ids.rscrates/biome_js_type_info/src/interned_types.rscrates/biome_js_type_info/src/lib.rscrates/biome_js_type_info/src/local_inference.rscrates/biome_js_type_info/src/type_data.rscrates/biome_js_type_info/src/type_data/literal.rscrates/biome_js_type_info/src/type_store.rscrates/biome_js_type_info/tests/local_inference.rscrates/biome_js_type_info/tests/utils.rscrates/biome_module_graph/Cargo.tomlcrates/biome_module_graph/src/db/mod.rscrates/biome_module_graph/src/db/queries/css.rscrates/biome_module_graph/src/db/type_inference/imports.rscrates/biome_module_graph/src/db/type_inference/promise_classification.rscrates/biome_module_graph/src/db/type_inference/resolver.rscrates/biome_module_graph/src/format_module_graph.rscrates/biome_module_graph/src/js_module_info.rscrates/biome_module_graph/src/js_module_info/binding.rscrates/biome_module_graph/src/js_module_info/collector.rscrates/biome_module_graph/src/js_module_info/diagnostics.rscrates/biome_module_graph/src/js_module_info/utils.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/src/type_inference/context.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/tests/spec_tests_v2.rscrates/biome_module_graph/tests/spec_tests_v2/expected_argument_inference.test.rscrates/biome_module_graph/tests/spec_tests_v2/globals.test.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_test_utils/src/lib.rscrates/biome_workspace_db/src/lib.rs
π€ Files with no reviewable changes (2)
- crates/biome_module_graph/src/js_module_info/utils.rs
- crates/biome_js_analyze/tests/specs/nursery/useAwaitThenable/thenableValid.ts
π§ Files skipped from review as they are similar to previous changes (1)
- crates/biome_module_graph/src/db/type_inference/resolver.rs
There was a problem hiding this comment.
π§Ή Nitpick comments (10)
crates/biome_module_graph/src/db/type_inference/qualifiers.rs (1)
248-257: π Maintainability & Code Quality | π΅ Trivial | β‘ Quick winAdd regression coverage for global type qualifiers. Add tests for
Symbol.disposeandSymbol.asyncDispose, plus a multi-member global type qualifier that exercises sequential traversal. The existingglobalThis.Promisetest covers an expression chain, notTypeReferenceQualifier.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/src/db/type_inference/qualifiers.rs` around lines 248 - 257, Add regression tests for TypeReferenceQualifier covering Symbol.dispose and Symbol.asyncDispose, plus a multi-member global type qualifier that verifies sequential traversal. Place the coverage alongside the existing globalThis.Promise test, ensuring the new cases exercise type qualifiers rather than expression-chain resolution.Source: Coding guidelines
crates/biome_module_graph/tests/spec_tests/module_resolution.test.rs (2)
72-80: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueRemove the stray fixture path.
project()never inserts/src/components/Hello.tsxinto the filesystem, and this test only asserts on/src/index.ts. The extra path looks like a leftover from the path-alias test and can confuse the next reader.β»οΈ Proposed cleanup
let db = build_js_db( &fs, &layout, - &[ - BiomePath::new("/src/index.ts"), - BiomePath::new("/src/components/Hello.tsx"), - ], + &[BiomePath::new("/src/index.ts")], true, );π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests/module_resolution.test.rs` around lines 72 - 80, Remove the unused /src/components/Hello.tsx entry from the file list passed to build_js_db in the affected test, leaving only /src/index.ts while preserving the existing project setup and assertions.
30-42: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueUse the imported helper name.
Line 1 imports
deserialize_from_json_str, and line 135 uses it. These two call sites still spell outbiome_deserialize::json::deserialize_from_json_str. Please make them consistent.Also applies to: 216-224
π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests/module_resolution.test.rs` around lines 30 - 42, Update the manifest deserialization call sites in the test setup and the corresponding location around the second noted block to use the imported deserialize_from_json_str helper directly instead of the fully qualified biome_deserialize::json::deserialize_from_json_str path, keeping behavior unchanged.crates/biome_module_graph/tests/spec_tests/requests.test.rs (1)
26-41: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueThe lookup depends on map iteration order.
raw_expressions.keys().find(...)returns the first key in iteration order. If two expressions in a fixture ever trim to the same snippet, the selected range becomes unstable. The current fixtures each have one match, so this is not a live bug. Sorting the candidates by range start, or asserting a single match, would keep future fixtures safe.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests/requests.test.rs` around lines 26 - 41, The expression_range_by_source helper currently selects an arbitrary matching range based on raw_expressions iteration order. Collect all ranges whose source snippet matches expected, then sort candidates by range start before selecting one, or assert that exactly one match exists; preserve the existing panic when no matching expression is found.crates/biome_module_graph/tests/spec_tests/css_properties.test.rs (1)
228-278: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueThree tests overlap completely.
css_property_query_traverses_js_importersalready contains both assertions. The first assertion duplicatescss_property_query_preserves_js_import_order. The second duplicatescss_property_query_skips_non_css_sibling_imports. Consider keeping the two focused tests and removing the combined one, or the reverse. Either way one of the three can go.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests/css_properties.test.rs` around lines 228 - 278, Remove the redundant css_property_query_traverses_js_importers test, since its assertions are already covered by css_property_query_preserves_js_import_order and css_property_query_skips_non_css_sibling_imports. Keep the two focused tests unchanged.crates/biome_module_graph/tests/spec_tests/html_classes.test.rs (1)
12-34: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueBind the markup once.
The same
"<div class=\"card\"></div>"literal appears at line 18 and line 25. If one copy changes, the file content in the memory filesystem and the parsed source diverge without any test failing. Also,CssFileSourceandWorkspaceDbare written fully qualified whileHtmlFileSourceis imported at line 2.β»οΈ Suggested tidy-up
+use biome_languages::CssFileSource; +use biome_workspace_db::WorkspaceDb; + fn classes( path: &str, source: HtmlFileSource, - styles: &[(&str, biome_languages::CssFileSource)], -) -> (biome_workspace_db::WorkspaceDb, Vec<String>) { + styles: &[(&str, CssFileSource)], +) -> (WorkspaceDb, Vec<String>) { + const MARKUP: &str = "<div class=\"card\"></div>"; let fs = MemoryFileSystem::default(); - fs.insert(path.into(), "<div class=\"card\"></div>"); + fs.insert(path.into(), MARKUP); let embedded = styles .iter() .map(|(css, source)| parse_embedded_css(css, *source)) .collect(); - let db = build_html_db( - &fs, - &[(path, "<div class=\"card\"></div>", source, embedded)], - ); + let db = build_html_db(&fs, &[(path, MARKUP, source, embedded)]);π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests/html_classes.test.rs` around lines 12 - 34, Update the classes helper to bind the shared HTML markup string once and reuse it for both fs.insert and build_html_db, preventing the filesystem content and parsed source from diverging. Also use the existing imports for CssFileSource and WorkspaceDb instead of fully qualified names, while preserving the helperβs behavior.crates/biome_module_graph/tests/spec_tests.rs (2)
138-153: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueConsider delegating to
module_for_key.
crates/biome_module_graph/src/db/mod.rsalready exposesmodule_for_key, which performs the same path lookup and stale-key rejection. The import list at line 29 already includes it.β»οΈ Suggested simplification
fn local_type_name( &self, module_key: InferredModuleKey, type_id: InferredLocalTypeId, ) -> Option<Text> { - let module = ModuleInfo::from_id(module_key.as_id()); - let current = self.module_for_path(module.path(self))?; - if InferredModuleKey::new(current.as_id()) != module_key { - return None; - } - - let ModuleInfoKind::Js(info) = current.kind(self) else { + let current = module_for_key(self, module_key)?; + let ModuleInfoKind::Js(info) = current.kind(self) else { return None; }; info.local_type_name(type_id) }π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests.rs` around lines 138 - 153, Update local_type_name to delegate module resolution to the existing module_for_key helper instead of duplicating ModuleInfo path lookup and stale-key validation; retain the JavaScript-kind check and info.local_type_name(type_id) call after obtaining the module.
682-704: π Maintainability & Code Quality | π΅ Trivial | β‘ Quick winReuse
snap::write_source_fileinstead of a second copy.
crates/biome_module_graph/tests/snap/mod.rslines 137-192 already define a publicwrite_source_filewith the same signature, andmod snap;is registered at line 86. This local copy only handles the JavaScript branch, so the two helpers will drift, and any HTML or CSS fixture passed toassert_inferred_type_snapshotwill print unformatted source here while the other path formats it.Call
snap::write_source_fileand delete the local function.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests.rs` around lines 682 - 704, In the snapshot test flow, replace the local write_source_file implementation with a call to the existing public snap::write_source_file helper, then delete the duplicate local function. Preserve the current callers, including assert_inferred_type_snapshot, so all supported fixture types use the shared formatting behavior.crates/biome_module_graph/tests/spec_tests/promises.test.rs (1)
7-23: π Maintainability & Code Quality | π΅ Trivial | β‘ Quick winTwo copies of the same expression-range lookup, both taking the first text match. Each helper scans
raw_expressionsand accepts the first range whose collapsed source text equals the expected string. Fixtures that repeat an expression therefore measure an arbitrary occurrence, and the duplication means a fix must be applied twice. Promote one helper intocrates/biome_module_graph/tests/spec_tests.rsnext tosource_snippet, and make it reject ambiguous matches.
crates/biome_module_graph/tests/spec_tests/promises.test.rs#L7-L23: drop the inline range lookup and call the shared helper, keeping only theinfer_expression_function_returns_promisecall.crates/biome_module_graph/tests/spec_tests/queries.test.rs#L24-L39: deleteexpression_range_by_sourceand use the shared helper from the parent module.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests/promises.test.rs` around lines 7 - 23, Centralize expression-range lookup in a shared helper next to source_snippet in crates/biome_module_graph/tests/spec_tests.rs, making it reject ambiguous source-text matches instead of selecting the first. In crates/biome_module_graph/tests/spec_tests/promises.test.rs lines 7-23, remove the inline lookup and call the shared helper before infer_expression_function_returns_promise; in crates/biome_module_graph/tests/spec_tests/queries.test.rs lines 24-39, delete expression_range_by_source and use the shared helper, with no other changes.crates/biome_module_graph/tests/spec_tests/calls.test.rs (1)
279-294: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueExtract the repeated callable-type lookup.
Six blocks scan
inferred.typesfor aReaderinterface or object with a given number of call signatures. Only the name and the expected count change. A pair of helpers keeps each test focused on the behaviour under test.β»οΈ Suggested helpers
fn inferred_interface_with_call_signatures<'db>( db: &'db TestModuleDb, inferred: &InferredModuleTypes<'db>, name: &str, count: usize, ) -> InferredTypeData<'db> { inferred .types .iter() .copied() .find(|ty| { matches!( ty, InferredTypeData::Interface(interface) if interface.name(db).text() == name && interface .members(db) .iter() .filter(|member| member.kind.is_call_signature()) .count() == count ) }) .unwrap_or_else(|| panic!("{name} interface type must be inferred")) }Also applies to: 318-335, 373-390, 428-445, 481-495, 519-535
π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/tests/spec_tests/calls.test.rs` around lines 279 - 294, Extract the repeated inferred-type lookup into an inferred_interface_with_call_signatures helper near the shared test utilities, accepting the database, inferred types, interface name, and expected call-signature count. Replace all six Reader/object lookup blocks, including the block around reader_ty and the additional referenced ranges, with calls to this helper while preserving each testβs existing name and expected count.
π€ Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/biome_module_graph/src/db/type_inference/qualifiers.rs`:
- Around line 248-257: Add regression tests for TypeReferenceQualifier covering
Symbol.dispose and Symbol.asyncDispose, plus a multi-member global type
qualifier that verifies sequential traversal. Place the coverage alongside the
existing globalThis.Promise test, ensuring the new cases exercise type
qualifiers rather than expression-chain resolution.
In `@crates/biome_module_graph/tests/spec_tests.rs`:
- Around line 138-153: Update local_type_name to delegate module resolution to
the existing module_for_key helper instead of duplicating ModuleInfo path lookup
and stale-key validation; retain the JavaScript-kind check and
info.local_type_name(type_id) call after obtaining the module.
- Around line 682-704: In the snapshot test flow, replace the local
write_source_file implementation with a call to the existing public
snap::write_source_file helper, then delete the duplicate local function.
Preserve the current callers, including assert_inferred_type_snapshot, so all
supported fixture types use the shared formatting behavior.
In `@crates/biome_module_graph/tests/spec_tests/calls.test.rs`:
- Around line 279-294: Extract the repeated inferred-type lookup into an
inferred_interface_with_call_signatures helper near the shared test utilities,
accepting the database, inferred types, interface name, and expected
call-signature count. Replace all six Reader/object lookup blocks, including the
block around reader_ty and the additional referenced ranges, with calls to this
helper while preserving each testβs existing name and expected count.
In `@crates/biome_module_graph/tests/spec_tests/css_properties.test.rs`:
- Around line 228-278: Remove the redundant
css_property_query_traverses_js_importers test, since its assertions are already
covered by css_property_query_preserves_js_import_order and
css_property_query_skips_non_css_sibling_imports. Keep the two focused tests
unchanged.
In `@crates/biome_module_graph/tests/spec_tests/html_classes.test.rs`:
- Around line 12-34: Update the classes helper to bind the shared HTML markup
string once and reuse it for both fs.insert and build_html_db, preventing the
filesystem content and parsed source from diverging. Also use the existing
imports for CssFileSource and WorkspaceDb instead of fully qualified names,
while preserving the helperβs behavior.
In `@crates/biome_module_graph/tests/spec_tests/module_resolution.test.rs`:
- Around line 72-80: Remove the unused /src/components/Hello.tsx entry from the
file list passed to build_js_db in the affected test, leaving only /src/index.ts
while preserving the existing project setup and assertions.
- Around line 30-42: Update the manifest deserialization call sites in the test
setup and the corresponding location around the second noted block to use the
imported deserialize_from_json_str helper directly instead of the fully
qualified biome_deserialize::json::deserialize_from_json_str path, keeping
behavior unchanged.
In `@crates/biome_module_graph/tests/spec_tests/promises.test.rs`:
- Around line 7-23: Centralize expression-range lookup in a shared helper next
to source_snippet in crates/biome_module_graph/tests/spec_tests.rs, making it
reject ambiguous source-text matches instead of selecting the first. In
crates/biome_module_graph/tests/spec_tests/promises.test.rs lines 7-23, remove
the inline lookup and call the shared helper before
infer_expression_function_returns_promise; in
crates/biome_module_graph/tests/spec_tests/queries.test.rs lines 24-39, delete
expression_range_by_source and use the shared helper, with no other changes.
In `@crates/biome_module_graph/tests/spec_tests/requests.test.rs`:
- Around line 26-41: The expression_range_by_source helper currently selects an
arbitrary matching range based on raw_expressions iteration order. Collect all
ranges whose source snippet matches expected, then sort candidates by range
start before selecting one, or assert that exactly one match exists; preserve
the existing panic when no matching expression is found.
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 74ff2d09-623f-455d-b468-960da900a294
β Files ignored due to path filters (73)
crates/biome_js_analyze/tests/specs/nursery/useDisposables/valid.ts.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_deduplicates_substituted_union_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_resolves_union_function_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_interface_overload_by_arity.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_interface_overload_with_optional_parameter_by_arity.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_interface_overload_with_rest_parameter_by_arity.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_object_overload_by_arity.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_function_declaration_overload_by_callback_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_imported_function_declaration_overload_by_callback_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_chained_generic_default_from_argument.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_chained_generic_defaults.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_from_callback_promise_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_from_callback_promise_union_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_inside_intersection_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_inside_promise_union_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_inside_union_with_promise_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_multiple_generics_inside_union_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_nested_generic_return_type.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_calls_imported_generic_function_type_aliases.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_coerces_tuples_in_additions.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_arithmetic_unary_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_array_element_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_await_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_await_local_union_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_await_promise_like_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_await_union_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_call_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_conditional_logical_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_conditional_logical_fast_paths_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_destructuring_edge_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_destructuring_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_new_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_static_member_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_this_and_super_edge_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_this_and_super_expressions_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_typeof_operator_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_filters_conditional_subsets_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_infers_new_expression_nested_generic_instances_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_keeps_overloads_viable_for_partially_modelled_arguments_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_class_instance_intersections_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_function_intersections_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_inline_object_intersections_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_mixed_intersections_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_normalizes_intersection_variants_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_normalizes_primitive_intersections_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_normalizes_union_variants_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_preserves_floating_promise_shapes.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_preserves_generic_class_this_parameters.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_preserves_generic_interface_instantiation_parameters.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_preserves_new_expression_generic_instances_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_preserves_optional_chain_short_circuit_types_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_builtin_global_identities_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_generic_builtin_instances_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_inherited_static_members.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_namespace_import_members.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_namespace_reexport_members.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_promise_member_chain.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_record_index_signature_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_this_member_in_object_method.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_utility_type_members_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_by_interface_call_signatures_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_by_nominal_class_parameters_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_by_parameter_types_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_by_required_object_members_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_for_array_and_optional_tuple_spreads_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_for_subclass_arguments_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_infer_module_types_substitutes_callback_returns_through_type_aliases_on_build.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_normalize_type_collapses_equal_merged_reference_targets.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_normalize_type_preserves_recursive_array_local_edge.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_normalize_type_preserves_recursive_local_edge.snapis excluded by!**/*.snapand included by**crates/biome_module_graph/tests/snapshots/test_normalize_type_resolves_typeof_type.snapis excluded by!**/*.snapand included by**crates/biome_service/src/snapshots/biome_service__workspace__tests__debug_type_info.snapis excluded by!**/*.snapand included by**crates/biome_service/src/snapshots/module_diagnostic.snapis excluded by!**/*.snapand included by**
π Files selected for processing (33)
crates/biome_js_analyze/tests/specs/nursery/useDisposables/valid.tscrates/biome_js_type_info/Cargo.tomlcrates/biome_js_type_info/src/interned_types.rscrates/biome_js_type_info/src/local_inference.rscrates/biome_js_type_info/src/type_data.rscrates/biome_js_type_info/tests/type_data.rscrates/biome_module_graph/Cargo.tomlcrates/biome_module_graph/src/db/type_inference/qualifiers.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/tests/spec_tests.rscrates/biome_module_graph/tests/spec_tests/calls.test.rscrates/biome_module_graph/tests/spec_tests/css_classes.test.rscrates/biome_module_graph/tests/spec_tests/css_properties.test.rscrates/biome_module_graph/tests/spec_tests/cycles.test.rscrates/biome_module_graph/tests/spec_tests/database.test.rscrates/biome_module_graph/tests/spec_tests/expected_argument_inference.test.rscrates/biome_module_graph/tests/spec_tests/expressions.test.rscrates/biome_module_graph/tests/spec_tests/globals.test.rscrates/biome_module_graph/tests/spec_tests/html_classes.test.rscrates/biome_module_graph/tests/spec_tests/html_components.test.rscrates/biome_module_graph/tests/spec_tests/imports.test.rscrates/biome_module_graph/tests/spec_tests/intersections.test.rscrates/biome_module_graph/tests/spec_tests/js_doc.test.rscrates/biome_module_graph/tests/spec_tests/module_resolution.test.rscrates/biome_module_graph/tests/spec_tests/normalization.test.rscrates/biome_module_graph/tests/spec_tests/overloads.test.rscrates/biome_module_graph/tests/spec_tests/promises.test.rscrates/biome_module_graph/tests/spec_tests/queries.test.rscrates/biome_module_graph/tests/spec_tests/requests.test.rscrates/biome_module_graph/tests/spec_tests/substitutions.test.rscrates/biome_module_graph/tests/spec_tests/support.rscrates/biome_module_graph/tests/spec_tests/types.test.rscrates/biome_module_graph/tests/spec_tests_v2.rs
π€ Files with no reviewable changes (2)
- crates/biome_js_type_info/tests/type_data.rs
- crates/biome_module_graph/tests/snap/mod.rs
π§ Files skipped from review as they are similar to previous changes (4)
- crates/biome_js_type_info/Cargo.toml
- crates/biome_js_type_info/src/interned_types.rs
- crates/biome_js_type_info/src/type_data.rs
- crates/biome_js_type_info/src/local_inference.rs
85b7819 to
4786ad2
Compare
|
The regressions are false positives |

Summary
Decouples retained Salsa types and test targets from the legacy engine so the follow-up purge can remove only complete files and dependency lines. Legacy implementation files remain present in this intermediary.
Additionally, this PR uses the newly added SCC algorithm for acyclic modules, and it removes the thread-local guards.
Test Plan
Before, I had
spect_test_v2.rsto avoid tarnishing the old test suite. In this PR, the tests created until now have been moved intospec_test.rs, and all tests have been split into features, so that they are more organised and easy to reach out.Docs
N/A