Skip to content

fix(mock): prepend strict mock type declarations in tags-split MSW/faker output #3574

Description

@Hypenate

Problem

Orval 8.16.0 generates mock factory signatures that reference strict mock helper types (MockWithNullableOverrides, {Schema}Mock, etc.) but does not emit the corresponding export type declarations when all of the following are combined:

This produces TypeScript errors such as:

error TS2304: Cannot find name 'MockWithNullableOverrides'.
error TS2304: Cannot find name 'PetMock'.
error TS2552: Cannot find name 'getPetMock'. Did you mean 'getGetPetsResponseMock'?

Why existing tests do not catch it

Strict-mock fixtures (issue-3525, issue-3525-multi, etc.) use client: 'fetch' and a single-file / non-tags-split layout. They do not cover tags-split per-tag .msw.ts + .faker.ts with arrayItems: true.

In that layout, strictMockSchemaTypeNames was dropped when building tag targets, so finalizeMockImplementation / dedupeStrictMockTypeDeclarations never prepended strict types. Faker files also referenced schema factories emitted only in the MSW file because array-item factory dedup was scoped per tag but not per mock generator file.

Expected behavior

Each generated mock file that references strict mock types should include (once per file):

  • export type KeysWithNull<O> = { ... };
  • export type MockWithNullableOverrides<...> = ...;
  • export type PetMock = { [K in keyof Required<Pet>]: NonNullable<Required<Pet>[K]>; };

Faker files must define or import schema factories they call (e.g. getPetMock()).

Related PRs

Metadata

Metadata

Assignees

Labels

mockRelated to mock generationmswMSW related issues

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions