From b62aa27acecd4f7d9cef14be02617bdcb4c8cf7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Miernik?= Date: Mon, 26 Dec 2022 21:42:08 +0100 Subject: [PATCH] Narrowed any to unknown. --- packages/uniforms-bridge-graphql/src/GraphQLBridge.ts | 7 +++++-- .../uniforms-bridge-json-schema/src/JSONSchemaBridge.ts | 5 ++++- .../src/SimpleSchema2Bridge.ts | 5 ++++- .../src/SimpleSchemaBridge.ts | 5 ++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/uniforms-bridge-graphql/src/GraphQLBridge.ts b/packages/uniforms-bridge-graphql/src/GraphQLBridge.ts index 1786f6b14..1c0f1a5dd 100644 --- a/packages/uniforms-bridge-graphql/src/GraphQLBridge.ts +++ b/packages/uniforms-bridge-graphql/src/GraphQLBridge.ts @@ -22,7 +22,7 @@ function fieldInvariant(name: string, condition: boolean): asserts condition { export default class GraphQLBridge extends Bridge { constructor( public schema: GraphQLType, - public validator: (model: UnknownObject) => any, + public validator: (model: UnknownObject) => unknown, public extras: UnknownObject = {}, ) { super(); @@ -34,6 +34,7 @@ export default class GraphQLBridge extends Bridge { this.getType = memoize(this.getType.bind(this)); } + // TODO: Get rid of this `any`. getError(name: string, error: any) { const details = error?.details; if (!Array.isArray(details)) { @@ -43,11 +44,13 @@ export default class GraphQLBridge extends Bridge { return details.find(error => error.name === name) || null; } + // TODO: Get rid of this `any`. getErrorMessage(name: string, error: any) { const scopedError = this.getError(name, error); return scopedError?.message || ''; } + // TODO: Get rid of this `any`. getErrorMessages(error: any) { if (!error) { return []; @@ -81,7 +84,7 @@ export default class GraphQLBridge extends Bridge { ); } - getInitialValue(name: string): any { + getInitialValue(name: string): unknown { const type = this.getType(name); if (type === Array) { diff --git a/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts b/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts index 5787431a5..ffa5dd6ab 100644 --- a/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts +++ b/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts @@ -85,7 +85,7 @@ export default class JSONSchemaBridge extends Bridge { constructor( // FIXME: The `schema` should be typed more precisely. public schema: Record, - public validator: (model: UnknownObject) => any, + public validator: (model: UnknownObject) => unknown, ) { super(); @@ -99,6 +99,7 @@ export default class JSONSchemaBridge extends Bridge { this.getType = memoize(this.getType.bind(this)); } + // TODO: Get rid of this `any`. getError(name: string, error: any) { const details = error?.details; if (!Array.isArray(details)) { @@ -120,11 +121,13 @@ export default class JSONSchemaBridge extends Bridge { return scopedError || null; } + // TODO: Get rid of this `any`. getErrorMessage(name: string, error: any) { const scopedError = this.getError(name, error); return scopedError?.message || ''; } + // TODO: Get rid of this `any`. getErrorMessages(error: any) { if (!error) { return []; diff --git a/packages/uniforms-bridge-simple-schema-2/src/SimpleSchema2Bridge.ts b/packages/uniforms-bridge-simple-schema-2/src/SimpleSchema2Bridge.ts index d4fdc4785..08c502142 100644 --- a/packages/uniforms-bridge-simple-schema-2/src/SimpleSchema2Bridge.ts +++ b/packages/uniforms-bridge-simple-schema-2/src/SimpleSchema2Bridge.ts @@ -21,6 +21,7 @@ export default class SimpleSchema2Bridge extends Bridge { this.getType = memoize(this.getType.bind(this)); } + // TODO: Get rid of this `any`. getError(name: string, error: any) { const details = error?.details; if (!Array.isArray(details)) { @@ -30,12 +31,14 @@ export default class SimpleSchema2Bridge extends Bridge { return details.find(error => error.name === name) || null; } + // TODO: Get rid of this `any`. getErrorMessage(name: string, error: any) { const scopedError = this.getError(name, error); // @ts-expect-error: `messageForError` has incorrect typing. return !scopedError ? '' : this.schema.messageForError(scopedError); } + // TODO: Get rid of this `any`. getErrorMessages(error: any) { if (!error) { return []; @@ -74,7 +77,7 @@ export default class SimpleSchema2Bridge extends Bridge { return merged; } - getInitialValue(name: string): any { + getInitialValue(name: string): unknown { const field = this.getField(name); const defaultValue = field.defaultValue; if (defaultValue !== undefined) { diff --git a/packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts b/packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts index 8ce432e76..c1b5fdcca 100644 --- a/packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts +++ b/packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts @@ -18,6 +18,7 @@ export default class SimpleSchemaBridge extends Bridge { this.getType = memoize(this.getType.bind(this)); } + // TODO: Get rid of this `any`. getError(name: string, error: any) { const details = error?.details; if (!Array.isArray(details)) { @@ -27,6 +28,7 @@ export default class SimpleSchemaBridge extends Bridge { return details.find(error => error.name === name) || null; } + // TODO: Get rid of this `any`. getErrorMessage(name: string, error: any) { const scopedError = this.getError(name, error); return !scopedError @@ -39,6 +41,7 @@ export default class SimpleSchemaBridge extends Bridge { ); } + // TODO: Get rid of this `any`. getErrorMessages(error: any) { if (!error) { return []; @@ -65,7 +68,7 @@ export default class SimpleSchemaBridge extends Bridge { return definition; } - getInitialValue(name: string): any { + getInitialValue(name: string): unknown { const field = this.getField(name); const defaultValue = field.defaultValue; if (defaultValue !== undefined) {