dotansimha / dotansimha/graphql-code-generator
[typescript] Add additional Types for possible null values
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Is your feature request related to a problem? Please describe.**
So there is the `Maybe` type already which says the value can be `null` which actually is more like `Nullable` if you ask me. Anyway, so the value may be `null` but if it is optional it also does not need to exist at all, so you either have `?` or `| undefined` added to the `Maybe` which could be shorter with adding an extra type for that.
**Describe the solution you'd like**
So additionally to the `Maybe` utility type lets have something like `Nullable` (😁 ) which is something like `type Nullable = Maybe | undefined = T | null | undefined`
Or if you want some other intermediate type maybe something like
```ts
type Nothing = null | undefined
type Nullable = T | Nothing
```
**Additional context**
Let's have a look at validation lib Zod for a moment. You have the option to use `.nullable()` and chain `.optional()` as well, but there is a short form for this which is called `.nullish()`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.