diff --git a/RescriptSchema.gen.d.ts b/RescriptSchema.gen.d.ts index f6e7da23..895041df 100644 --- a/RescriptSchema.gen.d.ts +++ b/RescriptSchema.gen.d.ts @@ -25,7 +25,7 @@ export type S_t = { serialize(value: Output): Result; serializeOrThrow(value: Output): Input; serializeToJsonOrThrow(value: Output): Json; - assert(data: unknown): asserts data is Output; + assert(data: unknown): asserts data is Input; }; export abstract class S_Path_t { diff --git a/docs/js-usage.md b/docs/js-usage.md index 203b6967..21db2de6 100644 --- a/docs/js-usage.md +++ b/docs/js-usage.md @@ -514,7 +514,7 @@ let nodeSchema = S.recursive((nodeSchema) => ```ts const shortStringSchema = S.refine(S.string, (value, s) => if (value.length > 255) { - throw s.fail("String can't be more than 255 characters") + s.fail("String can't be more than 255 characters") } ) ``` @@ -555,7 +555,7 @@ const intToString = (schema) => (string, s) => { const int = parseInt(string, 10); if (isNaN(int)) { - throw s.fail("Can't convert string to int"); + s.fail("Can't convert string to int"); } return int; } diff --git a/packages/tests/src/core/S_test.ts b/packages/tests/src/core/S_test.ts index 747f964c..7c040d1a 100644 --- a/packages/tests/src/core/S_test.ts +++ b/packages/tests/src/core/S_test.ts @@ -424,7 +424,7 @@ test("Fails to parse with transform with user error", (t) => { const schema = S.transform(S.string, (string, s) => { const number = Number(string); if (Number.isNaN(number)) { - throw s.fail("Invalid number"); + s.fail("Invalid number"); } return number; }); diff --git a/src/S.d.ts b/src/S.d.ts index 0fd167d7..ca90f759 100644 --- a/src/S.d.ts +++ b/src/S.d.ts @@ -3,7 +3,7 @@ export { Json, Result, S_error as Error } from "../RescriptSchema.gen"; export type EffectCtx = { schema: Schema; - fail: (message: string) => void; + fail: (message: string) => never; }; export type Schema = S_t;