Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update on "[compiler] Infer optional dependencies (behind feature flag)"
Adds a new feature flag, `enableOptionalDependencies` which when enabled allows PropagateScopeDeps and DeriveMinimalDeps to infer optional dependency paths (`a?.b`). In PropagateScopeDeps we look for specific safe patterns of nested optional member expressions: * `<variable> "." / "?." <property>` * or `<nested> "." / "?." <property>` When we find this pattern we record a dependency on the overall chain, so for example in `a?.b.c?.d.map()` we would record a dependency on `a?.b.c?.d` (because the outer `.map()` portion doesn't match the above structure). If the structure doesn't match - for example with `a?.b?.[foo(bar)]?.z` - then we fall back to the existing behavior which treats everything after the initial portion as conditional (for that last example we'd continue to record `a` as the dep). The other portion is DeriveMinimalDeps, which now represents optional access/dependency states and updates the merge logic to handle them. The order of precedence is unconditional > optional > conditional. Note: the flag is off by default, but i tried enabling it for all fixtures and the results were all either unchanged or had correct optional deps inferred. I'll also try running it internally with the flag enabled, but i think we can proceed with review and fix-forward any issues identified from that testing. [ghstack-poisoned]
- Loading branch information