Title: False positive for TS2729 (use before initialization) in 3.8.3, nightly · Issue #37573 · microsoft/TypeScript · GitHub
Open Graph Title: False positive for TS2729 (use before initialization) in 3.8.3, nightly · Issue #37573 · microsoft/TypeScript
X Title: False positive for TS2729 (use before initialization) in 3.8.3, nightly · Issue #37573 · microsoft/TypeScript
Description: TypeScript Version: 3.8.3, nightly Search Terms: used before initialization Code Reproduction requires both --target esnext and --useDefineForClassFields to be enabled. class Foo { constructor (readonly foo: boolean) {} } class Bar exten...
Open Graph Description: TypeScript Version: 3.8.3, nightly Search Terms: used before initialization Code Reproduction requires both --target esnext and --useDefineForClassFields to be enabled. class Foo { constructor (rea...
X Description: TypeScript Version: 3.8.3, nightly Search Terms: used before initialization Code Reproduction requires both --target esnext and --useDefineForClassFields to be enabled. class Foo { constructor (rea...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/37573
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False positive for TS2729 (use before initialization) in 3.8.3, nightly","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!--\r\nPlease try to reproduce the issue with the latest published version. It may have 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\n**TypeScript Version:** 3.8.3, nightly\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** used before initialization\r\n\r\n**Code**\r\n\r\nReproduction requires both `--target esnext` and `--useDefineForClassFields` to be enabled.\r\n\r\n```ts\r\nclass Foo {\r\n constructor (readonly foo: boolean) {}\r\n}\r\n\r\nclass Bar extends Foo {\r\n bar = this.calculateBar(this.foo)\r\n\r\n private calculateBar(positive: boolean) {\r\n return positive ? 1 : -1\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nCode to build.\r\n\r\nEven if TypeScript was doing some kind of flow analysis here (which could flag `this.foo` instead of `this.calculateBar`), `Foo`'s constructor is guaranteed to finish executing before `bar`'s initializer gets a chance to run; and a prototype method is never _not_ initialized.\r\n\r\n**Actual behavior:**\r\n\r\n```\r\nProperty 'calculateBar' is used before its initialization.(2729)\r\ninput.ts(8, 13): 'calculateBar' is declared here.\r\n```\r\n\r\n**Playground Link:** [Playground Link](https://www.typescriptlang.org/play/?useDefineForClassFields=true&target=99&ts=3.9.0-dev.20200323#code/MYGwhgzhAEBiD29oG8BQ0PWPAdhALgE4Cuw+8h0AFIQKZgAmuIAntAGaIBc0ARoiHo4AlCgC+qCalCQYAITCVaAD3y0cDGAiRpMfRdAC80fAAsAlhAB0wMCGDFwahYSpnLVzvGGp0mAA6E5gBuYGpYdg5OtC5U-vAQ5vghtDz88IJgIih+ehh0+MSEONDxicnBtNAA-NAAjNA8ALR1udASEkA)\r\n\r\n**Related Issues:** This seems related to #37287, just happens on different conditions\r\n","author":{"url":"https://github.com/Jessidhia","@type":"Person","name":"Jessidhia"},"datePublished":"2020-03-25T01:56:54Z","url":"https://github.com/microsoft/TypeScript/issues/37573"}
| 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:6a17b3be-8aac-3cce-966f-2136643337b5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6B8:1D8AA1:E13D6E:129DCBB:6B00F94B |
| html-safe-nonce | 768c79929bf41b47fcf9973f3f25577d16f22448f7140181110ee54ba034eafe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkI4OjFEOEFBMTpFMTNENkU6MTI5RENCQjo2QjAwRjk0QiIsInZpc2l0b3JfaWQiOiI0NDkzNjU4NzEyNjEwNzY1MTMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 07b29f52f4724174c68e879728f374c41b29b319a0fe0f974d3c3fea98bc383b |
| hovercard-subject-tag | issue:587387697 |
| 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/37573/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b58441343574abf1299e18b2d64869c418772cddd4ea8ce6154e34572b31acf1/microsoft/TypeScript/issues/37573 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b58441343574abf1299e18b2d64869c418772cddd4ea8ce6154e34572b31acf1/microsoft/TypeScript/issues/37573 |
| og:image:alt | TypeScript Version: 3.8.3, nightly Search Terms: used before initialization Code Reproduction requires both --target esnext and --useDefineForClassFields to be enabled. class Foo { constructor (rea... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jessidhia |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| 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 | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width