Skip to content

Commit 3f78080

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular-devkit/schematics): adjust types to support strict mode
1 parent 2dada50 commit 3f78080

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ export class SchematicImpl<CollectionT extends object, SchematicT extends object
5656
.pipe(
5757
first(),
5858
concatMap(tree => this._engine.transformOptions(this, options, context).pipe(
59-
map(o => [tree, o]),
59+
map(o => [tree, o] as [Tree, OptionT]),
6060
)),
61-
concatMap(([tree, transformedOptions]: [Tree, OptionT]) => {
61+
concatMap(([tree, transformedOptions]) => {
6262
let input: Tree;
6363
let scoped = false;
6464
if (executionOptions && executionOptions.scope) {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ export function empty(): Source {
3434
*/
3535
export function chain(rules: Rule[]): Rule {
3636
return (tree, context) => {
37-
return rules.reduce(
38-
(acc: Tree | Observable<Tree>, curr: Rule) => callRule(curr, acc, context),
39-
tree,
40-
);
37+
return rules.reduce<Tree | Observable<Tree>>((acc, curr) => callRule(curr, acc, context), tree);
4138
};
4239
}
4340

packages/angular_devkit/schematics/tasks/node/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { TaskExecutorFactory } from '../../src';
8+
import { TaskExecutor, TaskExecutorFactory } from '../../src';
99
import { NodePackageName, NodePackageTaskFactoryOptions } from '../package-manager/options';
1010
import {
1111
RepositoryInitializerName,
@@ -17,7 +17,7 @@ import { TslintFixName } from '../tslint-fix/options';
1717
export class BuiltinTaskExecutor {
1818
static readonly NodePackage: TaskExecutorFactory<NodePackageTaskFactoryOptions> = {
1919
name: NodePackageName,
20-
create: (options) => import('../package-manager/executor').then(mod => mod.default(options)),
20+
create: (options) => import('../package-manager/executor').then(mod => mod.default(options)) as Promise<TaskExecutor<{}>>,
2121
};
2222
static readonly RepositoryInitializer:
2323
TaskExecutorFactory<RepositoryInitializerTaskFactoryOptions> = {
@@ -26,7 +26,7 @@ export class BuiltinTaskExecutor {
2626
};
2727
static readonly RunSchematic: TaskExecutorFactory<{}> = {
2828
name: RunSchematicName,
29-
create: () => import('../run-schematic/executor').then(mod => mod.default()),
29+
create: () => import('../run-schematic/executor').then(mod => mod.default()) as Promise<TaskExecutor<{}>>,
3030
};
3131
static readonly TslintFix: TaskExecutorFactory<{}> = {
3232
name: TslintFixName,

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
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
1112
export class NodePackageInstallTaskOptions {
12-
packageManager: string;
13-
packageName: string;
14-
workingDirectory: string;
15-
quiet: boolean;
16-
hideOutput: boolean;
13+
packageManager!: string;
14+
packageName!: string;
15+
workingDirectory!: string;
16+
quiet!: boolean;
17+
hideOutput!: boolean;
1718
}
1819

1920
export class NodePackageInstallTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {

0 commit comments

Comments
 (0)