Chore: Change "?" for "Option" for optional fields #480
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Using
?
is not the same asOption
. With?
the field is optional, but withOption
, the field is mandatory, but the value can beundefined
.This small distinction is important when we render the information of proposals in NNS Dapp. We convert the actions to camelcase and remove
[] | [T]
.If we use
?
, we might forget to convert it and it will never show up in NNS Dapp. By usingOption
, we make sure that the field will always we present in the converters.You can see the example in the
params
,maxDirectParticipationIcpE8s
andminDirectParticipationIcpE8s
fields for the (deprecated)OpenSnsTokenSwap
proposal action that I had to change when I moved from?
toOption
.Changes
?
intypes/governance_converters.ts
forOption
. Only for the fields related to proposals.Tests
Todos