-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: take normal input and infer assertion
- Loading branch information
Showing
8 changed files
with
44 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import type { UnknownAssertion } from "@the-minimal/types"; | ||
import type { Infer } from "@types"; | ||
import type { Assertion } from "@the-minimal/types"; | ||
|
||
export type AndSchema = Array<UnknownAssertion>; | ||
export type AndSchema = Array<unknown>; | ||
|
||
export type InferAndSchema<$Validations extends AndSchema> = | ||
$Validations extends [infer $Head, ...infer $Tail] | ||
? $Tail extends [infer $1, ...infer $2] | ||
? Infer<$Head> & InferAndSchema<$Tail> | ||
: Infer<$Head> | ||
: never; | ||
export type InferAndSchema<$Schema extends AndSchema> = { | ||
[$Key in keyof $Schema]: Assertion<$Schema[$Key]>; | ||
}; | ||
|
||
export type InferAndOutput<$Schema extends AndSchema> = $Schema extends [ | ||
infer $Head, | ||
...infer $Tail, | ||
] | ||
? $Tail extends [infer $1, ...infer $2] | ||
? $Head & InferAndOutput<$Tail> | ||
: $Head | ||
: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import type { | ||
InferAssertion, | ||
Pretty, | ||
UnknownAssertion, | ||
} from "@the-minimal/types"; | ||
import type { ObjectUnknown } from "@assertions/isObject/types"; | ||
import type { Assertion, Pretty } from "@the-minimal/types"; | ||
|
||
export type ObjectSchema = Record<string, UnknownAssertion>; | ||
export type ObjectSchema = ObjectUnknown; | ||
|
||
export type InferObjectSchema<$Schema extends ObjectSchema> = Pretty<{ | ||
[$Key in keyof $Schema]: InferAssertion<$Schema[$Key]>; | ||
[$Key in keyof $Schema]: Assertion<$Schema[$Key]>; | ||
}>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import type { InferAssertion, UnknownAssertion } from "@the-minimal/types"; | ||
import type { | ||
Assertion, | ||
InferAssertion, | ||
UnknownAssertion, | ||
} from "@the-minimal/types"; | ||
|
||
export type OrSchema = Array<UnknownAssertion>; | ||
export type OrSchema = Array<unknown>; | ||
|
||
export type InferOrSchema<$Schema extends OrSchema> = { | ||
[$Key in keyof $Schema]: InferAssertion<$Schema[$Key]>; | ||
}[number]; | ||
[$Key in keyof $Schema]: Assertion<$Schema[$Key]>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import type { InferAssertion, UnknownAssertion } from "@the-minimal/types"; | ||
import type { Assertion } from "@the-minimal/types"; | ||
|
||
export type TupleSchema = Array<UnknownAssertion>; | ||
export type TupleSchema = Array<unknown>; | ||
|
||
export type InferTupleSchema<$Schema extends TupleSchema> = { | ||
[$Key in keyof $Schema]: InferAssertion<$Schema[$Key]>; | ||
[$Key in keyof $Schema]: Assertion<$Schema[$Key]>; | ||
}; |