Skip to content

Commit fc429c9

Browse files
clydinalan-agius4
authored andcommitted
refactor(@angular-devkit/architect): remove builder option generic json constraint
The `json.JsonObject` generic constraint did not force the options type to be a valid JSON object but required all builders to add the `json.JsonObject` type to all builder option types when calling `createBuilder`.
1 parent 8a805fe commit fc429c9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

etc/api/angular_devkit/architect/src/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface BuilderContext {
2626
validateOptions<T extends json.JsonObject = json.JsonObject>(options: json.JsonObject, builderName: string): Promise<T>;
2727
}
2828

29-
export interface BuilderHandlerFn<A extends json.JsonObject> {
29+
export interface BuilderHandlerFn<A> {
3030
(input: A, context: BuilderContext): BuilderOutputLike;
3131
}
3232

@@ -60,7 +60,7 @@ export interface BuilderRun {
6060
stop(): Promise<void>;
6161
}
6262

63-
export declare function createBuilder<OptT extends json.JsonObject, OutT extends BuilderOutput = BuilderOutput>(fn: BuilderHandlerFn<OptT>): Builder<OptT>;
63+
export declare function createBuilder<OptT = json.JsonObject, OutT extends BuilderOutput = BuilderOutput>(fn: BuilderHandlerFn<OptT>): Builder<OptT & json.JsonObject>;
6464

6565
export declare function fromAsyncIterable<T>(iterable: AsyncIterable<T>): Observable<T>;
6666

packages/angular_devkit/architect/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ async function handleAsyncIterator<T>(
305305
/**
306306
* A builder handler function. The function signature passed to `createBuilder()`.
307307
*/
308-
export interface BuilderHandlerFn<A extends json.JsonObject> {
308+
export interface BuilderHandlerFn<A> {
309309
/**
310310
* Builders are defined by users to perform any kind of task, like building, testing or linting,
311311
* and should use this interface.

packages/angular_devkit/architect/src/create-builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ import { scheduleByName, scheduleByTarget } from './schedule-by-name';
2828

2929
// tslint:disable-next-line: no-big-function
3030
export function createBuilder<
31-
OptT extends json.JsonObject,
31+
OptT = json.JsonObject,
3232
OutT extends BuilderOutput = BuilderOutput,
3333
>(
3434
fn: BuilderHandlerFn<OptT>,
35-
): Builder<OptT> {
35+
): Builder<OptT & json.JsonObject> {
3636
const cjh = experimental.jobs.createJobHandler;
3737
const handler = cjh<json.JsonObject, BuilderInput, OutT>((options, context) => {
3838
const scheduler = context.scheduler;

0 commit comments

Comments
 (0)