Skip to content
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

State issue needs clarification (hackathon feedback) #224

Closed
bucanero opened this issue Sep 15, 2022 · 3 comments · Fixed by #226
Closed

State issue needs clarification (hackathon feedback) #224

bucanero opened this issue Sep 15, 2022 · 3 comments · Fixed by #226
Assignees
Labels

Comments

@bucanero
Copy link
Contributor

From: @aut-protocol https://github.com/Aut-Protocol/Aut-on-NEAR/blob/main/protocol/pagoda_journey.md

Make it super clear in the docs that the state won't work if it's not initalized when set as a property, even if it does in the initializer. Example:

//prop: string;
prop: string = '';

@initialize({})
init() {
    this.prop = 'initial value'
}
@volovyks
Copy link
Collaborator

It is mentioned in README: https://github.com/near/near-sdk-js#nearbindgen-and-other-decorators

Your class must have a constructor(). You will not be able to call it, which is why it should not accept any parameters. You must declare all the parameters that you are planning to use in the constructor and set default values.

But yes, let's make it more clear.

@volovyks
Copy link
Collaborator

I wonder if there is something like 'strict' mode that will require users to do that.

@osalkanovic
Copy link
Contributor

@volovyks its possible by adding condition in babel transformer like this

if(child.kind == 'constructor') {
              hasConstructor = true;
}

If you want I can create PR :)

@volovyks volovyks self-assigned this Sep 21, 2022
@ailisp ailisp added v0.6 and removed v0.6 labels Sep 23, 2022
@ailisp ailisp modified the milestone: 0.6 Sep 23, 2022
@ailisp ailisp added the v0.6 label Sep 23, 2022
@ailisp ailisp linked a pull request Sep 23, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants