Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Add '| undefined' to optional properties #494

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

merrywhether
Copy link
Contributor

@merrywhether merrywhether commented Oct 22, 2021

Address #447, adding | undefined to all optional property types. Previously considered only updating input types (see #491 and #492), but after more consideration it seems that updating all optional types is safer and guarantees consumers don't run into issues however they choose to use the generated types. This also represents the most targeted changeset after learning a lot about the repo and TS factory types in the earlier versions.

See the snapshot to visualize the changes to the generated types. This change will be invisible to consumers who don't have exactOptionalPropertyTypes enabled, as foo?: Bar is already equivalent to foo?: Bar | undefined for them.

Also:

  • turns on exactOptionalPropertyTypes in this repo (and a few associated type updates)
  • narrows type of State.generatedInputObjectTypes (found while working in generateInputObjectTypes in Add '| undefined' to optional input properties (option 1) #491)
  • removes 2 duplicate fixtures that were named mutaion instead of mutation
  • replaces ts.factory.createLiteralTypeNode(ts.factory.createToken(ts.SyntaxKind.NullKeyword)) with ts.factory.createNull()

@merrywhether merrywhether changed the title Add '| undefined' to optional input properties Add '| undefined' to optional properties Oct 24, 2021
@fxOne fxOne added the Version: Minor Increment the minor version when merged label Oct 28, 2021
@saihaj saihaj merged commit 7e498f5 into relay-tools:master Oct 29, 2021
@saihaj
Copy link
Member

saihaj commented Oct 29, 2021

Thanks!!! @merrywhether

@github-actions
Copy link

🚀 PR was released in v14.3.0 🚀

@merrywhether merrywhether deleted the exact-optionals branch October 29, 2021 06:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
released Version: Minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants