Skip to content

Commit fd8b4c8

Browse files
clydinhybrist
authored andcommitted
refactor(@angular-devkit/schematics): update type usage to support isolated declarations
This commit addresses various TypeScript compilation errors that arise when the 'isolatedDeclarations' option is enabled.
1 parent 2d0dc74 commit fd8b4c8

File tree

9 files changed

+24
-21
lines changed

9 files changed

+24
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class NodeModulesTestEngineHost extends NodeModulesEngineHost {
203203
// (undocumented)
204204
protected _resolveCollectionPath(name: string, requester?: string): string;
205205
// (undocumented)
206-
get tasks(): TaskConfiguration<{}>[];
206+
get tasks(): TaskConfiguration[];
207207
// (undocumented)
208208
transformContext(context: FileSystemSchematicContext): FileSystemSchematicContext;
209209
}

packages/angular_devkit/schematics/tasks/repo-init/init-task.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ export interface CommitOptions {
1515
email?: string;
1616
}
1717

18-
export class RepositoryInitializerTask
19-
implements TaskConfigurationGenerator<RepositoryInitializerTaskOptions>
20-
{
18+
export class RepositoryInitializerTask implements TaskConfigurationGenerator<RepositoryInitializerTaskOptions> {
2119
constructor(
22-
public workingDirectory?: string,
23-
public commitOptions?: CommitOptions,
20+
public workingDirectory?: string | undefined,
21+
public commitOptions?: CommitOptions | undefined,
2422
) {}
2523

2624
toConfiguration(): TaskConfiguration<RepositoryInitializerTaskOptions> {

packages/angular_devkit/schematics/testing/schematic-test-runner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { BuiltinTaskExecutor } from '../tasks/node';
2525
import { NodeModulesTestEngineHost, validateOptionsWithSchema } from '../tools';
2626

2727
export class UnitTestTree extends DelegateTree {
28-
get files() {
28+
get files(): string[] {
2929
const result: string[] = [];
3030
this.visit((path) => result.push(path));
3131

@@ -74,7 +74,7 @@ export class SchematicTestRunner {
7474
this._collection = this._engine.createCollection(this._collectionName);
7575
}
7676

77-
get engine() {
77+
get engine(): SchematicEngine<{}, {}> {
7878
return this._engine;
7979
}
8080
get logger(): logging.Logger {
@@ -84,7 +84,7 @@ export class SchematicTestRunner {
8484
return [...this._engineHost.tasks];
8585
}
8686

87-
registerCollection(collectionName: string, collectionPath: string) {
87+
registerCollection(collectionName: string, collectionPath: string): void {
8888
this._engineHost.registerCollection(collectionName, collectionPath);
8989
}
9090

packages/angular_devkit/schematics/tools/export-ref.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ export class ExportStringRef<T> {
2626
}
2727
}
2828

29-
get ref() {
29+
get ref(): T | undefined {
3030
return this._ref;
3131
}
32-
get module() {
32+
get module(): string {
3333
return this._module;
3434
}
35-
get path() {
35+
get path(): string {
3636
return this._path;
3737
}
3838
}

packages/angular_devkit/schematics/tools/fallback-engine-host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class FallbackEngineHost implements EngineHost<{}, {}> {
4141

4242
addHost<CollectionT extends object, SchematicT extends object>(
4343
host: EngineHost<CollectionT, SchematicT>,
44-
) {
44+
): void {
4545
this._hosts.push(host);
4646
}
4747

packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
119119
private _contextTransforms: ContextTransform[] = [];
120120
private _taskFactories = new Map<string, () => Observable<TaskExecutor>>();
121121

122-
listSchematicNames(collection: FileSystemCollectionDesc, includeHidden?: boolean) {
122+
listSchematicNames(collection: FileSystemCollectionDesc, includeHidden?: boolean): string[] {
123123
const schematics: string[] = [];
124124
for (const key of Object.keys(collection.schematics)) {
125125
const schematic = collection.schematics[key];
@@ -140,11 +140,13 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
140140
return schematics;
141141
}
142142

143-
registerOptionsTransform<T extends object | null, R extends object>(t: OptionTransform<T, R>) {
143+
registerOptionsTransform<T extends object | null, R extends object>(
144+
t: OptionTransform<T, R>,
145+
): void {
144146
this._transforms.push(t);
145147
}
146148

147-
registerContextTransform(t: ContextTransform) {
149+
registerContextTransform(t: ContextTransform): void {
148150
this._contextTransforms.push(t);
149151
}
150152

packages/angular_devkit/schematics/tools/file-system-engine-host.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export class FileSystemEngineHost extends FileSystemEngineHostBase {
4848
throw new CollectionCannotBeResolvedException(name);
4949
}
5050

51-
protected _resolveReferenceString(refString: string, parentPath: string) {
51+
protected _resolveReferenceString(
52+
refString: string,
53+
parentPath: string,
54+
): { ref: RuleFactory<{}>; path: string } | null {
5255
// Use the same kind of export strings as NodeModule.
5356
const ref = new ExportStringRef<RuleFactory<{}>>(refString, parentPath);
5457
if (!ref.ref) {

packages/angular_devkit/schematics/tools/node-module-engine-host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
106106
refString: string,
107107
parentPath: string,
108108
collectionDescription?: FileSystemCollectionDesc,
109-
) {
109+
): { ref: RuleFactory<{}>; path: string } | null {
110110
const ref = new ExportStringRef<RuleFactory<{}>>(refString, parentPath);
111111
if (!ref.ref) {
112112
return null;

packages/angular_devkit/schematics/tools/node-modules-test-engine-host.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export class NodeModulesTestEngineHost extends NodeModulesEngineHost {
1818
#collections = new Map<string, string>();
1919
#tasks: TaskConfiguration[] = [];
2020

21-
get tasks() {
21+
get tasks(): TaskConfiguration[] {
2222
return this.#tasks;
2323
}
2424

25-
clearTasks() {
25+
clearTasks(): void {
2626
this.#tasks = [];
2727
}
2828

29-
registerCollection(name: string, path: string) {
29+
registerCollection(name: string, path: string): void {
3030
this.#collections.set(name, path);
3131
}
3232

0 commit comments

Comments
 (0)