Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated nested object types #248

Open
r1chm8 opened this issue Nov 3, 2022 · 0 comments
Open

Generated nested object types #248

r1chm8 opened this issue Nov 3, 2022 · 0 comments

Comments

@r1chm8
Copy link

r1chm8 commented Nov 3, 2022

Hello, I'm wondering if types returned by generating data in these two different ways should be the same or not?

Example one

article: {
  metadata: {
    author: nullable(String),
  }
},

the returned type of article.metadata.author is string | null | undefined.

Example Two

article: {
  metadata: oneOf('metadata'),
},
metadata: {
  author: nullable(String),
},

the returned type of article.metadata.author is string | null;

I would expect the types to be the same and I'd also expect the type to be string | null. If undefined was required, maybe a helper such as optional(nullable(String)) could be used to generate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant