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

[app-state] more informative error message when assigning to an undefined state #53

Closed
RaphiStein opened this issue Sep 19, 2021 · 2 comments

Comments

@RaphiStein
Copy link

When assigning to a state that is undefined, (i.e. store('mystate').state() === undefined), the library produces an error that is confusing and does not actually tell me what I'm doing wrong.

i.e.

store('mystate').assign(undefined)
store('mystate').assign({age: 30, name: 'joe'})

produces a console error saying:

preview-bc361a02a95aae7c3363b.js:2 TypeError: Cannot read property 'age' of undefined
    at eval (store.ts:73)
    at eval (every.ts:27)

Desired behaviour

A message saying "cannot assign to undefined property mystate"
(and perhaps include the application code line number in the stack trace?)

Stackblitz link:
https://stackblitz.com/edit/typescript-qg4jq7

@ersimont
Copy link
Member

I like your profile pic :)

Thanks for the suggestion!

ersimont added a commit that referenced this issue Oct 2, 2021
@ersimont
Copy link
Member

ersimont commented Oct 2, 2021

This will come with version 13

@ersimont ersimont closed this as completed Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants