Draft
Conversation
1 task
Contributor
size-limit report 📦
|
mstrasinskis
reviewed
Mar 6, 2024
| import { emptyOptionalsForSnsNeuronsFundParticipationConstraints } from "./optionals"; | ||
|
|
||
| // If this file has a compilation error because new optional fields were added | ||
| // to a Candid type, add the the empty optional field values to the |
Contributor
There was a problem hiding this comment.
Suggested change
| // to a Candid type, add the the empty optional field values to the | |
| // to a Candid type, add the empty optional field values to the |
Contributor
|
@dskloetd, thanks a lot for the explanation. I like this solution; it will definitely save some repetitive work in the future 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proof of concept: provide empty optionals
The problem
When Candid types are updated in ic-js, if new optional fields are added, updating the ic-js version in nns-dapp (or other depending repos) is a breaking change, even though the fields are optional.
Here is an example of a PR that updated the ic-js dependency in nns-dapp. In addition to updating the dependency, it had to add new empty field values in many places. I'd like updating the ic-js dependency to be automatic without manual changes.
A solution?
The solution I propose is to provide default empty values for all Candid types. The client repo can then destructure these values in order to get all empty optional values. If a new optional field is added, it should be added to the default empty values such that the client repo will use it automatically.
This PR shows how this could be done for just a single type.
It also adds a test which makes sure that any new optional fields are added.
Here is an example of how this would be used in NNS dapp: dfinity/nns-dapp#4594