Arbitrary records with optional fields
See original GitHub issue💬 Question and Help
Hi, I have an interface with optional fields, something like:
interface Foo {
bar?: number
}
I am trying to generate arbitraries for this, but fc.option(fc.integer())
doesn’t seem to do the trick, since it always includes the property (typed as number | null
). I’d like to omit the property entirely as optional, but I believe I can settle for number | undefined
.
What’s the best way to do this?
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
defrecord with optional keys - clojure - Stack Overflow
Since records in Clojure implement the map interface, all fields except for the ones specified in the constructor are optional. So, declaring your...
Read more >Creating a table with many optional fields
This schema only has 3 tables (not "tons") and you can have as many contact types as you want. The joins aren't that...
Read more >Less verbose records with optional values · Issue #382 - GitHub
For example, suppose that a user is interested in the default value for one of the non-required fields. If you represent the defaultable...
Read more >Limitations of OCAML records
Idea: add the concept of model for the fields that are not explicitely mentioned in the record type: • ∂Abs to say that...
Read more >Table - Airtable Scripting
Table. Table represents each table in your base. You can use it to find all of the views, fields, and records it contains....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @dubzzz! I just ran into this situation again and was quite surprised to see that past-me opened this issue over a year ago! And that you fixed it!
@gnidan The feature is now native in fast-check 2.11.0 🥳
Look for
record
andrequiredKeys
in https://github.com/dubzzz/fast-check/blob/master/documentation/Arbitraries.md#object