From 47c58330fa43453da8c42e063ade687dcecead68 Mon Sep 17 00:00:00 2001 From: Joao Pedro Campos Silva Date: Mon, 5 Jul 2021 01:13:17 -0300 Subject: [PATCH] fix: raw prop return types --- src/FluentJSONSchema.d.ts | 4 ++-- src/types/index.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/FluentJSONSchema.d.ts b/src/FluentJSONSchema.d.ts index 77e42db..fe12a97 100644 --- a/src/FluentJSONSchema.d.ts +++ b/src/FluentJSONSchema.d.ts @@ -22,7 +22,7 @@ export interface BaseSchema { writeOnly: (isWriteOnly?: boolean) => T isFluentSchema: boolean isFluentJSONSchema: boolean - raw: (fragment: any) => JSONSchema + raw: (fragment: any) => T } export type TYPE = @@ -239,7 +239,7 @@ export interface S extends BaseSchema { >( types: T ) => MixedSchema - raw: (fragment: any) => JSONSchema + raw: (fragment: any) => S FORMATS: FORMATS } diff --git a/src/types/index.ts b/src/types/index.ts index d932cc9..1d86449 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -90,3 +90,11 @@ console.log('array of user\n', JSON.stringify(arrayExtendedSchema)) const extendExtendedSchema = S.object().extend(userSchema) console.log('extend of user\n', JSON.stringify(extendExtendedSchema)) + +const rawNullableSchema = S.object() + .raw({ nullable: true }) + .required(['foo', 'hello']) + .prop('foo', S.string()) + .prop('hello', S.string()) + +console.log('raw schema with nullable props\n', JSON.stringify(rawNullableSchema))