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

fix(destructuring): rename parameter names containing curly brace. #96

Merged
merged 1 commit into from Mar 14, 2016

Conversation

alexeagle
Copy link
Contributor

Fixes #95

@@ -17,3 +17,7 @@ function FunctionsTest2(a: number, b: number) {}
* @param { number} b
*/
function FunctionsTest3(a: number, b: number) {}
/**
* @param {{a:number, b:number}} param0
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for more test coverage, you might throw in two destructuring params here, or a destructure of the form

function foo({a, b}, [c, d])

@evmar
Copy link
Contributor

evmar commented Mar 14, 2016

LGTM either way.

@alexeagle
Copy link
Contributor Author

Nice, I did not realize arrays could be destructured as well.

Now I encounter an error, this is the first array type annotation and needs
to be converted to Array from number[].

/Users/alexeagle/Projects/sickle/test_files/functions.tr.js:21: ERROR - Bad
type annotation. expected closing }
 * @param { number[]} param1
                  ^

/Users/alexeagle/Projects/sickle/test_files/functions.tr.js:21: ERROR - Bad
type annotation. expecting a variable name in a @param tag
 * @param { number[]} param1
                  ^

2 error(s), 0 warning(s)

@evmar
Copy link
Contributor

evmar commented Mar 14, 2016

Ah, good point. Skip the array for now, it's a separate issue.

This handles object destructuring, but not array destructuring.
Fixes #95
@alexeagle alexeagle merged commit 7343270 into master Mar 14, 2016
@alexeagle alexeagle deleted the fix95 branch March 14, 2016 22:56
evmar added a commit that referenced this pull request Mar 24, 2016
Summary:
For binding patterns, we must use a type like !Array in the
Closure side.
But the test verifies we don't need !Array<!Array<...>> for
multiply-nested binding patterns.

Fixes #96.

Reviewers: alexeagle, rkirov

Reviewed By: rkirov

Subscribers: typescript-eng

Differential Revision: https://reviews.angular.io/D24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants