Skip to content

Factory produces data incompatible to its type constraint #106

@lo1tuma

Description

@lo1tuma

Description

When using the factory overrides to set a property explicitly to undefined this is always allowed even when the type constraint doesn’t accept undefined as a valid value.

To Reproduce

import { Factory } from 'fishery';

interface Foo {
    bar: string;
}

const fooFactory = Factory.define<Foo>(() => {
    return { bar: 'any-value' };
});

const result = fooFactory.build({ bar: undefined }); // result has the type Foo but its value is { bar: undefined } which is not a valid Foo

Additional context

It seems like this bug has been introduced with #44

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions