Skip to content

Commit 1cd8aa6

Browse files
alan-agius4filipesilva
authored andcommitted
refactor(@angular-devkit/schematics): replace NodePackageInstallTaskOptions class with interface
In this context this is not a breaking change for two reasons. - `NodePackageInstallTaskOptions` is not exported. - `NodePackageInstallTask` is using `NodePackageInstallTaskOptions` with `Partial` type which would cause the Class to become an object literal. This can be seen here: https://github.com/angular/angular-cli/blob/efb97c87f023497dc59a2f4fa3825a2ca78606da/packages/schematics/angular/ng-new/index.ts#L81-L84
1 parent 6885758 commit 1cd8aa6

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

etc/api/angular_devkit/schematics/tasks/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export declare class NodePackageInstallTask implements TaskConfigurationGenerato
44
packageName?: string;
55
quiet: boolean;
66
workingDirectory?: string;
7-
constructor(options: Partial<NodePackageInstallTaskOptions>);
7+
constructor(options: NodePackageInstallTaskOptions);
88
constructor(workingDirectory?: string);
99
toConfiguration(): TaskConfiguration<NodePackageTaskOptions>;
1010
}

packages/angular_devkit/schematics/tasks/package-manager/install-task.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
import { TaskConfiguration, TaskConfigurationGenerator } from '../../src';
99
import { NodePackageName, NodePackageTaskOptions } from './options';
1010

11-
// TODO: This should be an interface but that would change the public API
12-
export class NodePackageInstallTaskOptions {
13-
packageManager!: string;
14-
packageName!: string;
15-
workingDirectory!: string;
16-
quiet!: boolean;
17-
hideOutput!: boolean;
11+
interface NodePackageInstallTaskOptions {
12+
packageManager?: string;
13+
packageName?: string;
14+
workingDirectory?: string;
15+
quiet?: boolean;
16+
hideOutput?: boolean;
1817
}
1918

2019
export class NodePackageInstallTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
@@ -25,8 +24,8 @@ export class NodePackageInstallTask implements TaskConfigurationGenerator<NodePa
2524
packageName?: string;
2625

2726
constructor(workingDirectory?: string);
28-
constructor(options: Partial<NodePackageInstallTaskOptions>);
29-
constructor(options?: string | Partial<NodePackageInstallTaskOptions>) {
27+
constructor(options: NodePackageInstallTaskOptions);
28+
constructor(options?: string | NodePackageInstallTaskOptions) {
3029
if (typeof options === 'string') {
3130
this.workingDirectory = options;
3231
} else if (typeof options === 'object') {

0 commit comments

Comments
 (0)