Skip to content

Commit

Permalink
refactor: remove add implicate types for better code readability
Browse files Browse the repository at this point in the history
When strictNullChecks in enabled in TS compiler, the following files
cause some failures in certain environments. Fix these failures.
Also update outdated goldens.
  • Loading branch information
gunan authored and alan-agius4 committed Oct 10, 2022
1 parent cdf78d4 commit 2230374
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion goldens/public-api/angular_devkit/core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class Logger extends Observable<LogEntry> implements LoggerApi {
// (undocumented)
fatal(message: string, metadata?: JsonObject): void;
// (undocumented)
forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void>;
forEach(next: (value: LogEntry) => void, promiseCtor?: typeof Promise): Promise<void>;
// (undocumented)
info(message: string, metadata?: JsonObject): void;
// (undocumented)
Expand Down
5 changes: 3 additions & 2 deletions packages/angular_devkit/core/src/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
arguments as unknown as Parameters<Observable<LogEntry>['subscribe']>,
);
}
override forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {
return this._observable.forEach(next, PromiseCtor);

override forEach(next: (value: LogEntry) => void, promiseCtor?: typeof Promise): Promise<void> {
return this._observable.forEach(next, promiseCtor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class PartiallyOrderedSet<T> implements Set<T> {
}

while (copy.size > 0) {
const run = [];
const run: T[] = [];
// Take the first item without dependencies.
for (const [item, deps] of copy.entries()) {
if (deps.size == 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/src/utils/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function levenshtein(a: string, b: string): number {
return a.length;
}

const matrix = [];
const matrix: number[][] = [];

// increment along the first column of each row
for (let i = 0; i <= b.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/src/utils/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export type TemplateAstNode =
* Given a source text (and a fileName), returns a TemplateAst.
*/
export function templateParser(sourceText: string, fileName: string): TemplateAst {
const children = [];
const children: TemplateAstNode[] = [];

// Compile the regexp to match each delimiter.
const reExpressions = [kEscapeRe, kCommentRe, kInterpolateRe, kEvaluateRe];
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/src/virtual-fs/host/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class SimpleMemoryHost implements Host<{}> {
const content = this._cache.get(from);
if (content) {
const fragments = split(to);
const newDirectories = [];
const newDirectories: Path[] = [];
let curr: Path = normalize('/');
for (const fr of fragments) {
curr = join(curr, fr);
Expand Down
7 changes: 3 additions & 4 deletions packages/angular_devkit/schematics/src/sink/sink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ export interface Sink {
const Noop = function () {};

export abstract class SimpleSinkBase implements Sink {
preCommitAction: (
action: Action,
) => void | Action | PromiseLike<Action> | Observable<Action> = Noop;
preCommitAction: (action: Action) => void | Action | PromiseLike<Action> | Observable<Action> =
Noop;
postCommitAction: (action: Action) => void | Observable<void> = Noop;
preCommit: () => void | Observable<void> = Noop;
postCommit: () => void | Observable<void> = Noop;
Expand Down Expand Up @@ -118,7 +117,7 @@ export abstract class SimpleSinkBase implements Sink {
return concat(
this.validateSingleAction(action),
new Observable<void>((observer) => {
let committed = null;
let committed: Observable<void> | null = null;
switch (action.kind) {
case 'o':
committed = this._overwriteFile(action.path, action.content);
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/schematics/src/tree/scoped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class ScopedTree implements Tree {
}

get actions(): Action[] {
const scopedActions = [];
const scopedActions: Action[] = [];

for (const action of this._base.actions) {
if (!action.path.startsWith(this._root.scope + '/')) {
Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/utility/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export function findNodes<T extends ts.Node>(
*/
export function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[] {
const nodes: ts.Node[] = [sourceFile];
const result = [];
const result: ts.Node[] = [];

while (nodes.length > 0) {
const node = nodes.shift();
Expand Down

0 comments on commit 2230374

Please sign in to comment.