Skip to content

Commit 2230374

Browse files
gunanalan-agius4
authored andcommitted
refactor: remove add implicate types for better code readability
When strictNullChecks in enabled in TS compiler, the following files cause some failures in certain environments. Fix these failures. Also update outdated goldens.
1 parent cdf78d4 commit 2230374

File tree

9 files changed

+13
-13
lines changed

9 files changed

+13
-13
lines changed

goldens/public-api/angular_devkit/core/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ class Logger extends Observable<LogEntry> implements LoggerApi {
616616
// (undocumented)
617617
fatal(message: string, metadata?: JsonObject): void;
618618
// (undocumented)
619-
forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void>;
619+
forEach(next: (value: LogEntry) => void, promiseCtor?: typeof Promise): Promise<void>;
620620
// (undocumented)
621621
info(message: string, metadata?: JsonObject): void;
622622
// (undocumented)

packages/angular_devkit/core/src/logger/logger.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
161161
arguments as unknown as Parameters<Observable<LogEntry>['subscribe']>,
162162
);
163163
}
164-
override forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {
165-
return this._observable.forEach(next, PromiseCtor);
164+
165+
override forEach(next: (value: LogEntry) => void, promiseCtor?: typeof Promise): Promise<void> {
166+
return this._observable.forEach(next, promiseCtor);
166167
}
167168
}

packages/angular_devkit/core/src/utils/partially-ordered-set.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class PartiallyOrderedSet<T> implements Set<T> {
138138
}
139139

140140
while (copy.size > 0) {
141-
const run = [];
141+
const run: T[] = [];
142142
// Take the first item without dependencies.
143143
for (const [item, deps] of copy.entries()) {
144144
if (deps.size == 0) {

packages/angular_devkit/core/src/utils/strings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export function levenshtein(a: string, b: string): number {
152152
return a.length;
153153
}
154154

155-
const matrix = [];
155+
const matrix: number[][] = [];
156156

157157
// increment along the first column of each row
158158
for (let i = 0; i <= b.length; i++) {

packages/angular_devkit/core/src/utils/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export type TemplateAstNode =
128128
* Given a source text (and a fileName), returns a TemplateAst.
129129
*/
130130
export function templateParser(sourceText: string, fileName: string): TemplateAst {
131-
const children = [];
131+
const children: TemplateAstNode[] = [];
132132

133133
// Compile the regexp to match each delimiter.
134134
const reExpressions = [kEscapeRe, kCommentRe, kInterpolateRe, kEvaluateRe];

packages/angular_devkit/core/src/virtual-fs/host/memory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export class SimpleMemoryHost implements Host<{}> {
224224
const content = this._cache.get(from);
225225
if (content) {
226226
const fragments = split(to);
227-
const newDirectories = [];
227+
const newDirectories: Path[] = [];
228228
let curr: Path = normalize('/');
229229
for (const fr of fragments) {
230230
curr = join(curr, fr);

packages/angular_devkit/schematics/src/sink/sink.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ export interface Sink {
3333
const Noop = function () {};
3434

3535
export abstract class SimpleSinkBase implements Sink {
36-
preCommitAction: (
37-
action: Action,
38-
) => void | Action | PromiseLike<Action> | Observable<Action> = Noop;
36+
preCommitAction: (action: Action) => void | Action | PromiseLike<Action> | Observable<Action> =
37+
Noop;
3938
postCommitAction: (action: Action) => void | Observable<void> = Noop;
4039
preCommit: () => void | Observable<void> = Noop;
4140
postCommit: () => void | Observable<void> = Noop;
@@ -118,7 +117,7 @@ export abstract class SimpleSinkBase implements Sink {
118117
return concat(
119118
this.validateSingleAction(action),
120119
new Observable<void>((observer) => {
121-
let committed = null;
120+
let committed: Observable<void> | null = null;
122121
switch (action.kind) {
123122
case 'o':
124123
committed = this._overwriteFile(action.path, action.content);

packages/angular_devkit/schematics/src/tree/scoped.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class ScopedTree implements Tree {
164164
}
165165

166166
get actions(): Action[] {
167-
const scopedActions = [];
167+
const scopedActions: Action[] = [];
168168

169169
for (const action of this._base.actions) {
170170
if (!action.path.startsWith(this._root.scope + '/')) {

packages/schematics/angular/utility/ast-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export function findNodes<T extends ts.Node>(
171171
*/
172172
export function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[] {
173173
const nodes: ts.Node[] = [sourceFile];
174-
const result = [];
174+
const result: ts.Node[] = [];
175175

176176
while (nodes.length > 0) {
177177
const node = nodes.shift();

0 commit comments

Comments
 (0)