Skip to content

Commit 8b35639

Browse files
committed
simplify schema types
1 parent 8764061 commit 8b35639

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

docs/atom/Result.ts.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Added in v1.0.0
2121
- [Encoded (type alias)](#encoded-type-alias)
2222
- [PartialEncoded (type alias)](#partialencoded-type-alias)
2323
- [Schema](#schema)
24+
- [Schema (interface)](#schema-interface)
2425
- [schemaFromSelf](#schemafromself)
2526
- [accessors](#accessors)
2627
- [cause](#cause)
@@ -217,14 +218,22 @@ export declare const Schema: <
217218
>(options: {
218219
readonly success?: Success | undefined
219220
readonly error?: Error | undefined
220-
}) => Schema_.transform<
221-
Schema_.Schema<
222-
PartialEncoded<Success["Type"], Error["Type"]>,
221+
}) => Schema<Success, Error>
222+
```
223+
224+
Added in v1.0.0
225+
226+
## Schema (interface)
227+
228+
**Signature**
229+
230+
```ts
231+
export interface Schema<Success extends Schema_.Schema.All, Error extends Schema_.Schema.All>
232+
extends Schema_.Schema<
233+
Result<Success["Type"], Error["Type"]>,
223234
Encoded<Success["Encoded"], Error["Encoded"]>,
224235
Success["Context"] | Error["Context"]
225-
>,
226-
Schema_.Schema<Result<Success["Type"], Error["Type"]>>
227-
>
236+
> {}
228237
```
229238

230239
Added in v1.0.0

packages/atom/src/Result.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,21 @@ export const schemaFromSelf: Schema_.Schema<Result<any, any>> = Schema_.declare(
797797
identifier: "Result"
798798
})
799799

800+
/**
801+
* @since 1.0.0
802+
* @category Schemas
803+
*/
804+
export interface Schema<
805+
Success extends Schema_.Schema.All,
806+
Error extends Schema_.Schema.All
807+
> extends
808+
Schema_.Schema<
809+
Result<Success["Type"], Error["Type"]>,
810+
Encoded<Success["Encoded"], Error["Encoded"]>,
811+
Success["Context"] | Error["Context"]
812+
>
813+
{}
814+
800815
/**
801816
* @since 1.0.0
802817
* @category Schemas
@@ -809,14 +824,7 @@ export const Schema = <
809824
readonly success?: Success | undefined
810825
readonly error?: Error | undefined
811826
}
812-
): Schema_.transform<
813-
Schema_.Schema<
814-
PartialEncoded<Success["Type"], Error["Type"]>,
815-
Encoded<Success["Encoded"], Error["Encoded"]>,
816-
Success["Context"] | Error["Context"]
817-
>,
818-
Schema_.Schema<Result<Success["Type"], Error["Type"]>>
819-
> => {
827+
): Schema<Success, Error> => {
820828
const success_: Success = options.success ?? Schema_.Never as any
821829
const error: Error = options.error ?? Schema_.Never as any
822830
const Success = Schema_.TaggedStruct("Success", {

0 commit comments

Comments
 (0)