Title: compilerOptions support TDZ error option · Issue #33576 · microsoft/TypeScript · GitHub
Open Graph Title: compilerOptions support TDZ error option · Issue #33576 · microsoft/TypeScript
X Title: compilerOptions support TDZ error option · Issue #33576 · microsoft/TypeScript
Description: According to the PR of #32221 , to prevent such problem like: (function () { function cleanup() { console.log(A); // throw error } cleanup(); const A = 1; }()); this snippet will compile into: (function () { function cleanup() { console....
Open Graph Description: According to the PR of #32221 , to prevent such problem like: (function () { function cleanup() { console.log(A); // throw error } cleanup(); const A = 1; }()); this snippet will compile into: (fun...
X Description: According to the PR of #32221 , to prevent such problem like: (function () { function cleanup() { console.log(A); // throw error } cleanup(); const A = 1; }()); this snippet will compile into: (fun...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/33576
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"compilerOptions support TDZ error option","articleBody":"According to the PR of #32221 , to prevent such problem like: \r\n\r\n```typescript\r\n(function () {\r\n function cleanup() {\r\n console.log(A); // throw error\r\n }\r\n\r\n cleanup();\r\n const A = 1;\r\n}());\r\n```\r\n\r\nthis snippet will compile into:\r\n\r\n```javascript\r\n(function () {\r\n function cleanup() {\r\n console.log(A); // log undefined\r\n }\r\n cleanup();\r\n var A = 1;\r\n}());\r\n```\r\n\r\nError in the first snippet will be ignored, and cause TDZ error. Can `tsc` support TDZ error enabled option like [babel-plugin-transform-block-scoping](https://babeljs.io/docs/en/next/babel-plugin-transform-block-scoping.html) ? It will notify peoples who write such pattern to prevent further weird problems.\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [ ] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [ ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n","author":{"url":"https://github.com/kyle7zhang","@type":"Person","name":"kyle7zhang"},"datePublished":"2019-09-24T13:00:20Z","url":"https://github.com/microsoft/TypeScript/issues/33576"}
| 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:f4ca9ec2-f4a2-6cb5-e417-c3eaac79ca50 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9564:DA744:2787FF4:3537606:6B01BF3C |
| html-safe-nonce | 728f88df7f3324f77539955aa09fcecae7d4b7a7167f5d9e8d33eeba9f13270f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTY0OkRBNzQ0OjI3ODdGRjQ6MzUzNzYwNjo2QjAxQkYzQyIsInZpc2l0b3JfaWQiOiI1MDA0Njk5MjIzMTQxMjM2NTQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 66019d663c7097496179ff80b829351386dfb96b854d8df3e0e6d35349246ded |
| hovercard-subject-tag | issue:497673271 |
| 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/33576/issue_layout |
| twitter:image | https://opengraph.githubassets.com/70f10dd6f88a8b6c3bd9278dd1346c745db0118add0cd018363358d2c2e7f097/microsoft/TypeScript/issues/33576 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/70f10dd6f88a8b6c3bd9278dd1346c745db0118add0cd018363358d2c2e7f097/microsoft/TypeScript/issues/33576 |
| og:image:alt | According to the PR of #32221 , to prevent such problem like: (function () { function cleanup() { console.log(A); // throw error } cleanup(); const A = 1; }()); this snippet will compile into: (fun... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kyle7zhang |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width