diff --git a/src/constructor.test.ts b/src/constructor.test.ts index 0db58c9a..78a13b41 100644 --- a/src/constructor.test.ts +++ b/src/constructor.test.ts @@ -32,13 +32,14 @@ describe('makeDomainFunction', () => { }) it('fails gracefully if gets something other than undefined', async () => { - const handler = mdf()(() => 'no input!') - type _R = Expect>> + const handler = mdf()((args) => args) + type _R = Expect>> assertEquals(await handler('some input'), { - success: false, + success: true, + data: undefined, errors: [], - inputErrors: [{ path: [], message: 'Expected undefined' }], + inputErrors: [], environmentErrors: [], }) }) diff --git a/src/constructor.ts b/src/constructor.ts index 08b7a8a5..2bcacd7d 100644 --- a/src/constructor.ts +++ b/src/constructor.ts @@ -87,7 +87,7 @@ async function safeResult(fn: () => T): Promise> { * return { message: `${greeting} ${user.name}` } * }) */ -function makeDomainFunction( +function makeDomainFunction>( inputSchema?: ParserSchema, environmentSchema?: ParserSchema, ) { @@ -131,14 +131,8 @@ const objectSchema: ParserSchema> = { } const undefinedSchema: ParserSchema = { - safeParseAsync: (data: unknown) => { - if (data !== undefined) { - return Promise.resolve({ - success: false, - error: { issues: [{ path: [], message: 'Expected undefined' }] }, - }) - } - return Promise.resolve({ success: true, data }) + safeParseAsync: (_data: unknown) => { + return Promise.resolve({ success: true, data: undefined }) }, }