Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeepPartial type cannot handle 'unknown' type #29

Closed
b-houghton opened this issue Jun 30, 2020 · 0 comments · Fixed by #30 or #32
Closed

DeepPartial type cannot handle 'unknown' type #29

b-houghton opened this issue Jun 30, 2020 · 0 comments · Fixed by #30 or #32
Assignees

Comments

@b-houghton
Copy link
Contributor

Given the following example:

import { Factory } from 'fishery';

interface Entity1 {
  entity2: Entity2;
}

interface Entity2 {
  id: string;
  entity3: Array<Entity3>;
}

interface Entity3 {
  _permissions: unknown;
}

const entity2Factory = Factory.define<Entity2>(() => ({
  id: 'abc',
  entity3: [],
}));

const entity2 = entity2Factory.build();

const entity1Factory = Factory.define<Entity1>(() => ({
  entity2: entity2Factory.build(),
}));

const entity1 = entity1Factory.build({
  entity2: entity2,
});

I receive the following TypeScript error:

TS2345: Argument of type '{ entity2: Entity2; }' is not assignable to parameter of type 'DeepPartial<Entity1>'.
   The types of 'entity2.entity3' are incompatible between these types.
      Type 'Entity3[]' is not assignable to type '(DeepPartial<Entity3> | undefined)[]'.
         Type 'Entity3' is not assignable to type 'DeepPartial<Entity3>'.
            Types of property '_permissions' are incompatible.
               Type 'unknown' is not assignable to type 'DeepPartial<unknown> | undefined'.
                  Type 'unknown' is not assignable to type 'DeepPartial<unknown>'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants