diff --git a/src/lib/types/auth_forms.ts b/src/lib/types/auth_forms.ts index 7cecc61fc..7fde5e132 100644 --- a/src/lib/types/auth_forms.ts +++ b/src/lib/types/auth_forms.ts @@ -19,7 +19,9 @@ export type AuthFormConstraints = { password?: FieldConstraints; }; -type SchemaShape = Record; +// Must match the recursive SchemaShape from sveltekit-superforms (dist/jsonSchema/schemaShape.d.ts) +// Record is semantically equivalent but triggers TS circular reference error. +type SchemaShape = { [K in string]: SchemaShape }; /** * Represents the state and data structure for authentication forms. diff --git a/src/lib/utils/auth_forms.ts b/src/lib/utils/auth_forms.ts index 3e387b3f4..186b86f6e 100644 --- a/src/lib/utils/auth_forms.ts +++ b/src/lib/utils/auth_forms.ts @@ -164,9 +164,11 @@ const createBaseAuthForm = () => ({ pattern: '(?=.*?[a-z])(?=.*?[A-Z])(?=.*?\\d)[a-zA-Z\\d]{8,128}', }, }, + // Primitive fields get empty objects; only arrays/objects produce nested shape nodes. + // See: sveltekit-superforms/src/lib/jsonSchema/schemaShape.ts (_schemaShape) shape: { - username: { type: 'string' }, - password: { type: 'string' }, + username: {}, + password: {}, }, }); diff --git a/src/test/lib/utils/auth_forms.test.ts b/src/test/lib/utils/auth_forms.test.ts index 2309d9fbd..1cc277acf 100644 --- a/src/test/lib/utils/auth_forms.test.ts +++ b/src/test/lib/utils/auth_forms.test.ts @@ -27,8 +27,8 @@ vi.mock('$lib/zod/schema', () => ({ authSchema: { _type: 'ZodObject', shape: { - username: { type: 'string' }, - password: { type: 'string' }, + username: {}, + password: {}, }, }, })); @@ -129,8 +129,8 @@ describe('auth_forms', () => { }, }, shape: { - username: { type: 'string' }, - password: { type: 'string' }, + username: {}, + password: {}, } as unknown, message: '', } as unknown as SuperValidated, string>; @@ -205,8 +205,8 @@ describe('auth_forms', () => { expect(result.form.shape).toBeDefined(); expect(result.form.shape).toEqual({ - username: { type: 'string' }, - password: { type: 'string' }, + username: {}, + password: {}, }); });