Title: "Block-scoped variable used before its declaration" not detected inside closures · Issue #9273 · microsoft/TypeScript · GitHub
Open Graph Title: "Block-scoped variable used before its declaration" not detected inside closures · Issue #9273 · microsoft/TypeScript
X Title: "Block-scoped variable used before its declaration" not detected inside closures · Issue #9273 · microsoft/TypeScript
Description: This is similar to #7477 and #8976, but occurs inside closures. TypeScript Version: 1.9.0-dev.20160620-1.0 Code const y = (() => x)(); const x = 3; Expected behavior: The compilation error "Block-scoped variable x used before its declara...
Open Graph Description: This is similar to #7477 and #8976, but occurs inside closures. TypeScript Version: 1.9.0-dev.20160620-1.0 Code const y = (() => x)(); const x = 3; Expected behavior: The compilation error "Block-s...
X Description: This is similar to #7477 and #8976, but occurs inside closures. TypeScript Version: 1.9.0-dev.20160620-1.0 Code const y = (() => x)(); const x = 3; Expected behavior: The compilation error "...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/9273
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Block-scoped variable used before its declaration\" not detected inside closures","articleBody":"This is similar to #7477 and #8976, but occurs inside closures.\n\n**TypeScript Version:** \n\n1.9.0-dev.20160620-1.0\n\n**Code**\n\n``` ts\nconst y = (() => x)();\nconst x = 3;\n```\n\n**Expected behavior:**\n\nThe compilation error \"Block-scoped variable `x` used before its declaration\".\n\n**Actual behavior:** \n\nThe code is compiled to:\n\n``` ts\nvar y = (function () { return x; })();\nvar x = 3;\n```\n\nThis sets `y` to `undefined`.\n\n**Additional variants:**\n\nThis also occurs when the access to the binding `x` is in default argument value position:\n\n``` ts\nconst y = ((i: number = x) => i)();\nconst x = 3;\n```\n\n**Comparison against spec behavior:**\nAll of the following result in a `ReferenceError` being thrown on Node 5.1:\n\n``` js\n(function() {\n 'use strict';\n var y = (() => x)();\n const x = 3;\n return y;\n})();\n\n(function() {\n 'use strict';\n const y = (() => x)();\n const x = 3;\n return y;\n})();\n```\n","author":{"url":"https://github.com/kourge","@type":"Person","name":"kourge"},"datePublished":"2016-06-20T17:51:04Z","url":"https://github.com/microsoft/TypeScript/issues/9273"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a8c2a5c5-6490-a1e0-8b71-7c6a255debcd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8F6:3F8A67:99CB1B:CE9512:6B00EBC7 |
| html-safe-nonce | fef7377815283f8f23046dc3c3409bf3d4588d7615a329f3a76cc4511c748f13 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEY2OjNGOEE2Nzo5OUNCMUI6Q0U5NTEyOjZCMDBFQkM3IiwidmlzaXRvcl9pZCI6IjM5NDM5OTk0MjgxMTI3MzkyNzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 082d4c2c62c92b65e4867f6a370d4947ab52bdd75f9aed609dfa1937ea11ca70 |
| hovercard-subject-tag | issue:161254349 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/9273/issue_layout |
| twitter:image | https://opengraph.githubassets.com/10b99b13c86fc1585b3179238c1178fc28270293e95c14b789b5cbc1d980c57b/microsoft/TypeScript/issues/9273 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/10b99b13c86fc1585b3179238c1178fc28270293e95c14b789b5cbc1d980c57b/microsoft/TypeScript/issues/9273 |
| og:image:alt | This is similar to #7477 and #8976, but occurs inside closures. TypeScript Version: 1.9.0-dev.20160620-1.0 Code const y = (() => x)(); const x = 3; Expected behavior: The compilation error "Block-s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kourge |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width