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

  1. Ensure the tree passed to partition is a HostTree (or FilterHostTree, which extends it)
  2. For DelegateTree, extract and partition the underlying host tree (tree.branch() results or the wrapped host)
  3. Implement the partition yourself for custom trees: build two FilterHostTrees from the base HostTree
  4. 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

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


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/992a79ad59b45832. Report an issue: GitHub.