-
Notifications
You must be signed in to change notification settings - Fork 97
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
Unknown node type: ObjectPattern #163
Comments
Root cause is that we parse everything after |
As far as I know, this syntax is valid JS, as long as we're talking about assignment expressions (in the same way that const array = [1, 2, 3, 4, 5].map((i) => ({ id: i }));
array.push({}); // object missing an `id`
for (const { id = -1 } of array) {
console.log(id); // prints 1, 2, 3, 4, 5, -1
}
array.forEach(({ id = -1 }) => console.log(id)); // prints 1, 2, 3, 4, 5, -1
array.forEach(({ val }) => console.log(val)); // prints undefined five times
array.forEach(({ val = 0 }) => console.log(val)); // prints 0 five times |
Handle default value inside object destructuring that way sveltejs#163
It's valid JS syntax if the parser knows the broader context. If the parser only gets |
Handle default value inside object destructuring that way #163
Hi! 👋
I'm running into an issue when I try to run prettier on a svelte template that has object destructuring with a default value.
{#each array as { prop = defaultValue }}
prettier-plugin-svelte
version 1.4.1prettier
version 2.2.0Full code example
Full stack trace
The text was updated successfully, but these errors were encountered: