refactor(v2): correct some of type errors reported by eslint (#4382)

* fix: correct some of type errors reported by eslint

* fix: remove unnecessary import
This commit is contained in:
Armano 2021-03-12 12:24:22 +01:00 committed by GitHub
parent a39c62f644
commit bfe52cdae3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 32 additions and 21 deletions

View file

@ -28,7 +28,6 @@ function createTestHelpers({
function testFail(value: unknown) {
expect(() => Joi.attempt(value, schema)).toThrowErrorMatchingSnapshot(
// @ts-expect-error: seems ok at runtime, but bad typedef
`for value=${JSON.stringify(value)}`,
);
}

View file

@ -38,7 +38,7 @@ export const logValidationBugReportHint = (): void => {
export function normalizePluginOptions<T extends {id?: string}>(
schema: Joi.ObjectSchema<T>,
options: unknown,
) {
): T {
// All plugins can be provided an "id" option (multi-instance support)
// we add schema validation automatically
const finalSchema = schema.append({
@ -51,7 +51,7 @@ export function normalizePluginOptions<T extends {id?: string}>(
logValidationBugReportHint();
if (isValidationDisabledEscapeHatch) {
console.error(error);
return options;
return options as T;
} else {
throw error;
}
@ -62,7 +62,7 @@ export function normalizePluginOptions<T extends {id?: string}>(
export function normalizeThemeConfig<T>(
schema: Joi.ObjectSchema<T>,
themeConfig: unknown,
) {
): T {
// A theme should only validate his "slice" of the full themeConfig,
// not the whole object, so we allow unknown attributes
// otherwise one theme would fail validating the data of another theme
@ -76,7 +76,7 @@ export function normalizeThemeConfig<T>(
logValidationBugReportHint();
if (isValidationDisabledEscapeHatch) {
console.error(error);
return themeConfig;
return themeConfig as T;
} else {
throw error;
}