Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(@angular-devkit/core): remove any types #18542

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -51,9 +51,7 @@ export class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = Jso
return of(null);
}

// TODO: this should be unknown
// tslint:disable-next-line:no-any
function _getValue(...fields: any[]) {
function _getValue(...fields: unknown[]) {
return fields.find(x => schema.isJsonSchema(x)) || true;
}

Expand Down
12 changes: 6 additions & 6 deletions packages/angular_devkit/core/src/experimental/jobs/api.ts
Expand Up @@ -453,10 +453,10 @@ export function isJobHandler<
A extends JsonValue,
I extends JsonValue,
O extends JsonValue,
// TODO: this should be unknown
// tslint:disable-next-line:no-any
>(value: any): value is JobHandler<A, I, O> {
return typeof value == 'function'
&& typeof value.jobDescription == 'object'
&& value.jobDescription !== null;
>(value: unknown): value is JobHandler<A, I, O> {
const job = value as JobHandler<A, I, O>;

return typeof job == 'function'
&& typeof job.jobDescription == 'object'
&& job.jobDescription !== null;
}
3 changes: 1 addition & 2 deletions packages/angular_devkit/core/src/json/schema/interface.ts
Expand Up @@ -69,6 +69,7 @@ export interface SchemaValidator {

export interface SchemaFormatter {
readonly async: boolean;
// TODO should be unknown remove before next major release
// tslint:disable-next-line:no-any
validate(data: any): boolean | Observable<boolean>;
}
Expand All @@ -84,13 +85,11 @@ export interface SmartDefaultProvider<T> {

export interface SchemaKeywordValidator {
(
// tslint:disable-next-line:no-any
data: JsonValue,
schema: JsonValue,
parent: JsonObject | JsonArray | undefined,
parentProperty: string | number | undefined,
pointer: JsonPointer,
// tslint:disable-next-line:no-any
rootData: JsonValue,
): boolean | Observable<boolean>;
}
Expand Down
7 changes: 2 additions & 5 deletions packages/angular_devkit/core/src/json/schema/registry.ts
Expand Up @@ -447,8 +447,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
}

addFormat(format: SchemaFormat): void {
// tslint:disable-next-line:no-any
const validate = (data: any) => {
const validate = (data: unknown) => {
const result = format.formatter.validate(data);

if (typeof result == 'boolean') {
Expand All @@ -461,9 +460,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
this._ajv.addFormat(format.name, {
async: format.formatter.async,
validate,
// AJV typings list `compare` as required, but it is optional.
// tslint:disable-next-line:no-any
} as any);
});
}

addSmartDefaultProvider<T>(source: string, provider: SmartDefaultProvider<T>) {
Expand Down
8 changes: 3 additions & 5 deletions packages/angular_devkit/core/src/json/schema/schema.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import { clean } from '../../utils';
import { JsonObject, isJsonObject } from '../interface';
import { JsonObject, JsonValue, isJsonObject } from '../interface';

/**
* A specialized interface for JsonSchema (to come). JsonSchemas are also JsonObject.
Expand All @@ -16,10 +16,8 @@ import { JsonObject, isJsonObject } from '../interface';
export type JsonSchema = JsonObject | boolean;


// TODO: this should be unknown
// tslint:disable-next-line:no-any
export function isJsonSchema(value: any): value is JsonSchema {
return isJsonObject(value) || value === false || value === true;
export function isJsonSchema(value: unknown): value is JsonSchema {
return isJsonObject(value as JsonValue) || value === false || value === true;
}

/**
Expand Down