-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proof of concept: provide empty optionals #569
Draft
dskloetd
wants to merge
2
commits into
main
Choose a base branch
from
kloet/empty-optionals
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
1 task
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Done.
@dskloetd, thanks a lot for the explanation. I like this solution; it will definitely save some repetitive work in the future 👍 |
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