GeezerVison is showing github.com — fix(@angular-devkit/schematics): support delegating trees in `filter` and `partition` by Thanatos9404 · Pull Request #34539 · angular/angular-cli
Conversation
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
- Bugfix
- Feature
- Code style update (formatting, local variables)
- Refactoring (no functional changes, no api changes)
- Build related changes
- CI related changes
- Documentation content changes
- Other... Please describe:
What is the current behavior?
filter() only accepts a HostTree and throws "Tree type is not supported." for anything else. A UnitTestTree is a DelegateTree around a HostTree, so a schematic that uses filter() fails in unit tests when it runs on the tree returned by an earlier runSchematic call.
Issue Number: #26000
What is the new behavior?
filter() and partition() (behind partitionApplyMerge) call branch() on a delegating tree first, which returns a branch of the HostTree it wraps. Other tree types still throw as before.
Does this PR introduce a breaking change?
Other information
The new specs in base_spec.ts cover filter on a plain HostTree (it had no spec) and filter and partitionApplyMerge on a nested UnitTestTree, since runSchematic returns a UnitTestTree around another one when the schematic edits its input tree in place. Locally, the UnitTestTree specs fail on main with "Tree type is not supported." and pass with this change, and the 86 specs under src/rules and src/tree pass (run with jasmine, not Bazel).
Closes #26000
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gemini-code-assist[bot] reacted with eyes emoji
…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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
`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.
Thanatos9404
changed the title
fix(@angular-devkit/schematics): support delegating trees in the filter rule
fix(@angular-devkit/schematics): support delegating trees in filter and partition
Oct 27, 2026
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR was merged into the repository. The changes were merged into the following branches:
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
alan-agius4
pushed a commit
that referenced
this pull request
Oct 27, 2026
…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
alan-agius4
pushed a commit
that referenced
this pull request
Oct 27, 2026
…on` (#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 #34539
angular-robot
pushed a commit
to angular-robot/angular-cli
that referenced
this pull request
Oct 27, 2026
…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
Reviewers
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|