Open TomerAberbach opened 1 year ago
It might be a great thing to do for a next major 🤔 Doing that in the current one would mean break the official compatibility with TS and force users to bump to 5.0 or above. We can already create the PR and wait for a next major to be ready to merge it (I already have one queued PR with breaking).
Sounds good! Did you want me to make the PR? Or were you planning on doing it?
As you want.
Note: I think a next major will come soon even if it will not bring that much into fast-check: it will help me to change some internal (but exposed) APIs such as IProperty.
Thanks for moving ahead with this!
It will be part of v4. I'm currently stacking PRs to have it ready in the coming weeks/months. I might do some new minors in-between to properly advertise new APIs and deprecate old ones.
This is a helpful change, thanks! Can you give the same treatment to constant
?
@seansfkelley Just opened a PR with our suggestion for constant
. Same thing as for constantFrom
, it will have to wait v4. And this time I hope to be able to publish it soon (1-2 months is my target).
🚀 Feature Request
Motivation
Right now
fc.constantFrom('a', 'b', 'c')
returnsArbitrary<string>
, which is a bit inconvenient because often the reason you are usingfc.constantFrom
in the first place is that you need the specific type represented by the constants. You can fix this by writingfc.constantFrom<'a' | 'b' | 'c'>('a', 'b', 'c')
, but that requires duplicating the constants between the types and the values.const
generics solve this problem.Example
TS Playground