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

svelte5: Better error message for binding to undefined variables #13049

Open
ottomated opened this issue Aug 27, 2024 · 3 comments
Open

svelte5: Better error message for binding to undefined variables #13049

ottomated opened this issue Aug 27, 2024 · 3 comments

Comments

@ottomated
Copy link
Contributor

Describe the problem

The current error message for attempting to bind to an undefined variable is Can only bind to state or props, which is technically correct but confusing. REPL

Describe the proposed solution

The error message here should be something like Cannot find name 'x'..

Importance

nice to have

@rChaoz
Copy link
Contributor

rChaoz commented Aug 28, 2024

Should probably copy the error message from non-bindings - x is not defined

@dummdidumm
Copy link
Member

In a sense it's correct, this is a global variable, so not state nor props

@ottomated
Copy link
Contributor Author

Yes, as I said it's technically correct, but the most common place people will run into this is A. misspelling a local state or B. renaming / deleting local state without updating the binding. The error could have a disclaimer about global variables if you think it needs that, but it's such an edge case.
i.e.

x is not defined.
If x is a global variable, bind using globalThis.x

or

x is not defined.
You can only bind to existing local state and props

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

3 participants