Skip to content

Commit

Permalink
fix: Import missing type
Browse files Browse the repository at this point in the history
  • Loading branch information
SQReder committed Sep 3, 2024
1 parent cfed9ea commit 725e85c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/zod/src/__tests__/contract.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ describe('zodContract', () => {

test('branded type', () => {
const BrandedContainer = zod.object({
branded: zod.string().brand<'Branded'>()
})
const brandedContract = zodContract(BrandedContainer)
branded: zod.string().brand<'Branded'>(),
});
const brandedContract = zodContract(BrandedContainer);

const smth: unknown = { branded: 'branded' };

if (brandedContract.isData(smth)) {
expectTypeOf(smth).toEqualTypeOf<zod.infer<typeof BrandedContainer>>();
}
})
});
});
4 changes: 2 additions & 2 deletions packages/zod/src/zod_contract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ZodType } from 'zod';
import { type ZodType, type TypeOf } from 'zod';
import { type Contract } from '@farfetched/core';

/**
Expand All @@ -8,7 +8,7 @@ import { type Contract } from '@farfetched/core';
* @param {ZodType} data Zod Contract for valid data
*/
function zodContract<T extends ZodType<any, any, any>>(data: T): Contract<unknown, TypeOf<T>> {
function isData(prepared: unknown): prepared is D {
function isData(prepared: unknown): prepared is T {
return data.safeParse(prepared).success;
}

Expand Down

0 comments on commit 725e85c

Please sign in to comment.