Skip to content

false default binding pattern values#538

Merged
Perryvw merged 4 commits intoTypeScriptToLua:masterfrom
hazzard993:destructure-fix
Apr 28, 2019
Merged

false default binding pattern values#538
Perryvw merged 4 commits intoTypeScriptToLua:masterfrom
hazzard993:destructure-fix

Conversation

@hazzard993
Copy link
Copy Markdown
Contributor

Closes #529

Default destructuring parameters are handled the same way default parameters are, with a nil check

{ bindingString: "{x: foo, y}", objectString: "{x: true, y: false}", returnVariable: "foo" },
{ bindingString: "{x}", objectString: "{x: true}", returnVariable: "x", expectedResult: true },
{
bindingString: "[x, y]",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to adjust all existing tests for this. It is probably tidier if you just add a new test.each([<...>])("Binding patterns handle false correctly (%p)" with your false test cases.

bindingString: "{x, y: [z = true]}",
objectString: "{x: false, y: [false]}",
returnVariable: "z",
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test with simply the pattern [x = false] too?

Copy link
Copy Markdown
Contributor Author

@hazzard993 hazzard993 Apr 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array binding pattern default parameters don't work in variable declaration statements. I'll add this with another commit, doesn't look like it resulted in much more code to review

@Perryvw Perryvw merged commit 247ceba into TypeScriptToLua:master Apr 28, 2019
@hazzard993 hazzard993 deleted the destructure-fix branch April 28, 2019 21:31
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.

Default values in destructuring handle false incorrectly

2 participants