angular/angular-cli · error · SchematicsException
Tree type is not supported.
Error message
Tree type is not supported.
What it means
partition() only knows how to split a HostTree into two FilterHostTree halves (kept/filtered). If the tree instance is any other Tree implementation, it throws SchematicsException('Tree type is not supported.') because filtered views can't be built generically.
Source
Thrown at packages/angular_devkit/schematics/src/tree/static.ts:38
export function merge(
tree: Tree,
other: Tree,
strategy: MergeStrategy = MergeStrategy.Default,
): Tree {
tree.merge(other, strategy);
return tree;
}
export function partition(tree: Tree, predicate: FilePredicate<boolean>): [Tree, Tree] {
if (tree instanceof HostTree) {
return [
new FilterHostTree(tree, predicate),
new FilterHostTree(tree, (path, entry) => !predicate(path, entry)),
];
} else {
throw new SchematicsException('Tree type is not supported.');
}
}
View on GitHub (pinned to bb72145f9a)
Solutions
- Ensure the tree passed to partition is a HostTree (or FilterHostTree, which extends it)
- For DelegateTree, extract and partition the underlying host tree (tree.branch() results or the wrapped host)
- Implement the partition yourself for custom trees: build two FilterHostTrees from the base HostTree
- In tests, use unit tree utilities from @angular-devkit/schematics (e.g. new HostTree(new virtualFs.SimpleMemoryHost())) instead of hand-rolled stubs
Example fix
// before
return partition(myCustomTree as Tree, predicate);
// after
import { HostTree } from '@angular-devkit/schematics';
if (!(myCustomTree instanceof HostTree)) {
throw new Error('partition requires a HostTree');
}
return partition(myCustomTree, predicate); Defensive patterns
Strategy: type-guard
Validate before calling
if (!(tree instanceof HostTree)) {
throw new Error('partition() requires a HostTree');
}
const [kept, rest] = partition(tree, predicate); Type guard
import { HostTree } from '@angular-devkit/schematics';
function isHostTree(t: unknown): t is HostTree {
return t instanceof HostTree;
} Try / catch
try {
const parts = partition(tree, predicate);
} catch (e) {
if (String(e).includes('Tree type is not supported')) {
// fall back to manual filtering on tree.getDir('/').visit(...)
} else throw e;
} Prevention
- Only construct trees via HostTree/virtual-fs utilities in tooling
- Unwrap DelegateTree before calling partition
- Avoid hand-rolled Tree implementations in tests; use the library's testing utils
- Type parameters as HostTree when the API requires it so mistakes surface at compile time
When it happens
Trigger: Calling partition(tree, predicate) with a custom Tree implementation (not instanceof HostTree), e.g. a DelegateTree wrapper, a test stub implementing Tree, or a tree from a custom engine host.
Common situations: Custom schematic tooling or testing utilities that pass mock trees into partition; wrapping trees in custom Tree classes for instrumentation; third-party tree implementations incompatible with HostTree.
Related errors
- Option "project" is required.
- Project is not defined in this workspace.
- Targets are not defined for this project.
- The 'getPrerenderParams' function defined for the '${stripLe
- Tree type is not supported.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/992a79ad59b45832.
Report an issue: GitHub.