Skip to content

Commit 319fbb6

Browse files
clydinalan-agius4
authored andcommitted
refactor(@angular-devkit/core): add missing function return types
Adding explicit type information for function return types is needed to allow the `@angular-devkit/core` package to eventually be built with the `isolatedDeclarations` option.
1 parent 9a46be8 commit 319fbb6

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

packages/angular_devkit/core/src/json/schema/registry.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
173173
* @param {JsonVisitor} visitor The visitor to transform every value.
174174
* @param {JsonVisitor[]} deps A list of other visitors to run before.
175175
*/
176-
addPreTransform(visitor: JsonVisitor, deps?: JsonVisitor[]) {
176+
addPreTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void {
177177
this._pre.add(visitor, deps);
178178
}
179179

@@ -184,7 +184,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
184184
* @param {JsonVisitor} visitor The visitor to transform every value.
185185
* @param {JsonVisitor[]} deps A list of other visitors to run before.
186186
*/
187-
addPostTransform(visitor: JsonVisitor, deps?: JsonVisitor[]) {
187+
addPostTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void {
188188
this._post.add(visitor, deps);
189189
}
190190

@@ -386,7 +386,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
386386
this._ajv.addFormat(format.name, format.formatter);
387387
}
388388

389-
addSmartDefaultProvider<T>(source: string, provider: SmartDefaultProvider<T>) {
389+
addSmartDefaultProvider<T>(source: string, provider: SmartDefaultProvider<T>): void {
390390
if (this._sourceMap.has(source)) {
391391
throw new Error(source);
392392
}
@@ -424,11 +424,11 @@ export class CoreSchemaRegistry implements SchemaRegistry {
424424
}
425425
}
426426

427-
registerUriHandler(handler: UriHandler) {
427+
registerUriHandler(handler: UriHandler): void {
428428
this._uriHandlers.add(handler);
429429
}
430430

431-
usePromptProvider(provider: PromptProvider) {
431+
usePromptProvider(provider: PromptProvider): void {
432432
const isSetup = !!this._promptProvider;
433433

434434
this._promptProvider = provider;

packages/angular_devkit/core/src/json/schema/visitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export function visitJson<ContextT>(
155155
return _visitJsonRecursive(json, visitor, buildJsonPointer([]), schema, refResolver, context);
156156
}
157157

158-
export function visitJsonSchema(schema: JsonSchema, visitor: JsonSchemaVisitor) {
158+
export function visitJsonSchema(schema: JsonSchema, visitor: JsonSchemaVisitor): void {
159159
if (schema === false || schema === true) {
160160
// Nothing to visit.
161161
return;

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
101101
};
102102
}
103103

104-
createChild(name: string) {
104+
createChild(name: string): Logger {
105105
return new (this.constructor as typeof Logger)(name, this);
106106
}
107107

108-
complete() {
108+
complete(): void {
109109
this._subject.complete();
110110
}
111111

@@ -121,20 +121,20 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
121121
this._subject.next(entry);
122122
}
123123

124-
debug(message: string, metadata: JsonObject = {}) {
125-
return this.log('debug', message, metadata);
124+
debug(message: string, metadata: JsonObject = {}): void {
125+
this.log('debug', message, metadata);
126126
}
127-
info(message: string, metadata: JsonObject = {}) {
128-
return this.log('info', message, metadata);
127+
info(message: string, metadata: JsonObject = {}): void {
128+
this.log('info', message, metadata);
129129
}
130-
warn(message: string, metadata: JsonObject = {}) {
131-
return this.log('warn', message, metadata);
130+
warn(message: string, metadata: JsonObject = {}): void {
131+
this.log('warn', message, metadata);
132132
}
133-
error(message: string, metadata: JsonObject = {}) {
134-
return this.log('error', message, metadata);
133+
error(message: string, metadata: JsonObject = {}): void {
134+
this.log('error', message, metadata);
135135
}
136-
fatal(message: string, metadata: JsonObject = {}) {
137-
return this.log('fatal', message, metadata);
136+
fatal(message: string, metadata: JsonObject = {}): void {
137+
this.log('fatal', message, metadata);
138138
}
139139

140140
override toString() {

packages/angular_devkit/core/src/utils/priority-queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export class PriorityQueue<T> {
1212

1313
constructor(private _comparator: (x: T, y: T) => number) {}
1414

15-
clear() {
15+
clear(): void {
1616
this._items = new Array<T>();
1717
}
1818

19-
push(item: T) {
19+
push(item: T): void {
2020
const index = this._items.findIndex((existing) => this._comparator(item, existing) <= 0);
2121

2222
if (index === -1) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import { ResolverHost } from './resolver';
5656
* .subscribe(x => expect(x).toBe(content2));
5757
*/
5858
export class AliasHost<StatsT extends object = {}> extends ResolverHost<StatsT> {
59-
protected _aliases = new Map<Path, Path>();
59+
protected _aliases: Map<Path, Path> = new Map();
6060

6161
protected _resolve(path: Path): Path {
6262
let maybeAlias = this._aliases.get(path);

packages/angular_devkit/core/src/virtual-fs/path.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export function join(p1: Path, ...others: string[]): Path {
120120
/**
121121
* Returns true if a path is absolute.
122122
*/
123-
export function isAbsolute(p: Path) {
123+
export function isAbsolute(p: Path): boolean {
124124
return p.startsWith(NormalizedSep);
125125
}
126126

@@ -166,7 +166,7 @@ export function relative(from: Path, to: Path): Path {
166166
* Returns a Path that is the resolution of p2, from p1. If p2 is absolute, it will return p2,
167167
* otherwise will join both p1 and p2.
168168
*/
169-
export function resolve(p1: Path, p2: Path) {
169+
export function resolve(p1: Path, p2: Path): Path {
170170
if (isAbsolute(p2)) {
171171
return p2;
172172
} else {

packages/angular_devkit/core/src/workspace/json/metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { JSONPath, Node, findNodeAtLocation, getNodeValue } from 'jsonc-parser';
1010
import { JsonValue } from '../../json';
1111
import { ProjectDefinition, TargetDefinition, WorkspaceDefinition } from '../definitions';
1212

13-
export const JsonWorkspaceSymbol = Symbol.for('@angular/core:workspace-json');
13+
export const JsonWorkspaceSymbol: unique symbol = Symbol.for('@angular/core:workspace-json');
1414

1515
export interface JsonWorkspaceDefinition extends WorkspaceDefinition {
1616
[JsonWorkspaceSymbol]: JsonWorkspaceMetadata;

0 commit comments

Comments
 (0)