Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions goldens/public-api/angular_devkit/schematics/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,16 @@ export interface CreateFileAction extends ActionBase {
readonly kind: 'c';
}

// @public (undocumented)
export interface DelegateTree {
// (undocumented)
[TreeSymbol](): DelegateTree;
}

// @public (undocumented)
export class DelegateTree implements Tree_2 {
// (undocumented)
[TreeSymbol]: () => this;
[TreeSymbol]: () => DelegateTree;
constructor(_other: Tree_2);
// (undocumented)
get actions(): Action[];
Expand Down Expand Up @@ -516,10 +522,16 @@ export class HostSink extends SimpleSinkBase {
protected _validateFileExists(p: Path): Observable<boolean>;
}

// @public (undocumented)
export interface HostTree {
// (undocumented)
[TreeSymbol](): HostTree;
}

// @public (undocumented)
export class HostTree implements Tree_2 {
// (undocumented)
[TreeSymbol]: () => this;
[TreeSymbol]: () => HostTree;
constructor(_backend?: virtualFs.ReadonlyHost<{}>);
// (undocumented)
get actions(): Action[];
Expand Down
16 changes: 11 additions & 5 deletions packages/angular_devkit/schematics/src/tree/delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ import {
UpdateRecorder,
} from './interface';

// Workaround for "error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."
// When this is fixed within TypeScript, the method can be added back directly to the class.
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export interface DelegateTree {
[TreeSymbol](): DelegateTree;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class DelegateTree implements Tree {
constructor(protected _other: Tree) {}
constructor(protected _other: Tree) {
this[TreeSymbol] = () => this;
}

branch(): Tree {
return this._other.branch();
Expand Down Expand Up @@ -83,8 +93,4 @@ export class DelegateTree implements Tree {
get actions(): Action[] {
return this._other.actions;
}

[TreeSymbol]() {
return this;
}
}
13 changes: 9 additions & 4 deletions packages/angular_devkit/schematics/src/tree/host-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export class HostDirEntry implements DirEntry {
}
}

// Workaround for "error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."
// When this is fixed within TypeScript, the method can be added back directly to the class.
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export interface HostTree {
[TreeSymbol](): HostTree;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class HostTree implements Tree {
private readonly _id = --_uniqueId;
private _record: virtualFs.CordHost;
Expand All @@ -106,10 +114,6 @@ export class HostTree implements Tree {

private _dirCache = new Map<Path, HostDirEntry>();

[TreeSymbol](): this {
return this;
}

static isHostTree(tree: Tree): tree is HostTree {
if (tree instanceof HostTree) {
return true;
Expand All @@ -123,6 +127,7 @@ export class HostTree implements Tree {
}

constructor(protected _backend: virtualFs.ReadonlyHost<{}> = new virtualFs.Empty()) {
this[TreeSymbol] = () => this;
this._record = new virtualFs.CordHost(new virtualFs.SafeReadonlyHost(_backend));
this._recordSync = new virtualFs.SyncDelegateHost(this._record);
}
Expand Down
12 changes: 10 additions & 2 deletions packages/angular_devkit/schematics/src/tree/null.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ export class NullTreeDirEntry implements DirEntry {
visit(): void {}
}

// Workaround for "error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."
// When this is fixed within TypeScript, the method can be added back directly to the class.
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export interface NullTree {
[TreeSymbol](): NullTree;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class NullTree implements Tree {
[TreeSymbol](): this {
return this;
constructor() {
this[TreeSymbol] = () => this;
}

branch(): Tree {
Expand Down
13 changes: 9 additions & 4 deletions packages/angular_devkit/schematics/src/tree/scoped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,22 @@ class ScopedDirEntry implements DirEntry {
}
}

// Workaround for "error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."
// When this is fixed within TypeScript, the method can be added back directly to the class.
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export interface ScopedTree {
[TreeSymbol](): ScopedTree;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class ScopedTree implements Tree {
readonly _root: ScopedDirEntry;

constructor(
private _base: Tree,
scope: string,
) {
this[TreeSymbol] = () => this;
const normalizedScope = normalize('/' + scope);
this._root = new ScopedDirEntry(this._base.getDir(normalizedScope), normalizedScope);
}
Expand Down Expand Up @@ -197,10 +206,6 @@ export class ScopedTree implements Tree {
return scopedActions;
}

[TreeSymbol](): this {
return this;
}

private _fullPath(path: string): Path {
return join(this._root.scope, normalize('/' + path));
}
Expand Down
Loading