DeepPartial type cannot handle 'unknown' type
b-houghton opened this issue · 0 comments
b-houghton commented
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>'.