Skip to content

feat(inference): inference engine via salsa - #10888

Merged
ematipico merged 37 commits into
mainfrom
refactor/inference-to-salsa
Jul 12, 2026
Merged

ematipico merged 37 commits into
mainfrom
refactor/inference-to-salsa

Conversation

@ematipico

@ematipico ematipico commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Important

This code isn't wired to production. Production still uses the current engine.

Part of #10883

This PR ports the existing engine to use the new salsa-backed engine. I implemented the PR mostly via coding agents. I crafted the plan with 5 iterations, and used two agents + and human review of the code emitted.

Below, an AI-generated summary of the change


How the new inference engine works

The big picture

source file
    β”‚  AST walk (collector)
    β–Ό
raw type table          ← plain data, one entry per type the file mentions
    β”‚  infer_module_types (salsa query)
    β–Ό
inferred types          ← resolved, deduplicated, cached by salsa
    β”‚  lookups (find member, resolve handle, normalize)
    β–Ό
lint rules

The old engine did everything in one go, per file, every time. The new engine splits the work into collect once, infer once per change, look up many times.

Step 1 β€” Collect raw types

While walking the AST, the collector writes down every type it sees into a flat table: "slot 3 is a function returning slot 5", "slot 7 is typeof of the expression in slot 6". Nothing is resolved yet β€” names are still names, imports are still paths. This table is cheap to build and is the input salsa watches for changes.

Step 2 β€” Resolve (the salsa query)

infer_module_types walks the raw table and turns every entry into a real type:

  • Names are looked up through the scope chain, then globals.
  • Imports trigger the same query on the imported module first, so a module's types depend on its dependencies' types β€” salsa records that and only recomputes what a change actually touches.
  • Named types (classes, interfaces, type aliases) don't get copied β€” they become a small handle (module + slot number). This is how recursive types work: class Foo { next: Foo } stores a handle to itself instead of infinitely nesting. Whoever holds the handle resolves it later, one hop at a time.

Flattening happens while building, not after

The old engine built messy types first and then ran a flatten pass up to ten times to clean them up. The new engine refuses to build messy types in the first place: every union and intersection goes through a builder that flattens nested unions, removes duplicates, collapses true | false into boolean, and merges intersected object members β€” at the moment the type is created. There is no flatten pass anymore because there is nothing left to flatten.

Expressions are evaluated during resolution

The raw table stores expressions like "the call of slot 4" or "await of slot 9". During resolution these are computed: a call looks up the function's return type (picking the right overload by checking each argument against each parameter), await unwraps the Promise, a ?? b becomes "the non-nullish part of a, or b", member access finds the member β€” walking up extends chains if needed.

Substitution makes generics concrete

When a generic shape meets concrete type arguments β€” Box<string>, or a call like identity("hi") β€” the engine collects which type parameter maps to what (T β†’ string) and then rebuilds the affected type with every T replaced. Types are immutable here, so substitution never edits anything: it produces a new type, and the union builder cleans up whatever the replacement produced (e.g. T | T after substitution becomes just string). This runs for generic classes, function returns, callbacks, and inherited members (ClassBox<T> extends ClassBase<T> carries the substitution through the lookup).

Everything is interned

Every type built this way is stored once, globally, and referred to by a tiny copyable id. Two identical types β€” even from different modules β€” are literally the same id, so comparing types is comparing two numbers, and duplicates cost nothing.

Why it's fast on re-analysis

Salsa remembers the result of infer_module_types per module. Edit one file and only that file (and the files whose results actually change) re-infer; everything else is a cache hit. Measured on the benchmark fixtures: a five-module graph costs ~142 ms to infer cold, ~80 Β΅s after editing one file, and 3–46 Β΅s to re-query unchanged.

Safety rails

Every loop that follows references (handle chains, member lookups, promise unwrapping) carries a visited set and a step budget: a weird or cyclic type degrades to unknown instead of hanging. The engine prefers a vaguer answer over a wrong one β€” and always over no answer.


  • I created a mirror of the types we currently have; however, these ones carry the lifetime 'db, which is one of the reasons why it was best to create a new engine. The type is TypeData
  • The new types are very cheap to copy, because they are baked by salsa ids
  • Create the TypeDb trait. It only contains a function used to resolve the name of the locally resolved types.
  • Using the function mentioned, the new snapshots are way improved compared to the old ones. The new ones don't carry
  • The queries.rs is a big mess in terms of sorting and placement. I will tidy them up in the next PR.
  • I added some guards when it comes to how the DB write/reads. Those should be triggered when we have a deadlock inside the database. They also semi-panic so we can untangle the deadlock. I avoided the panic.

Test Plan

I added new tests inside the spec_test_v2.rs, and many snapshot tests so that we can cover as much ground as possible before switching to the new engine, without breaking people's code.

I also added new benchmarks that show how salsa is useful:

  • I added end-to-end benchmarks that simulate what we already have. They are slightly faster, but it also does more work: substitution of generics, normalisation of overload functions and their parameters, evaluation of expressions.
  • I added a benchmark that shows memoisation. We get the new data for free.
  • Then I added bench_index_d_ts_salsa_incremental and bench_index_d_ts_salsa_incremental_first_run. The latter runs inference on cold cache, the former runs on cold cache, we apply a change to the source code e.g. a type and then it runs the inference again. Below, you can how it takes less because with salsa we compute only things that changed
type_inference                                   fastest       β”‚ slowest       β”‚ median        β”‚ mean          β”‚ samples β”‚ iters
β”œβ”€ bench_index_d_ts_salsa_end_to_end                           β”‚               β”‚               β”‚               β”‚         β”‚
β”‚  β”œβ”€ @next/font/google/index.d.ts               78.5 ms       β”‚ 91.86 ms      β”‚ 79.6 ms       β”‚ 80.35 ms      β”‚ 100     β”‚ 100
β”‚  β”œβ”€ RedisCommander.d.ts                        37.2 ms       β”‚ 65.77 ms      β”‚ 37.69 ms      β”‚ 38.7 ms       β”‚ 100     β”‚ 100
β”‚  β”œβ”€ astro_server.mjs                           49.03 ms      β”‚ 55.78 ms      β”‚ 49.47 ms      β”‚ 50.62 ms      β”‚ 100     β”‚ 100
β”‚  ╰─ react/index.d.ts                           7.234 ms      β”‚ 8.476 ms      β”‚ 7.326 ms      β”‚ 7.433 ms      β”‚ 100     β”‚ 100
β”œβ”€ bench_index_d_ts_salsa_incremental            71.33 Β΅s      β”‚ 1.534 ms      β”‚ 79.54 Β΅s      β”‚ 94.67 Β΅s      β”‚ 100     β”‚ 100
β”œβ”€ bench_index_d_ts_salsa_incremental_first_run  137.9 ms      β”‚ 149 ms        β”‚ 142.5 ms      β”‚ 142.5 ms      β”‚ 100     β”‚ 100
β”œβ”€ bench_index_d_ts_salsa_invalidated                          β”‚               β”‚               β”‚               β”‚         β”‚
β”‚  β”œβ”€ @next/font/google/index.d.ts               12.81 ms      β”‚ 16.75 ms      β”‚ 13.07 ms      β”‚ 13.41 ms      β”‚ 100     β”‚ 100
β”‚  β”œβ”€ RedisCommander.d.ts                        3.642 ms      β”‚ 4.392 ms      β”‚ 3.684 ms      β”‚ 3.711 ms      β”‚ 100     β”‚ 100
β”‚  β”œβ”€ astro_server.mjs                           7.956 ms      β”‚ 20.23 ms      β”‚ 8.079 ms      β”‚ 8.495 ms      β”‚ 100     β”‚ 100
β”‚  ╰─ react/index.d.ts                           1.65 ms       β”‚ 2.294 ms      β”‚ 1.667 ms      β”‚ 1.684 ms      β”‚ 100     β”‚ 100
╰─ bench_index_d_ts_salsa_memoized                             β”‚               β”‚               β”‚               β”‚         β”‚
   β”œβ”€ @next/font/google/index.d.ts               29.79 Β΅s      β”‚ 56.12 Β΅s      β”‚ 38 Β΅s         β”‚ 37.49 Β΅s      β”‚ 100     β”‚ 100
   β”œβ”€ RedisCommander.d.ts                        13.74 Β΅s      β”‚ 39.91 Β΅s      β”‚ 17.04 Β΅s      β”‚ 16.97 Β΅s      β”‚ 100     β”‚ 100
   β”œβ”€ astro_server.mjs                           37.58 Β΅s      β”‚ 61.79 Β΅s      β”‚ 45.6 Β΅s       β”‚ 46.08 Β΅s      β”‚ 100     β”‚ 100
   ╰─ react/index.d.ts                           3.02 Β΅s       β”‚ 10.64 Β΅s      β”‚ 3.405 Β΅s      β”‚ 3.729 Β΅s      β”‚ 100     β”‚ 200

Docs

What's next

Two major things:

  • The implementation of salsa fixpoints so that we can fix cycles (which aren't the cycles that happen during inference e.g. type Tree = string | Tree[]. For that, there's the TypeData::Divergent type. We will use it for fixing cycles when importing modules e.g. module A imports B, and B imports A.
  • Plumbing with the linter. There's a comment there already.

ematipico added 30 commits July 8, 2026 09:18
@github-actions github-actions Bot added L-JavaScript Language: JavaScript and super languages A-Type-Inference Area: type inference labels Jul 9, 2026
@codspeed

codspeed Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

βœ… 249 untouched benchmarks
πŸ†• 14 new benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
πŸ†• bench_index_d_ts_salsa_end_to_end[@next/font/google/index.d.ts] N/A 331.9 ms N/A
πŸ†• bench_index_d_ts_salsa_end_to_end[astro_server.mjs] N/A 191.8 ms N/A
πŸ†• bench_index_d_ts_salsa_end_to_end[react/index.d.ts] N/A 26.6 ms N/A
πŸ†• bench_index_d_ts_salsa_end_to_end[RedisCommander.d.ts] N/A 149.5 ms N/A
πŸ†• bench_index_d_ts_salsa_incremental N/A 333.9 Β΅s N/A
πŸ†• bench_index_d_ts_salsa_incremental_first_run N/A 554.8 ms N/A
πŸ†• bench_index_d_ts_salsa_invalidated[@next/font/google/index.d.ts] N/A 53.8 ms N/A
πŸ†• bench_index_d_ts_salsa_invalidated[astro_server.mjs] N/A 27.6 ms N/A
πŸ†• bench_index_d_ts_salsa_invalidated[react/index.d.ts] N/A 5.9 ms N/A
πŸ†• bench_index_d_ts_salsa_invalidated[RedisCommander.d.ts] N/A 16.5 ms N/A
πŸ†• bench_index_d_ts_salsa_memoized[@next/font/google/index.d.ts] N/A 736.6 Β΅s N/A
πŸ†• bench_index_d_ts_salsa_memoized[astro_server.mjs] N/A 1 ms N/A
πŸ†• bench_index_d_ts_salsa_memoized[react/index.d.ts] N/A 77.4 Β΅s N/A
πŸ†• bench_index_d_ts_salsa_memoized[RedisCommander.d.ts] N/A 351.4 Β΅s N/A

Comparing refactor/inference-to-salsa (b6f0cd0) with main (d6bc447)

Open in CodSpeed

@ematipico
ematipico marked this pull request as ready for review July 9, 2026 16:29
@ematipico
ematipico requested review from a team July 9, 2026 16:30
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb7a6db4-4c43-4bf8-b7b1-23a5df13bc3b

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a4cf7fc and b6f0cd0.

β›” Files ignored due to path filters (2)
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_coerces_tuples_in_additions.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_filters_conditional_subsets_on_build.snap is excluded by !**/*.snap and included by **
πŸ“’ Files selected for processing (6)
  • crates/biome_js_type_info/src/format_inferred_type_info.rs
  • crates/biome_module_graph/src/db/mod.rs
  • crates/biome_module_graph/src/db/type_inference/expressions.rs
  • crates/biome_module_graph/tests/spec_tests_v2.rs
  • crates/biome_service/src/workspace/db.rs
  • crates/biome_service/src/workspace/server.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/biome_js_type_info/src/format_inferred_type_info.rs
  • crates/biome_module_graph/src/db/mod.rs
  • crates/biome_service/src/workspace/db.rs
  • crates/biome_module_graph/src/db/type_inference/expressions.rs
  • crates/biome_service/src/workspace/server.rs

Walkthrough

This PR adds a Salsa-backed JavaScript type-inference engine with interned types, compound-type builders, module-graph queries, expression and member resolution, formatting, benchmarks, and extensive tests. Module collection now supports TypeInferenceMode, while analyser services consume typed modules. Workspace database forks gain read-guard tracking that prevents conflicting setter updates, and workspace server operations use untracked database views with phased module-graph commits.

Possibly related issues

Possibly related PRs

  • biomejs/biome#10315: Provides the Salsa interned/event machinery used by this change.
  • biomejs/biome#10796: Refactors the workspace Salsa database and fork model used by the new read-guard wiring.

Suggested labels: A-Core, A-Resolver, L-JavaScript

Suggested reviewers: dyc3, chansuke

πŸš₯ Pre-merge checks | βœ… 4
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly captures the main change: moving the inference engine to Salsa-backed implementation.
Description check βœ… Passed The description is directly related and accurately explains the Salsa-backed inference engine changes and supporting work.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/inference-to-salsa

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (4)
crates/biome_db/src/testing.rs (1)

112-140: πŸ“ Maintainability & Code Quality | πŸ”΅ Trivial | ⚑ Quick win

Duplicated matching predicate.

The event-matching predicate here is identical to the one in find_will_execute_event (lines 141-160). Consider extracting a shared helper (e.g. a small closure factory or a common iterator filter) so future tweaks to the matching logic don't need to be applied in two places.

♻️ Possible consolidation
+fn matches_query_event<I>(db: &dyn salsa::Database, query_name: &str, input_id: salsa::Id, event: &Event) -> bool
+where
+    I: salsa::plumbing::AsId,
+{
+    if let salsa::EventKind::WillExecute { database_key } = event.kind {
+        db.ingredient_debug_name(database_key.ingredient_index()) == query_name
+            && database_key.key_index() == input_id
+    } else {
+        false
+    }
+}

Then both function_query_will_execute_position and find_will_execute_event could call this shared helper.

πŸ€– 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_db/src/testing.rs` around lines 112 - 140, The
`function_query_will_execute_position` predicate duplicates the `WillExecute`
matching logic already used by `find_will_execute_event`, so extract the shared
event-matching check into a common helper and have both functions reuse it. Keep
the helper focused on comparing `ingredient_debug_name`,
`database_key.key_index()`, and `query_name(&query)` so any future changes to
`salsa::EventKind::WillExecute` matching only need to be made in one place.
crates/biome_service/src/workspace/db.rs (1)

101-113: 🩺 Stability & Availability | πŸ”΅ Trivial | ⚑ Quick win

Drop DerefMut from DbReadGuard
DbReadGuard is only used for reads here, and there are no call sites that need a mutable fork result. Removing DerefMut keeps the deadlock guard tighter; if a mutable escape is intentional, document that path explicitly.

πŸ€– 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_service/src/workspace/db.rs` around lines 101 - 113, DbReadGuard
currently exposes mutable access via DerefMut even though it is only used for
reads, so remove the DerefMut impl from DbReadGuard and keep only the Deref impl
to WorkspaceDb. If any mutable access is truly needed later, route it through an
explicit API on DbReadGuard or WorkspaceDb instead of implicit mutable deref.
crates/biome_module_graph/src/db/mod.rs (1)

8-10: πŸ“ Maintainability & Code Quality | πŸ”΅ Trivial | πŸ’€ Low value

Stale doc comment. The trait now extends TypeDb, but the comment still references Db.

πŸ“ Tiny wording fix
-/// Extends `Db` with module-graph-specific lookups.
+/// Extends `TypeDb` with module-graph-specific lookups.
 #[salsa::db]
 pub trait ModuleDb: TypeDb {
πŸ€– 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/mod.rs` around lines 8 - 10, Update the doc
comment on ModuleDb so it no longer refers to Db and instead matches the actual
supertrait TypeDb; keep the wording aligned with the trait definition in
ModuleDb and preserve the module-graph-specific context.
crates/biome_js_analyze/src/services/typed.rs (1)

43-56: πŸš€ Performance & Scalability | πŸ”΅ Trivial | ⚑ Quick win

resolver() re-runs full module inference on every call.

ModuleResolver::for_module(...) runs run_inference() (imports + resolve_all + flatten_all) on construction. Since type_of_expression, type_of_named_value, and type_of_function all call resolver() afresh β€” and type_of_member fans out into two of them β€” a rule visiting many nodes will re-infer the entire module for each lookup. The previous stored Arc<ModuleResolver> amortised this; consider memoising per TypedService instance (e.g. a OnceCell<Option<Arc<ModuleResolver>>>).

Not blocking given this isn't wired to production yet, but it'll bite once it is.

πŸ€– 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_analyze/src/services/typed.rs` around lines 43 - 56, The
TypedService::resolver() method is recreating a ModuleResolver on every lookup,
which re-runs full module inference repeatedly. Memoize the resolver per
TypedService instance so type_of_expression, type_of_named_value,
type_of_function, and type_of_member can reuse the same Arc<ModuleResolver>; a
OnceCell<Option<Arc<ModuleResolver>>> or equivalent cache in TypedService is a
good fit.
πŸ€– 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/src/format_inferred_type_info.rs`:
- Line 795: The `Self::New` formatter in `format_inferred_type_info.rs` is
omitting constructor arguments, so the debug/format output is incomplete
compared with `Self::Call`. Update the `write!` branch for `TypeofNewExpression`
to format both `expr.callee` and `expr.arguments`, mirroring the existing
call-expression handling so `new` expressions round-trip with their full
argument list.

In `@crates/biome_module_graph/src/db/type_inference/expressions.rs`:
- Around line 1432-1471: The string-coercion logic in expressions handling `+`
is missing `InferredTypeData::Tuple(_)`, so tuple/array operands can incorrectly
fall through to `None`. Update the match in `expressions.rs` so the same branch
that returns `Some(InferredTypeData::String)` for `Class`, `Object`, `String`,
etc. also covers `Tuple`, ensuring array-like values are treated as strings
during coercion.
- Around line 1705-1711: In the FilterAction::Retained branch inside the
expression type inference logic, non-flattenable InferredTypeData::InstanceOf
values are currently skipped instead of being preserved. Update the retained
handling in the expressions inference path so that when should_flatten_instance
returns false, the original ty is added to pending/types rather than being
dropped, matching the behavior used for other retained cases and keeping
InstanceOf in the inferred union.

In `@crates/biome_service/src/workspace/db.rs`:
- Around line 58-64: The doc comment for into_untracked_db is mangled and should
be rewritten for clarity. Update the wording in the comment on into_untracked_db
and DbState so the final sentence reads naturally, especially the guidance about
keeping the guard alive for normal reads and only using this escape hatch when a
lower-level read-only API needs a plain WorkspaceDb. Ensure the NOTE remains
intact and legible.

In `@crates/biome_service/src/workspace/server.rs`:
- Around line 3059-3064: The comment above new_root in server.rs has a typo and
is missing the key wording that explains the block scope; update the prose
around get_db and update_snippets so it clearly says the operations are
intentionally kept inside blocks to ensure the forks created by get_db are
dropped before setters run. Keep the fix limited to the nearby inline comment
and preserve the intent of the new_root / workspace_db flow.

---

Nitpick comments:
In `@crates/biome_db/src/testing.rs`:
- Around line 112-140: The `function_query_will_execute_position` predicate
duplicates the `WillExecute` matching logic already used by
`find_will_execute_event`, so extract the shared event-matching check into a
common helper and have both functions reuse it. Keep the helper focused on
comparing `ingredient_debug_name`, `database_key.key_index()`, and
`query_name(&query)` so any future changes to `salsa::EventKind::WillExecute`
matching only need to be made in one place.

In `@crates/biome_js_analyze/src/services/typed.rs`:
- Around line 43-56: The TypedService::resolver() method is recreating a
ModuleResolver on every lookup, which re-runs full module inference repeatedly.
Memoize the resolver per TypedService instance so type_of_expression,
type_of_named_value, type_of_function, and type_of_member can reuse the same
Arc<ModuleResolver>; a OnceCell<Option<Arc<ModuleResolver>>> or equivalent cache
in TypedService is a good fit.

In `@crates/biome_module_graph/src/db/mod.rs`:
- Around line 8-10: Update the doc comment on ModuleDb so it no longer refers to
Db and instead matches the actual supertrait TypeDb; keep the wording aligned
with the trait definition in ModuleDb and preserve the module-graph-specific
context.

In `@crates/biome_service/src/workspace/db.rs`:
- Around line 101-113: DbReadGuard currently exposes mutable access via DerefMut
even though it is only used for reads, so remove the DerefMut impl from
DbReadGuard and keep only the Deref impl to WorkspaceDb. If any mutable access
is truly needed later, route it through an explicit API on DbReadGuard or
WorkspaceDb instead of implicit mutable deref.
πŸͺ„ 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: a000ae35-18c7-4d35-8310-d1ae9dce9844

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 60c8043 and a4cf7fc.

β›” Files ignored due to path filters (55)
  • Cargo.lock is excluded by !**/*.lock and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_deduplicates_substituted_union_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_resolves_union_function_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_interface_overload_by_arity.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_interface_overload_with_optional_parameter_by_arity.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_interface_overload_with_rest_parameter_by_arity.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_callable_object_overload_by_arity.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_function_declaration_overload_by_callback_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_selects_imported_function_declaration_overload_by_callback_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_from_callback_promise_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_inside_intersection_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_inside_promise_union_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_generic_inside_union_with_promise_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_multiple_generics_inside_union_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_call_expression_type_substitutes_nested_generic_return_type.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_arithmetic_unary_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_array_element_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_await_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_await_promise_like_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_await_union_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_call_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_conditional_logical_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_conditional_logical_fast_paths_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_destructuring_edge_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_destructuring_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_new_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_static_member_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_this_and_super_edge_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_this_and_super_expressions_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_evaluates_typeof_operator_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_filters_conditional_subsets_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_infers_new_expression_nested_generic_instances_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_class_instance_intersections_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_function_intersections_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_inline_object_intersections_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_merges_mixed_intersections_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_normalizes_intersection_variants_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_normalizes_primitive_intersections_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_normalizes_union_variants_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_preserves_generic_interface_instantiation_parameters.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_preserves_new_expression_generic_instances_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_builtin_global_identities_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_generic_builtin_instances_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_namespace_import_members.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_namespace_reexport_members.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_record_index_signature_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_resolves_utility_type_members_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_by_nominal_class_parameters_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_by_parameter_types_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_for_array_and_optional_tuple_spreads_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_infer_module_types_selects_call_overloads_for_subclass_arguments_on_build.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_normalize_type_collapses_equal_merged_reference_targets.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_normalize_type_preserves_recursive_array_local_edge.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_normalize_type_preserves_recursive_local_edge.snap is excluded by !**/*.snap and included by **
  • crates/biome_module_graph/tests/snapshots/test_normalize_type_resolves_typeof_type.snap is excluded by !**/*.snap and included by **
πŸ“’ Files selected for processing (30)
  • crates/biome_db/src/testing.rs
  • crates/biome_js_analyze/src/lib.rs
  • crates/biome_js_analyze/src/services/typed.rs
  • crates/biome_js_type_info/Cargo.toml
  • crates/biome_js_type_info/src/builders.rs
  • crates/biome_js_type_info/src/format_inferred_type_info.rs
  • crates/biome_js_type_info/src/interned_types.rs
  • crates/biome_js_type_info/src/lib.rs
  • crates/biome_js_type_info/src/local_inference.rs
  • crates/biome_module_graph/Cargo.toml
  • crates/biome_module_graph/benches/type_inference.rs
  • crates/biome_module_graph/src/db/mod.rs
  • crates/biome_module_graph/src/db/queries.rs
  • crates/biome_module_graph/src/db/type_inference/expressions.rs
  • crates/biome_module_graph/src/db/type_inference/globals.rs
  • crates/biome_module_graph/src/db/type_inference/imports.rs
  • crates/biome_module_graph/src/db/type_inference/lookup.rs
  • crates/biome_module_graph/src/db/type_inference/mod.rs
  • crates/biome_module_graph/src/db/type_inference/qualifiers.rs
  • crates/biome_module_graph/src/db/type_inference/resolver.rs
  • crates/biome_module_graph/src/js_module_info.rs
  • crates/biome_module_graph/src/js_module_info/collector.rs
  • crates/biome_module_graph/src/js_module_info/visitor.rs
  • crates/biome_module_graph/src/lib.rs
  • crates/biome_module_graph/src/module_graph.rs
  • crates/biome_module_graph/tests/snap/mod.rs
  • crates/biome_module_graph/tests/spec_tests_v2.rs
  • crates/biome_service/src/workspace/db.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_workspace_db/src/lib.rs

@ematipico

Copy link
Copy Markdown
Member Author

One important thing I forgot. Inside the inference code, I disabled the match wildcard on purpose, because it's very easy to make mistakes. So it's best let the compiler fail when adding a type, so that we're forced in fixing it

@ematipico

Copy link
Copy Markdown
Member Author

Small update: the benchmarks can't be compared in the case of legacy VS new because the new engine works on a pull system. The old system is eager and flatten the types every time, the new system is lazy, and flattening (normalisation) is executed on demand by the rules.

@ematipico
ematipico merged commit 01bba12 into main Jul 12, 2026
38 checks passed
@ematipico
ematipico deleted the refactor/inference-to-salsa branch July 12, 2026 16:45
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 A-Type-Inference Area: type inference L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant