mswjs / data

Data modeling and relation library for testing JavaScript applications.

Home Page:https://npm.im/@mswjs/data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type instantiation is excessively deep and possibly infinite.

ericchernuka opened this issue · comments

I just added v0.8.0 and ran into a weird issue with the types around the drop function. I've attached a screenshot of the TS error.
My factory is pretty barebones and shown below:

export const dbInstance = factory({
  ingressWorkload: {
    id: primaryKey(faker.datatype.uuid),
    organization: oneOf('organization'),
    state: (): IngressWorkload['state'] => 'Draft',
    name: (): string => 'Untitled',
    notes: nullable(String),
  },
  organization: {
    organizationId: primaryKey(faker.datatype.uuid),
    name: faker.company.companyName,
  },
});

image

I had this working for a bit then it cropped up in CI. We are running TypeScript 4.5.2.

Magically went away.

Hey, @ericchernuka. Thanks for reporting this.

With the addition of the nested objects support (#113), our type definitions now reference themselves (the depth of the model may be infinite, in theory). I believe the latest releases of TypeScript can tolerate that just fine. Please note that we support TypeScript 4.2.x at the moment. Recursive types should be possible, otherwise, how can one annotate a recursively nested data structure?