{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/27172708","id":27172708,"diff_hunk":"@@ -1353,30 +1361,84 @@ module ts {\n                         }\r\n                         else {\r\n                             // Interfaces cannot have parameter types that cannot be named\r\n-                            diagnosticMessage = symbolAccesibilityResult.errorModuleName ?\r\n+                            return symbolAccesibilityResult.errorModuleName ?\r\n                                 Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :\r\n                                 Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;\r\n                         }\r\n-                        break;\r\n \r\n                     case SyntaxKind.FunctionDeclaration:\r\n-                        diagnosticMessage = symbolAccesibilityResult.errorModuleName ?\r\n+                        return symbolAccesibilityResult.errorModuleName ?\r\n                             symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?\r\n                                 Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :\r\n                                 Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :\r\n                             Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;\r\n-                        break;\r\n \r\n                     default:\r\n                         Debug.fail(\"This is unknown parent for parameter: \" + node.parent.kind);\r\n                 }\r\n+            }\r\n \r\n-                return {\r\n-                    diagnosticMessage,\r\n-                    errorNode: node,\r\n-                    typeName: node.name\r\n-                };\r\n+            function emitBindingPattern(bindingPattern: BindingPattern) {\r\n+                // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node.\r\n+                if (bindingPattern.kind === SyntaxKind.ObjectBindingPattern) {\r\n+                    write(\"{\");\r\n+                    emitCommaList(bindingPattern.elements, emitBindingElement);\r\n+                    write(\"}\");\r\n+                }\r\n+                else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) {\r\n+                    write(\"[\");\r\n+                    emitCommaList(bindingPattern.elements, emitBindingElement);\r\n+                    write(\"]\");\r\n+                }\r\n             }\r\n+\r\n+            function emitBindingElement(bindingElement: BindingElement) {\r\n+                function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {\r\n+                    let diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);\r\n+                    return diagnosticMessage !== undefined ? {\r\n+                        diagnosticMessage,\r\n+                        errorNode: bindingElement,\r\n+                        typeName: bindingElement.name\r\n+                    } : undefined;\r\n+                }\r\n+\r\n+                if (bindingElement.propertyName) {\r\n+                    // bindingElement has propertyName property in the following case:\r\n+                    //      { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for \"y\"\r\n+                    // We have to explicitly emit the propertyName before descending into its binding elements.\r\n+                    // Example:\r\n+                    //      original: function foo({y: [a,b,c]}) {}\r\n+                    //      emit    : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void;\r\n+                    writeTextOfNode(currentSourceFile, bindingElement.propertyName);\r\n+                    write(\": \");\r\n+\r\n+                    // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern\r\n+                    emitBindingPattern(<BindingPattern>bindingElement.name);\r\n+                }\r\n+                else if (bindingElement.name) {\r\n+                    if (isBindingPattern(bindingElement.name)) {\r\n+                        // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately.\r\n+                        // In the case of rest element, we will omit rest element.\r\n+                        // Example:\r\n+                        //      original: function foo([a, [[b]], c] = [1,[[\"string\"]], 3]) {}\r","path":"src/compiler/declarationEmitter.ts","position":140,"original_position":140,"commit_id":"1c2eae6b72c8cc9646fda407bbaa6344bcf4e997","original_commit_id":"1c2eae6b72c8cc9646fda407bbaa6344bcf4e997","user":{"login":"CyrusNajmabadi","id":4564579,"avatar_url":"https://avatars.githubusercontent.com/u/4564579?v=3","gravatar_id":"","url":"https://api.github.com/users/CyrusNajmabadi","html_url":"https://github.com/CyrusNajmabadi","followers_url":"https://api.github.com/users/CyrusNajmabadi/followers","following_url":"https://api.github.com/users/CyrusNajmabadi/following{/other_user}","gists_url":"https://api.github.com/users/CyrusNajmabadi/gists{/gist_id}","starred_url":"https://api.github.com/users/CyrusNajmabadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CyrusNajmabadi/subscriptions","organizations_url":"https://api.github.com/users/CyrusNajmabadi/orgs","repos_url":"https://api.github.com/users/CyrusNajmabadi/repos","events_url":"https://api.github.com/users/CyrusNajmabadi/events{/privacy}","received_events_url":"https://api.github.com/users/CyrusNajmabadi/received_events","type":"User","site_admin":false},"body":"Great comments, thanks!","created_at":"2015-03-25T22:23:42Z","updated_at":"2015-03-25T22:23:42Z","html_url":"https://github.com/Microsoft/TypeScript/pull/2429#discussion_r27172708","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/27172708"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/2429#discussion_r27172708"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429","id":31569898,"html_url":"https://github.com/Microsoft/TypeScript/pull/2429","diff_url":"https://github.com/Microsoft/TypeScript/pull/2429.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/2429.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2429","number":2429,"state":"open","locked":false,"title":"Allow destructuring in ambient","user":{"login":"yuit","id":489742,"avatar_url":"https://avatars.githubusercontent.com/u/489742?v=3","gravatar_id":"","url":"https://api.github.com/users/yuit","html_url":"https://github.com/yuit","followers_url":"https://api.github.com/users/yuit/followers","following_url":"https://api.github.com/users/yuit/following{/other_user}","gists_url":"https://api.github.com/users/yuit/gists{/gist_id}","starred_url":"https://api.github.com/users/yuit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuit/subscriptions","organizations_url":"https://api.github.com/users/yuit/orgs","repos_url":"https://api.github.com/users/yuit/repos","events_url":"https://api.github.com/users/yuit/events{/privacy}","received_events_url":"https://api.github.com/users/yuit/received_events","type":"User","site_admin":false},"body":"Address #2421","created_at":"2015-03-19T21:51:01Z","updated_at":"2015-03-25T22:23:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95b9c19df46b59e5e085b1e70e7749155c722c82","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2429/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/1c2eae6b72c8cc9646fda407bbaa6344bcf4e997","head":{"label":"Microsoft:allowDestructuringInAmbient","ref":"allowDestructuringInAmbient","sha":"1c2eae6b72c8cc9646fda407bbaa6344bcf4e997","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-03-25T22:07:25Z","pushed_at":"2015-03-25T22:07:24Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":641538,"stargazers_count":4214,"watchers_count":4214,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":408,"mirror_url":null,"open_issues_count":545,"forks":408,"open_issues":545,"watchers":4214,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"79272d7cef6e255d8e33101535e119e9c6f2085b","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-03-25T22:07:25Z","pushed_at":"2015-03-25T22:07:24Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":641538,"stargazers_count":4214,"watchers_count":4214,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":408,"mirror_url":null,"open_issues_count":545,"forks":408,"open_issues":545,"watchers":4214,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/2429"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/2429"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/2429/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2429/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/1c2eae6b72c8cc9646fda407bbaa6344bcf4e997"}}}}