Title: Parameter Defaults See Scope of Function Body · Issue #8465 · microsoft/TypeScript · GitHub
Open Graph Title: Parameter Defaults See Scope of Function Body · Issue #8465 · microsoft/TypeScript
X Title: Parameter Defaults See Scope of Function Body · Issue #8465 · microsoft/TypeScript
Description: TypeScript Version: 1.8.10 Code namespace A { "use strict"; let foo = "out"; export function bar(func = () => foo) { let foo = "in"; console.log(func()); } } A.bar(); Expected behavior: I read http://www.2ality.com/2015/02/es6-scoping.ht...
Open Graph Description: TypeScript Version: 1.8.10 Code namespace A { "use strict"; let foo = "out"; export function bar(func = () => foo) { let foo = "in"; console.log(func()); } } A.bar(); Expected behavior: I read http...
X Description: TypeScript Version: 1.8.10 Code namespace A { "use strict"; let foo = "out"; export function bar(func = () => foo) { let foo = "in"; console.log(func()); } } A.bar(...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/8465
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Parameter Defaults See Scope of Function Body","articleBody":"**TypeScript Version:** \n\n1.8.10\n\n**Code**\n\n``` ts\nnamespace A {\n \"use strict\";\n let foo = \"out\";\n export function bar(func = () => foo) {\n let foo = \"in\";\n console.log(func());\n }\n}\nA.bar();\n```\n\n**Expected behavior:**\nI read http://www.2ality.com/2015/02/es6-scoping.html (section: _5.3. Parameter default values don’t see the scope of the body_) and then tried out:\n\n``` js\n(() => { \"use strict\"; let v = \"out\"; ((f = () => v) => { let v = \"in\"; console.log(f())})()})()\n```\n\nin node v6.0.0 and got the value `'out'`.\n\n**Actual behavior:** \nWhat TypeScript generates gives you the result `'in'`.\n\nDoesn't matter if you swap `var` for `let`.\n","author":{"url":"https://github.com/SlurpTheo","@type":"Person","name":"SlurpTheo"},"datePublished":"2016-05-04T19:01:22Z","url":"https://github.com/microsoft/TypeScript/issues/8465"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:83d17c5a-bd3d-2b9c-5480-e9281a97a22d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1DA:258059:166D055:1F50E82:6AFA3B41 |
| html-safe-nonce | 0a564ea472e0bacd7e20b9c883dad9c3bc4b44c7c1d83791520d9758cd97d6f9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMURBOjI1ODA1OToxNjZEMDU1OjFGNTBFODI6NkFGQTNCNDEiLCJ2aXNpdG9yX2lkIjoiODk3NDU2NTAwODM5NDA0MjE3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2cb8c1a285bba0528c94c3845ef5797ab6876b62a44ad2a244bb9909175c159e |
| hovercard-subject-tag | issue:153089812 |
| 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/8465/issue_layout |
| twitter:image | https://opengraph.githubassets.com/762eda372a5714a337b5f96aa501a3584ebf9f8697ebe1bc4c1e2b7e458b48db/microsoft/TypeScript/issues/8465 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/762eda372a5714a337b5f96aa501a3584ebf9f8697ebe1bc4c1e2b7e458b48db/microsoft/TypeScript/issues/8465 |
| og:image:alt | TypeScript Version: 1.8.10 Code namespace A { "use strict"; let foo = "out"; export function bar(func = () => foo) { let foo = "in"; console.log(func()); } } A.bar(); Expected behavior: I read http... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SlurpTheo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| 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 | 072e34035c13c31543fba9f025cbbbda4210dae4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width