From 1d3bc0ff40e8b1727d093ae7165fa0fec956385b Mon Sep 17 00:00:00 2001 From: Jon Sheppard Date: Thu, 24 Mar 2016 17:18:20 +0700 Subject: [PATCH] Joi: Update when to use generics --- joi/joi-tests.ts | 2 +- joi/joi.d.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/joi/joi-tests.ts b/joi/joi-tests.ts index 4eea606a6..a00543fe4 100644 --- a/joi/joi-tests.ts +++ b/joi/joi-tests.ts @@ -97,7 +97,7 @@ uriOpts = {scheme: expArr}; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var whenOpts: Joi.WhenOptions = null; +var whenOpts: Joi.WhenOptions = null; whenOpts = {is: x}; whenOpts = {is: schema, then: schema}; diff --git a/joi/joi.d.ts b/joi/joi.d.ts index c5d78dc88..d9ee7c20d 100644 --- a/joi/joi.d.ts +++ b/joi/joi.d.ts @@ -95,11 +95,11 @@ declare module 'joi' { scheme ?: string | RegExp | Array; } - export interface WhenOptions { + export interface WhenOptions { /** * the required condition joi type. */ - is: any; + is: T; /** * the alternative schema type if the condition is true. Required if otherwise is missing. */ @@ -269,8 +269,8 @@ declare module 'joi' { /** * Converts the type into an alternatives type where the conditions are merged into the type definition where: */ - when(ref: string, options: WhenOptions): AlternativesSchema; - when(ref: Reference, options: WhenOptions): AlternativesSchema; + when(ref: string, options: WhenOptions): AlternativesSchema; + when(ref: Reference, options: WhenOptions): AlternativesSchema; /** * Overrides the key name in error messages. @@ -691,8 +691,8 @@ declare module 'joi' { export interface AlternativesSchema extends AnySchema { try(schemas: Schema[]): AlternativesSchema; - when(ref: string, options: WhenOptions): AlternativesSchema; - when(ref: Reference, options: WhenOptions): AlternativesSchema; + when(ref: string, options: WhenOptions): AlternativesSchema; + when(ref: Reference, options: WhenOptions): AlternativesSchema; } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---