mswjs / data

Data modeling and relation library for testing JavaScript applications.
https://npm.im/@mswjs/data
MIT License
827 stars 52 forks source link

feat(manyOf): return empty array for non-nullable without value #201

Closed kettanaito closed 2 years ago

kettanaito commented 2 years ago

Changes

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 0.10.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

borodean commented 2 years ago

Shouldn't the typing be also updated like this?

diff --git a/src/glossary.ts b/src/glossary.ts
index 925cc4a..63326ab 100644
--- a/src/glossary.ts
+++ b/src/glossary.ts
@@ -230,7 +230,7 @@ export type Value<
     Target[Key] extends ManyOf<infer ModelName, infer Nullable>
     ? Nullable extends true
       ? PublicEntity<Dictionary, ModelName>[] | null
-      : PublicEntity<Dictionary, ModelName>[] | undefined
+      : PublicEntity<Dictionary, ModelName>[]
     : // Account for primitive value getters because
     // native constructors (i.e. StringConstructor) satisfy
     // the "AnyObject" predicate below.
kettanaito commented 2 years ago

Hi, @borodean. I believe you're right, I've missed the type definition updates. Thank you for spotting this!