-
-
Notifications
You must be signed in to change notification settings - Fork 794
fix(analyze/types): reduce created types when flattening a static member access on a union type #8536
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
Conversation
π¦ Changeset detectedLatest commit: 32e3fc6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis patch fixes runaway type growth when resolving static members on union types (issue Suggested reviewers
Pre-merge checks and finishing touchesβ Passed checks (4 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
crates/biome_js_type_info/src/flattening/expressions.rs (1)
267-293: Solid fix for the runaway type growth issue.The approach of directly resolving each variant and collecting member references is the right call β it avoids the exponential wrapper growth that plagued the previous implementation. Per the retrieved learnings,
flattened_union_variants()already returnsTypeReferenceinstances with correct module IDs, so using them directly is appropriate.One optional simplification: the
TypeData::Referencewrapper on line 284-286 adds an indirection level. Sincemember.deref_ty(resolver)already yields aTypeReference, you could push it directly:π Optional simplification
if let Some(member) = member_opt { - let type_ref = resolver.reference_to_owned_data( - TypeData::Reference(member.deref_ty(resolver).into_owned()), - ); - types.push(type_ref); + types.push(member.deref_ty(resolver).into_owned()); }If the extra storage step is intentional (e.g., to ensure the type is registered in the resolver for later lookups), please disregard β the current implementation works correctly either way.
π Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
β Files ignored due to path filters (1)
crates/biome_js_type_info/tests/snapshots/infer_flattened_type_of_static_member_on_union.snapis excluded by!**/*.snapand included by**
π Files selected for processing (3)
.changeset/union-static-member-resolution.md(1 hunks)crates/biome_js_type_info/src/flattening/expressions.rs(2 hunks)crates/biome_js_type_info/tests/flattening.rs(1 hunks)
π§° Additional context used
π Path-based instructions (4)
crates/biome_js_type_info/**/*.rs
π CodeRabbit inference engine (crates/biome_js_type_info/CONTRIBUTING.md)
crates/biome_js_type_info/**/*.rs: No module may copy or clone data from another module in the module graph, not even behind anArc
UseTypeReferenceinstead ofArcfor types that reference other types to avoid stale cache issues when modules are replaced
Store type data in linear vectors instead of using recursive data structures withArcfor improved data locality and performance
UseTypeReferencevariants (Qualifier,Resolved,Import,Unknown) to represent different phases of type resolution
UseTypeData::Unknownto indicate when type inference falls short or is not implemented
Distinguish betweenTypeData::UnknownandTypeData::UnknownKeywordto measure inference effectiveness versus explicit user-provided unknown types
When usingResolvedTypeData, track theResolverIdto ensure subsequent resolver calls use the correct context
Always apply the correctResolverIdwhen retrieving raw type data fromResolvedTypeData.as_raw_data()to prevent panics during subsequent resolution calls
Files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
crates/biome_js_type_info/**/flattening.rs
π CodeRabbit inference engine (crates/biome_js_type_info/CONTRIBUTING.md)
Implement type flattening to simplify
TypeofExpressionvariants once all component types are resolved
Files:
crates/biome_js_type_info/tests/flattening.rs
crates/**/*.rs
π CodeRabbit inference engine (CONTRIBUTING.md)
Update inline rustdoc documentation for rules, assists, and their options when adding new features or changing existing features in Rust crates
Files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
.changeset/*.md
π CodeRabbit inference engine (CONTRIBUTING.md)
Write changesets that are concise (1-3 sentences), user-focused, use past tense for actions taken and present tense for Biome behavior, include code examples for rules, and end sentences with periods
Files:
.changeset/union-static-member-resolution.md
π§ Learnings (14)
π Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `declare_node_union!` macro to query multiple node types at once
Learnt from: arendjr
Repo: biomejs/biome PR: 7266
File: crates/biome_js_type_info/src/type.rs:94-102
Timestamp: 2025-08-20T16:24:59.781Z
Learning: In crates/biome_js_type_info/src/type.rs, the flattened_union_variants() method returns TypeReference instances that already have the correct module IDs applied to them. These references should be used directly with resolver.resolve_reference() without applying additional module ID transformations, as variant references may originate from nested unions in different modules.
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/flattening.rs : Implement type flattening to simplify `TypeofExpression` variants once all component types are resolved
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/flattening.rs : Implement type flattening to simplify `TypeofExpression` variants once all component types are resolved
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `declare_node_union!` macro to query multiple node types at once
Applied to files:
crates/biome_js_type_info/tests/flattening.rs
π Learning: 2025-08-20T16:24:59.781Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7266
File: crates/biome_js_type_info/src/type.rs:94-102
Timestamp: 2025-08-20T16:24:59.781Z
Learning: In crates/biome_js_type_info/src/type.rs, the flattened_union_variants() method returns TypeReference instances that already have the correct module IDs applied to them. These references should be used directly with resolver.resolve_reference() without applying additional module ID transformations, as variant references may originate from nested unions in different modules.
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeData::Unknown` to indicate when type inference falls short or is not implemented
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/scoped_resolver.rs : Implement full inference to resolve `TypeReference::Import` variants across the entire module graph
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/local_inference.rs : Implement local inference in dedicated modules to derive type definitions from expressions without context of surrounding scopes
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Store type data in linear vectors instead of using recursive data structures with `Arc` for improved data locality and performance
Applied to files:
crates/biome_js_type_info/tests/flattening.rscrates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-12-12T10:11:05.564Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-12T10:11:05.564Z
Learning: Create a changeset for user-facing bug fixes and features using `just new-changeset`, selecting appropriate packages and change type (`major`, `minor`, or `patch`)
Applied to files:
.changeset/union-static-member-resolution.md
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` variants (`Qualifier`, `Resolved`, `Import`, `Unknown`) to represent different phases of type resolution
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : When using `ResolvedTypeData`, track the `ResolverId` to ensure subsequent resolver calls use the correct context
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
𧬠Code graph analysis (1)
crates/biome_js_type_info/tests/flattening.rs (3)
crates/biome_js_type_info/tests/utils.rs (3)
get_interface_declaration(256-270)get_expression(224-238)assert_type_data_snapshot(22-55)crates/biome_js_type_info/src/local_inference.rs (1)
from_ts_interface_declaration(1216-1242)crates/biome_js_type_info/src/helpers.rs (1)
union_of(268-320)
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: End-to-end tests
- GitHub Check: Check Dependencies
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test Node.js API
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: autofix
π Additional comments (3)
crates/biome_js_type_info/src/flattening/expressions.rs (1)
11-11: Good cleanup.Removing the unused
TypeofStaticMemberExpressionimport aligns with the refactored approach below..changeset/union-static-member-resolution.md (1)
1-5: Changeset looks good.Concise, user-focused, and properly links to the issue. Nice work keeping it clear without being overly technical.
crates/biome_js_type_info/tests/flattening.rs (1)
11-49: Good regression test.The test directly exercises the problematic code path that caused runaway type growth. The setup mirrors real-world patterns (union with nullable interface, recursive property access) and the snapshot assertion will catch any regressions.
One minor note: the inline comment (lines 13-16) is helpful context β future maintainers will thank you.
CodSpeed Performance ReportMerging #8536 will not alter performanceComparing Summary
Footnotes
|
ematipico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
β¦ber access on a union type
47989cc to
32e3fc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
crates/biome_js_type_info/src/flattening/expressions.rs (1)
267-293: Solid fix for the runaway type creation issue.The approach of resolving each variant directly and collecting member type references is much more efficient than the previous
TypeofExpressionwrapper approach. The logic correctly handles the edge cases viaunion_of.One minor observation on lines 284-286: you're wrapping an already-dereferenced
TypeReferenceinTypeData::Reference(...)before registering it. Consider whether you could pushmember.deref_ty(resolver).into_owned()directly:π Potential simplification
if let Some(member) = member_opt { - let type_ref = resolver.reference_to_owned_data( - TypeData::Reference(member.deref_ty(resolver).into_owned()), - ); + let type_ref = member.deref_ty(resolver).into_owned(); types.push(type_ref); }If the
reference_to_owned_datacall is intentional for module ID normalisation or deduplication, feel free to disregardβjust wanted to flag it. Based on coding guidelines, ensure theResolverIdcontext is correctly tracked when working withResolvedTypeData.
π Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
β Files ignored due to path filters (1)
crates/biome_js_type_info/tests/snapshots/infer_flattened_type_of_static_member_on_union.snapis excluded by!**/*.snapand included by**
π Files selected for processing (3)
.changeset/union-static-member-resolution.md(1 hunks)crates/biome_js_type_info/src/flattening/expressions.rs(2 hunks)crates/biome_js_type_info/tests/flattening.rs(1 hunks)
π§ Files skipped from review as they are similar to previous changes (1)
- crates/biome_js_type_info/tests/flattening.rs
π§° Additional context used
π Path-based instructions (2)
crates/biome_js_type_info/**/*.rs
π CodeRabbit inference engine (crates/biome_js_type_info/CONTRIBUTING.md)
crates/biome_js_type_info/**/*.rs: No module may copy or clone data from another module in the module graph, not even behind anArc
UseTypeReferenceinstead ofArcfor types that reference other types to avoid stale cache issues when modules are replaced
Store type data in linear vectors instead of using recursive data structures withArcfor improved data locality and performance
UseTypeReferencevariants (Qualifier,Resolved,Import,Unknown) to represent different phases of type resolution
UseTypeData::Unknownto indicate when type inference falls short or is not implemented
Distinguish betweenTypeData::UnknownandTypeData::UnknownKeywordto measure inference effectiveness versus explicit user-provided unknown types
When usingResolvedTypeData, track theResolverIdto ensure subsequent resolver calls use the correct context
Always apply the correctResolverIdwhen retrieving raw type data fromResolvedTypeData.as_raw_data()to prevent panics during subsequent resolution calls
Files:
crates/biome_js_type_info/src/flattening/expressions.rs
**/*.rs
π CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use thedbg!()macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests
Files:
crates/biome_js_type_info/src/flattening/expressions.rs
π§ Learnings (14)
π Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `declare_node_union!` macro to query multiple node types at once
π Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `declare_node_union!` macro to query multiple node types at once
Applied to files:
.changeset/union-static-member-resolution.md
π Learning: 2025-12-21T21:15:03.782Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.782Z
Learning: Changesets should describe user-facing changes only; internal refactoring without behavior changes does not require a changeset
Applied to files:
.changeset/union-static-member-resolution.md
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/flattening.rs : Implement type flattening to simplify `TypeofExpression` variants once all component types are resolved
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-08-20T16:24:59.781Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7266
File: crates/biome_js_type_info/src/type.rs:94-102
Timestamp: 2025-08-20T16:24:59.781Z
Learning: In crates/biome_js_type_info/src/type.rs, the flattened_union_variants() method returns TypeReference instances that already have the correct module IDs applied to them. These references should be used directly with resolver.resolve_reference() without applying additional module ID transformations, as variant references may originate from nested unions in different modules.
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` variants (`Qualifier`, `Resolved`, `Import`, `Unknown`) to represent different phases of type resolution
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/scoped_resolver.rs : Implement full inference to resolve `TypeReference::Import` variants across the entire module graph
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Store type data in linear vectors instead of using recursive data structures with `Arc` for improved data locality and performance
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/local_inference.rs : Implement local inference in dedicated modules to derive type definitions from expressions without context of surrounding scopes
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeData::Unknown` to indicate when type inference falls short or is not implemented
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
π Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : When using `ResolvedTypeData`, track the `ResolverId` to ensure subsequent resolver calls use the correct context
Applied to files:
crates/biome_js_type_info/src/flattening/expressions.rs
𧬠Code graph analysis (1)
crates/biome_js_type_info/src/flattening/expressions.rs (2)
crates/biome_js_type_info/src/type_data.rs (6)
types(659-661)types(1533-1535)new(40-44)new(1457-1461)new(1492-1502)ty(566-571)crates/biome_js_type_info/src/helpers.rs (1)
union_of(268-320)
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Check Dependencies
- GitHub Check: End-to-end tests
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Documentation
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: autofix
π Additional comments (2)
.changeset/union-static-member-resolution.md (1)
1-5: LGTM!Clear, user-facing description that explains the fix without exposing internal implementation details. Correctly references the linked issue.
crates/biome_js_type_info/src/flattening/expressions.rs (1)
10-11: Import cleanup aligns with the fix.Removing
TypeofStaticMemberExpressionfrom imports is consistent with the change to resolve union variants directly rather than wrapping them.
Summary
The root cause was that during type flattening, when a static member was accessed on a union type eg.
node.parentNode(see the snapshot test to get a better idea of what I'm talking about), it would continuously create new types over and over. As a result, it would hit the type limit, and emit the diagnostic.I have no idea if this is the "correct" fix, since I'm not super familiar with this area of the codebase. I used AI quite heavily here to do the initial instrumentation, draft the fix, and write the test.
fixes #8527
Test Plan
I created a test that showed the behavior on
main, and then switched to this branch to make sure the snapshot output changed.Docs