Comparing version 0.0.11 to 0.0.13
@@ -64,2 +64,3 @@ declare abstract class Type<T> { | ||
} | ||
declare type ObjectShape = Record<string, AnyType>; | ||
declare type InferObjectShape<T> = { | ||
@@ -74,3 +75,3 @@ [key in keyof T]: T[key] extends Type<infer K> ? K : any; | ||
}; | ||
declare class ObjectType<T extends object> extends Type<InferObjectShape<T>> { | ||
declare class ObjectType<T extends ObjectShape> extends Type<Eval<InferObjectShape<T>>> { | ||
private readonly objectShape; | ||
@@ -150,3 +151,3 @@ private readonly opts?; | ||
export declare const literal: <T extends Literal>(literal: T) => LiteralType<T>; | ||
export declare const object: <T extends object>(shape: T, opts?: ObjectOptions | undefined) => ObjectType<T>; | ||
export declare const object: <T extends Record<string, AnyType>>(shape: T, opts?: ObjectOptions | undefined) => ObjectType<T>; | ||
export declare const array: <T extends AnyType>(type: T, opts?: Partial<{ | ||
@@ -182,3 +183,3 @@ length: number; | ||
literal: <T extends Literal>(literal: T) => LiteralType<T>; | ||
object: <T_1 extends object>(shape: T_1, opts?: ObjectOptions | undefined) => ObjectType<T_1>; | ||
object: <T_1 extends Record<string, AnyType>>(shape: T_1, opts?: ObjectOptions | undefined) => ObjectType<T_1>; | ||
array: <T_2 extends AnyType>(type: T_2, opts?: Partial<{ | ||
@@ -185,0 +186,0 @@ length: number; |
@@ -347,3 +347,2 @@ "use strict"; | ||
} | ||
// TODO Handle Partial Types???? | ||
parse(value, opts) { | ||
@@ -362,2 +361,8 @@ if (this.left instanceof ObjectType && this.right instanceof ObjectType) { | ||
} | ||
if (this.left instanceof PartialType) { | ||
return new IntersectionType(this.left.schema, this.right).parse(value); | ||
} | ||
if (this.right instanceof PartialType) { | ||
return new IntersectionType(this.left, this.right.schema).parse(value); | ||
} | ||
this.left.parse(value); | ||
@@ -364,0 +369,0 @@ this.right.parse(value); |
{ | ||
"name": "myzod", | ||
"version": "0.0.11", | ||
"version": "0.0.13", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./libs/index.js", |
60876
1363