apollographql / apollographql/apollo-tooling

Generate undefined instead of null in typescript

Open
#622 22 comments 75 reactions 0 assignees View on GitHub
:tada: feature 🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

- [x] feature

I think there has been an intense argument going around with `null` vs `undefined` in the JS community. But, in the typescript world, pretty much [microsoft](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#null-and-undefined) has recommended to avoid `null` and use `undefined`.

Can we have an option argument to generate `undefined` instead of `null` in typescript? Coming from `swift` world, it will be pretty useful to just deal with `undefined` than adding `null` to the mix.

Any thoughts?

Contributor guide

Open the contributing guide

Research direction

Start by locating the TypeScript generation entry point and how generation options are defined. Determine the scope of replacing generated null values with undefined, including how the option should affect output, then review the existing discussion before proposing a design and corresponding coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.