Support rest pattern in destructuring#568
Merged
Perryvw merged 9 commits intoTypeScriptToLua:masterfrom Aug 18, 2019
Merged
Conversation
Collaborator
|
One way ObjectRest could be improved is by passing a set-like object for usedProperties instead of an array that has to be manually searched: const {a, b, ...rest} = {a: "A", b: "B", c: "C", d: "D"};function __TS__ObjectRest(target, usedProperties)
local result = {}
for property in pairs(target) do
if usedProperties[property] == nil then
result[property] = target[property]
end
end
return result
end
local ____ = {
a = "A",
b = "B",
c = "C",
d = "D",
}
a = ____.a
b = ____.b
rest = __TS__ObjectRest(____, {
a = true,
b = true,
rest = true,
}) |
2059140 to
f7d6497
Compare
Perryvw
reviewed
Aug 18, 2019
| return ts.isObjectLiteralExpression(node) || ts.isArrayLiteralExpression(node); | ||
| } | ||
|
|
||
| export function isDestructuringAssignment(node: ts.Node): node is ts.DestructuringAssignment { |
Member
There was a problem hiding this comment.
Typescript has this one too, any reason we're not using that?
Contributor
Author
There was a problem hiding this comment.
Are you sure about that? I couldn't find any functions that have a is ts.DestructuringAssignment type guard
Member
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
It's in the block with @internal annotation, so can't be used directly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #545.