Skip to content

Commit 464cf33

Browse files
ddubravaalan-agius4
authored andcommitted
feat(@angular-devkit/schematics): support null for options parameter from OptionTransform type
1 parent 78460e9 commit 464cf33

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Diff for: goldens/public-api/angular_devkit/schematics/tools/index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost_2
117117
// (undocumented)
118118
registerContextTransform(t: ContextTransform): void;
119119
// (undocumented)
120-
registerOptionsTransform<T extends object, R extends object>(t: OptionTransform<T, R>): void;
120+
registerOptionsTransform<T extends object | null, R extends object>(t: OptionTransform<T, R>): void;
121121
// (undocumented)
122122
registerTaskExecutor<T>(factory: TaskExecutorFactory<T>, options?: T): void;
123123
// (undocumented)
@@ -235,7 +235,7 @@ export interface NodeWorkflowOptions {
235235
// (undocumented)
236236
force?: boolean;
237237
// (undocumented)
238-
optionTransforms?: OptionTransform<object, object>[];
238+
optionTransforms?: OptionTransform<Record<string, unknown> | null, object>[];
239239
// (undocumented)
240240
packageManager?: string;
241241
// (undocumented)
@@ -251,7 +251,7 @@ export interface NodeWorkflowOptions {
251251
}
252252

253253
// @public (undocumented)
254-
export type OptionTransform<T extends object, R extends object> = (schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable<R> | PromiseLike<R> | R;
254+
export type OptionTransform<T extends object | null, R extends object> = (schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable<R> | PromiseLike<R> | R;
255255

256256
// @public (undocumented)
257257
export class SchematicMissingDescriptionException extends BaseException {
@@ -274,7 +274,7 @@ export class SchematicNameCollisionException extends BaseException {
274274
}
275275

276276
// @public (undocumented)
277-
export function validateOptionsWithSchema(registry: schema.SchemaRegistry): <T extends {}>(schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext | undefined) => Observable<T>;
277+
export function validateOptionsWithSchema(registry: schema.SchemaRegistry): <T extends {} | null>(schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext | undefined) => Observable<T>;
278278

279279
// (No @packageDocumentation comment for this package)
280280

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from './description';
3030
import { readJsonFile } from './file-system-utility';
3131

32-
export declare type OptionTransform<T extends object, R extends object> = (
32+
export declare type OptionTransform<T extends object | null, R extends object> = (
3333
schematic: FileSystemSchematicDescription,
3434
options: T,
3535
context?: FileSystemSchematicContext,
@@ -140,7 +140,7 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
140140
return schematics;
141141
}
142142

143-
registerOptionsTransform<T extends object, R extends object>(t: OptionTransform<T, R>) {
143+
registerOptionsTransform<T extends object | null, R extends object>(t: OptionTransform<T, R>) {
144144
this._transforms.push(t);
145145
}
146146

Diff for: packages/angular_devkit/schematics/tools/schema-option-transform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class InvalidInputOptions<T = {}> extends schema.SchemaValidationExceptio
2222

2323
// This can only be used in NodeJS.
2424
export function validateOptionsWithSchema(registry: schema.SchemaRegistry) {
25-
return <T extends {}>(
25+
return <T extends {} | null>(
2626
schematic: FileSystemSchematicDescription,
2727
options: T,
2828
context?: FileSystemSchematicContext,

Diff for: packages/angular_devkit/schematics/tools/workflow/node-workflow.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface NodeWorkflowOptions {
2424
registry?: schema.CoreSchemaRegistry;
2525
resolvePaths?: string[];
2626
schemaValidation?: boolean;
27-
optionTransforms?: OptionTransform<object, object>[];
27+
optionTransforms?: OptionTransform<Record<string, unknown> | null, object>[];
2828
engineHostCreator?: (options: NodeWorkflowOptions) => NodeModulesEngineHost;
2929
}
3030

0 commit comments

Comments
 (0)