Repository navigation
fix(@angular-devkit/schematics): support delegating trees in filter and partition - #34539
Thanatos9404 wants to merge 3 commits into
Conversation
…ter` rule `filter()` only accepted a `HostTree` and threw "Tree type is not supported." for any other tree. A `UnitTestTree` is a `DelegateTree` around a `HostTree`, so a schematic that uses `filter()` failed in unit tests when run on the tree returned by a previous `runSchematic` call. Unwrap delegating trees and filter the `HostTree` they wrap. Closes angular#26000
There was a problem hiding this comment.
Code Review
This pull request updates the filter rule in Angular Devkit Schematics to support DelegateTree wrappers (such as UnitTestTree) by recursively unwrapping them to access the underlying HostTree. It also adds corresponding unit tests to verify this behavior. The review feedback suggests a minor improvement to type safety by using an intersection cast (DelegateTree & { _other: Tree }) instead of casting to unknown first when accessing the private _other property.
`partition()`, which backs the `partitionApplyMerge` rule, threw "Tree type is not supported." for a `UnitTestTree` and other delegating trees. Branch the tree they wrap instead, as `filter()` does.
filter rulefilter and partition
…ter` rule (#34539) `filter()` only accepted a `HostTree` and threw "Tree type is not supported." for any other tree. A `UnitTestTree` is a `DelegateTree` around a `HostTree`, so a schematic that uses `filter()` failed in unit tests when run on the tree returned by a previous `runSchematic` call. Unwrap delegating trees and filter the `HostTree` they wrap. Closes #26000 PR Close #34539
…on` (angular#34539) `partition()`, which backs the `partitionApplyMerge` rule, threw "Tree type is not supported." for a `UnitTestTree` and other delegating trees. Branch the tree they wrap instead, as `filter()` does. PR Close angular#34539
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
filter()only accepts aHostTreeand throws "Tree type is not supported." for anything else. AUnitTestTreeis aDelegateTreearound aHostTree, so a schematic that usesfilter()fails in unit tests when it runs on the tree returned by an earlierrunSchematiccall.Issue Number: #26000
What is the new behavior?
filter()andpartition()(behindpartitionApplyMerge) callbranch()on a delegating tree first, which returns a branch of theHostTreeit wraps. Other tree types still throw as before.Does this PR introduce a breaking change?
Other information
The new specs in
base_spec.tscoverfilteron a plainHostTree(it had no spec) andfilterandpartitionApplyMergeon a nestedUnitTestTree, sincerunSchematicreturns aUnitTestTreearound another one when the schematic edits its input tree in place. Locally, theUnitTestTreespecs fail onmainwith "Tree type is not supported." and pass with this change, and the 86 specs undersrc/rulesandsrc/treepass (run with jasmine, not Bazel).Closes #26000