Skip to content

Commit 8b613c8

Browse files
committed
refactor(@angular-devkit/schematics): initial isolated declarations type adjustments
Several type only changes have been made to the schematics code to support the eventual compilation of the package with TypeScript's `isolatedDeclarations` option. This is not yet comprehensive and more changes will be needed to fully support the option.
1 parent 42811d8 commit 8b613c8

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

goldens/public-api/angular_devkit/schematics/index.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ export type CollectionDescription<CollectionMetadataT extends object> = Collecti
170170

171171
// @public (undocumented)
172172
export class CollectionImpl<CollectionT extends object, SchematicT extends object> implements Collection<CollectionT, SchematicT> {
173-
constructor(_description: CollectionDescription<CollectionT>, _engine: SchematicEngine<CollectionT, SchematicT>, baseDescriptions?: Array<CollectionDescription<CollectionT>> | undefined);
173+
constructor(_description: CollectionDescription<CollectionT>, _engine: SchematicEngine<CollectionT, SchematicT>, baseDescriptions?: CollectionDescription<CollectionT>[] | undefined);
174174
// (undocumented)
175-
readonly baseDescriptions?: Array<CollectionDescription<CollectionT>> | undefined;
175+
readonly baseDescriptions?: CollectionDescription<CollectionT>[] | undefined;
176176
// (undocumented)
177177
createSchematic(name: string, allowPrivate?: boolean): Schematic<CollectionT, SchematicT>;
178178
// (undocumented)

packages/angular_devkit/schematics/src/engine/engine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class CollectionImpl<CollectionT extends object, SchematicT extends objec
8787
constructor(
8888
private _description: CollectionDescription<CollectionT>,
8989
private _engine: SchematicEngine<CollectionT, SchematicT>,
90-
public readonly baseDescriptions?: Array<CollectionDescription<CollectionT>>,
90+
public readonly baseDescriptions?: CollectionDescription<CollectionT>[] | undefined,
9191
) {}
9292

9393
get description(): CollectionDescription<CollectionT> {
@@ -180,7 +180,7 @@ export class SchematicEngine<CollectionT extends object, SchematicT extends obje
180180

181181
constructor(
182182
private _host: EngineHost<CollectionT, SchematicT>,
183-
protected _workflow?: Workflow,
183+
protected _workflow?: Workflow | undefined,
184184
) {}
185185

186186
get workflow(): Workflow | null {

packages/angular_devkit/schematics/src/rules/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function asSource(rule: Rule): Source {
8686
return (context) => callRule(rule, staticEmpty(), context);
8787
}
8888

89-
export function branchAndMerge(rule: Rule, strategy = MergeStrategy.Default): Rule {
89+
export function branchAndMerge(rule: Rule, strategy: MergeStrategy = MergeStrategy.Default): Rule {
9090
return (tree, context) => {
9191
return callRule(rule, tree.branch(), context).pipe(
9292
map((branch) => tree.merge(branch, strategy || context.strategy)),

packages/angular_devkit/schematics/src/rules/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { FileOperator, Rule } from '../engine/interface';
1212
import { FileEntry } from '../tree/interface';
1313
import { chain, composeFileOperators, forEach, when } from './base';
1414

15-
export const TEMPLATE_FILENAME_RE = /\.template$/;
15+
export const TEMPLATE_FILENAME_RE: RegExp = /\.template$/;
1616

1717
export class OptionIsNotDefinedException extends BaseException {
1818
constructor(name: string) {

packages/angular_devkit/schematics/src/sink/dryrun.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ export type DryRunEvent =
4444
| DryRunRenameEvent;
4545

4646
export class DryRunSink extends HostSink {
47-
protected _subject = new Subject<DryRunEvent>();
48-
protected _fileDoesNotExistExceptionSet = new Set<string>();
49-
protected _fileAlreadyExistExceptionSet = new Set<string>();
47+
protected _subject: Subject<DryRunEvent> = new Subject();
48+
protected _fileDoesNotExistExceptionSet: Set<string> = new Set();
49+
protected _fileAlreadyExistExceptionSet: Set<string> = new Set();
5050

5151
readonly reporter: Observable<DryRunEvent> = this._subject.asObservable();
5252

@@ -72,7 +72,7 @@ export class DryRunSink extends HostSink {
7272
this._fileDoesNotExistExceptionSet.add(path);
7373
}
7474

75-
override _done() {
75+
override _done(): Observable<void> {
7676
this._fileAlreadyExistExceptionSet.forEach((path) => {
7777
this._subject.next({
7878
kind: 'error',

packages/angular_devkit/schematics/src/sink/host.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import { CreateFileAction } from '../tree/action';
2020
import { SimpleSinkBase } from './sink';
2121

2222
export class HostSink extends SimpleSinkBase {
23-
protected _filesToDelete = new Set<Path>();
24-
protected _filesToRename = new Set<[Path, Path]>();
25-
protected _filesToCreate = new Map<Path, Buffer>();
26-
protected _filesToUpdate = new Map<Path, Buffer>();
23+
protected _filesToDelete: Set<Path> = new Set();
24+
protected _filesToRename: Set<[Path, Path]> = new Set();
25+
protected _filesToCreate: Map<Path, Buffer<ArrayBufferLike>> = new Map();
26+
protected _filesToUpdate: Map<Path, Buffer<ArrayBufferLike>> = new Map();
2727

2828
constructor(
2929
protected _host: virtualFs.Host,

packages/angular_devkit/schematics/src/tree/recorder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ContentHasMutatedException } from '../exception/exception';
1212
import { FileEntry, UpdateRecorder } from './interface';
1313

1414
export class IndexOutOfBoundException extends BaseException {
15-
constructor(index: number, min: number, max = Infinity) {
15+
constructor(index: number, min: number, max: number = Infinity) {
1616
super(`Index ${index} outside of range [${min}, ${max}].`);
1717
}
1818
}

0 commit comments

Comments
 (0)