thoughtbot / fishery

A library for setting up JavaScript objects as test data
MIT License
876 stars 36 forks source link

Loose inferred return type of generator function #114

Open purepear opened 1 year ago

purepear commented 1 year ago

Description

The inferred type of the generator allows for extra properties(variant 1). In the case of class extension it also requires narrowing the literal types(variant 3). It seems to work well when the return type is set explicitly(variant 2, variant 4).

Looking at the source code(the generic types), I would expect the generator return type to be inferred properly 🤔

I'm not sure if this is a bug or a feature 😄

image

To Reproduce

https://stackblitz.com/edit/fishery-test?file=Post.ts

Additional context Fishery version: 2.2.2