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

Fall back to raw text if there is a parser error in JS #164

Merged
merged 1 commit into from
Dec 5, 2020

Conversation

dummdidumm
Copy link
Member

Handle default value inside object destructuring that way
#163

Handle default value inside object destructuring that way
sveltejs#163
@Conduitry
Copy link
Member

"Raw text" - does this mean that it won't actually be reformatted? If so, could we instead do something like creating a dummy destructuring to format that we then strip off the unneeded parts of?

@dummdidumm
Copy link
Member Author

dummdidumm commented Nov 30, 2020

Yes, it means it's not formatted at all in the case of { a, b = [] }. It's not great but at least it will unblock formatting the rest of the document.

I did some steps in the "dummy destructuring" direction. It will format such a destructuring if we do let ${expression} = null. But then we have to remove the let and = null from the Doc-Array, which requires some inside knowledge on how the Doc-Structure from the printer looks like. I did not find a quick generic way to cut off the unneeded doc elements.

@dummdidumm
Copy link
Member Author

I'm inclined to merge this. It would unblock devs using the default values at the very minimal cost that only that expression is not reformatted, the rest of the document will be. We can always look into a more sophisticated solution later on. Thoughts?

@Conduitry
Copy link
Member

Yeah, agreed that this partial solution is definitely better than what there is now.

@dummdidumm dummdidumm merged commit c597a93 into sveltejs:master Dec 5, 2020
@dummdidumm dummdidumm deleted the fix-obj-destr-default-value branch December 5, 2020 15:56
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

Successfully merging this pull request may close these issues.

2 participants