From f86b9137fb1b01fb07e1d08eb454cd53e804d0b6 Mon Sep 17 00:00:00 2001 From: Anton Evzhakov Date: Wed, 6 Feb 2019 16:57:30 +0200 Subject: [PATCH] Add definition for `isSchema()` method signature --- types/yup/index.d.ts | 1 + types/yup/yup-tests.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index 9f3cb687a2..88c4890b82 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -26,6 +26,7 @@ export function addMethod>( export function ref(path: string, options?: { contextPrefix: string }): Ref; export function lazy(fn: (value: T) => Schema): Lazy; export function setLocale(customLocale: LocaleObject): void; +export function isSchema(obj: any): obj is Schema; export const mixed: MixedSchemaConstructor; export const string: StringSchemaConstructor; diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index a90a7df25d..f0404cf8bd 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -3,6 +3,7 @@ import * as yup from "yup"; // tslint:disable-next-line:no-duplicate-imports import { reach, + isSchema, date, Schema, ObjectSchema, @@ -24,6 +25,10 @@ const schema1 = yup.object().shape({ reach(schema1, "nested.arr.num"); reach(schema1, "nested.arr[].num"); +// isSchema function +const isSchemaResult1: boolean = isSchema(schema1); +const isSchemaResult2: boolean = isSchema({}); + // addMethod function yup.addMethod(yup.number, "minimum", function( this,