Title: Why TDZ checks are not implemented · Issue #54343 · microsoft/TypeScript · GitHub
Open Graph Title: Why TDZ checks are not implemented · Issue #54343 · microsoft/TypeScript
X Title: Why TDZ checks are not implemented · Issue #54343 · microsoft/TypeScript
Description: Bug Report It may not be a bug, because I see that you clearly know what TDZ check is (such as the code example in this issue), but it is not applied. I did find some related issues reported by TypeScript team members such as #5174 sever...
Open Graph Description: Bug Report It may not be a bug, because I see that you clearly know what TDZ check is (such as the code example in this issue), but it is not applied. I did find some related issues reported by Typ...
X Description: Bug Report It may not be a bug, because I see that you clearly know what TDZ check is (such as the code example in this issue), but it is not applied. I did find some related issues reported by Typ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/54343
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Why TDZ checks are not implemented","articleBody":"# Bug Report\r\n\r\nIt may not be a bug, because I see that you clearly know what TDZ check is (such as the code example [in this issue](https://github.com/microsoft/TypeScript/issues/52924#issue-1595962667)), but it is not applied. I did find some related issues reported by TypeScript team members such as https://github.com/microsoft/TypeScript/issues/5174 several years before, but it still passes the check now.\r\n\r\nJust out of curiosity, would you please explain why such checks are not (fully) implemented?\r\n\r\n### 🔎 Search Terms\r\n\r\nTDZ check\r\n\r\n### 🕗 Version \u0026 Regression Information\r\n\r\n\u003c!-- When did you start seeing this bug occur?\r\n\r\n\"Bugs\" that have existed in TS for a long time are very likely to be FAQs; refer to\r\n https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs\r\n\r\nIf possible, please try testing the nightly version of TS to see if it's already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n\r\nNote: The TypeScript Playground can be used to try older versions of TypeScript.\r\n\r\nPlease keep and fill in the line that best applies:\r\n--\u003e\r\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries.\r\n\r\n### ⏯ Playground Link\r\n\r\n\u003c!--\r\n A link to a TypeScript Playground \"Share\" link which shows this behavior.\r\n This should have the same code as the code snippet below, and use whichever settings are relevant to your report.\r\n\r\n As a last resort, you can link to a repo, but these will be slower for us to investigate.\r\n--\u003e\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?#code/PTAEAsBdIBwZwFwgOYEtLgK4CMB0BjAewFthjV8AnQuQgM0mABUBPGAUwGUrUZHU4cTOzjAArAEYA7ABYAUHUwA7fJFSEloOgAoAHglBLMxbO0oBKUAG85oO6DgB3dPnB7LN+19D4AhnHZQCQRbbzCAG3ZIUF1QAF4ggG5QsL8A0AAmELCw2ISMxNAQB3BCTHCAE1BTUDNqSmr2P0x0+lAmABEALRTQAF85AbliqFhEFHQsPCJScioaekZWDm5KXn5BYVExDIBODJkAYgEhdgBaCTFdq4A2DJubqQVlVXVNNw9eyOjKEXLohLIbTmZJeb4xAxGExmeJBAAMoPsv0gmEoml+QnCkGSvUUKjUGlAQM+OVAyNRml0iLsAz6QA)\r\n\r\n### 💻 Code\r\n\r\n``` typescript\r\n// https://github.com/microsoft/TypeScript/issues/5174\r\nfunction f(x: number) {\r\n switch(x) {\r\n case 1:\r\n let x = 1;\r\n case 2:\r\n x = 2; // should be error because of TDZ\r\n }\r\n}\r\n\r\n// https://github.com/microsoft/TypeScript/issues/52924#issue-1595962667\r\nfunction h() {\r\n let result = g();\r\n let x: number = 10;\r\n return result;\r\n\r\n function g() {\r\n return x;\r\n }\r\n}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nNo error reported.\r\n\r\n### 🙂 Expected behavior\r\n\r\nTDZ check should be applied.\r\n","author":{"url":"https://github.com/yf-yang","@type":"Person","name":"yf-yang"},"datePublished":"2023-05-22T09:19:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/54343/TypeScript/issues/54343"}
| 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:5342f27b-52b6-c147-01b9-b09801393a99 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8AF6:B97C3:8D513EB:C5416ED:6A507A6A |
| html-safe-nonce | 99b7c2906031dfe62f89e22f065e6e028c3b1edc90a82f1b674411b0cc5b7b5a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUY2OkI5N0MzOjhENTEzRUI6QzU0MTZFRDo2QTUwN0E2QSIsInZpc2l0b3JfaWQiOiI0ODA1MzI5OTg5NDYwMzI3MDE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 305b78b5a191e11cee4ed35e2f09cdc72fe1fdce0b0e694296ab8c2ee4671769 |
| hovercard-subject-tag | issue:1719271400 |
| 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/54343/issue_layout |
| twitter:image | https://opengraph.githubassets.com/af125e869f22f1fd01b52ef9ff4dbc34ba886ff6431696224bca25346c98988f/microsoft/TypeScript/issues/54343 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/af125e869f22f1fd01b52ef9ff4dbc34ba886ff6431696224bca25346c98988f/microsoft/TypeScript/issues/54343 |
| og:image:alt | Bug Report It may not be a bug, because I see that you clearly know what TDZ check is (such as the code example in this issue), but it is not applied. I did find some related issues reported by Typ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yf-yang |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width