Title: error TS2612 Property will overwrite base property not raised if "strictNullCheck" is true · Issue #48667 · microsoft/TypeScript · GitHub
Open Graph Title: error TS2612 Property will overwrite base property not raised if "strictNullCheck" is true · Issue #48667 · microsoft/TypeScript
X Title: error TS2612 Property will overwrite base property not raised if "strictNullCheck" is true · Issue #48667 · microsoft/TypeScript
Description: Bug Report If you enable useDefineForClassFields then a new error is possible TS26126 If you have code that trigger TS2612 Property 'xxx' will overwrite the base propert in 'yyy'. It this is intentional, add an initializer. Othertwise, a...
Open Graph Description: Bug Report If you enable useDefineForClassFields then a new error is possible TS26126 If you have code that trigger TS2612 Property 'xxx' will overwrite the base propert in 'yyy'. It this is intent...
X Description: Bug Report If you enable useDefineForClassFields then a new error is possible TS26126 If you have code that trigger TS2612 Property 'xxx' will overwrite the base propert in 'yyy'. I...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/48667
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"error TS2612 Property will overwrite base property not raised if \"strictNullCheck\" is true","articleBody":"# Bug Report\r\n\r\nIf you enable [useDefineForClassFields](https://www.typescriptlang.org/tsconfig#useDefineForClassFields) then a new error is possible TS26126\r\n\r\nIf you have code that trigger TS2612 Property 'xxx' will overwrite the base propert in 'yyy'. It this is intentional, add an initializer. Othertwise, add a \"declare\" modifier or remove the redundant declaration.\r\n\r\nThe error do not appear if you enable strictNullCheck.\r\n\r\nWithout strictNullCheck you'll see this error.\r\n\r\nIf you put strict=true or strictNullCheck=true the error is not reported anymore\r\n\r\n### 🔎 Search Terms\r\n\r\nTS2612\r\nstrictNullCheck\r\n\r\n### 🕗 Version & Regression Information\r\n\r\nNoticed this on typescript 4.6.3\r\nTested on typescript@nightly 4.7.0-dev.20220408 and it behave the same (no error on strict mode)\r\nTested on 4.3.5 and it behave the same (no error on strict mode)\r\n\r\nTS2612 was introduced in 4.3 so previous version do not make sense\r\n\r\n### ⏯ Playground Link\r\n\r\nThis link contain a minimal code to show the problem but you need to enable/disable strictNullCheck and [useDefineForClassFields](https://www.typescriptlang.org/tsconfig#useDefineForClassFields) to see it in action\r\n\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?ssl=33&ssc=2&pln=10&pc=1#code/PTAEHUFMBsGMHsC2lQBd5oBYoCoE8AHSAZVgCcBLA1UABWgEM8BzM+AVwDsATAGiwoBnUENANQAd0gAjQRVSQAUCEmYKsTKGYUAbpGF4OY0BoadYKdJMoL+gzAzIoz3UNEiPOofEVKVqAHSKymAAmkYI7NCuqGqcANag8ABmIjQUXrFOKBJMggBcISGgoAC0oACCbvCwDKgU8JkY7p7ehCTkVDQS2E6gnPCxGcwmZqDSTgzxxWWVoASMFmgYkAAeRJTInN3ymj4d-jSCeNsMq-wuoPaOltigAKoASgAywhK7SbGQZIIz5VWCFzSeCrZagNYbChbHaxUDcCjJZLfSDbExIAgUdxkUBIursJzCFJtXydajBVDtUAAIQYghQAF5QABvRQlErSWmQfJXVCUTjMADcigAvkLFBSiKAACLfXSQVyMml00AAMmZrLZ3Flem43MEvOGQuFwVgjEEwiqLLZ8zYBG5SsgYutCE4+rI7Fg6DIAAoCLaAPz2zkASnV1utQ0EAT98AIoEZMbj-v9zPGnO5ACIOXSM6BRRqSsbjYpTbThFTwasFDwLWG2YnuTLKDqnWyXW6PV7fbbG9r5aGreGSoJ2BtvcGhUOSpHo7b4zbY5O2UXgiocM0PGQvIh4H0GMD2DQvm4zMx2AxmJB+Kb1Il9-A9CIvBmAKKrBiIBb6XO70AZ8AOKgADkwgAHKQBIGZBCoADyXxkO8dL8JeRyoI4CiuNIeCgE4O46MMWD6CgCCINCwiXMeEi7tEIgGBw2ILEwrAcDwQQlEAA)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\ntype Base = {\r\n base: string;\r\n};\r\n\r\ntype Derived = Base & {\r\n derived: string;\r\n}\r\n\r\nclass A {\r\n prop: Base;\r\n\r\n constructor(prop?: Base) {\r\n this.prop = prop ?? { base: \"base\" };\r\n }\r\n}\r\n\r\nclass B extends A {\r\n // This should trigger TS2612 but does not do it with strictNullCheck enabled\r\n prop: Derived;\r\n\r\n constructor(prop: Derived) {\r\n super();\r\n this.prop = prop;\r\n }\r\n}\r\n\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nWhen compiled with:\r\n* target - esnext\r\n* useDefineConfigForClass - true\r\n* strictNullCheck - true\r\n\r\nthe code does not raise any error\r\n\r\n\r\n### 🙂 Expected behavior\r\n\r\nIt should raise the TS2612 error\r\n","author":{"url":"https://github.com/amodiopescefaro","@type":"Person","name":"amodiopescefaro"},"datePublished":"2022-04-13T13:06:01Z","url":"https://github.com/microsoft/TypeScript/issues/48667"}
| 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:12419c87-966b-1d37-ddc0-9bb1fef1c55a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 88F0:6DC60:1BFB42B:23416B2:6B018AFE |
| html-safe-nonce | 786443236657fec43053061fdc00b0cff82ebdaa4145adc67eba8d4793bf5c36 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEYwOjZEQzYwOjFCRkI0MkI6MjM0MTZCMjo2QjAxOEFGRSIsInZpc2l0b3JfaWQiOiIyOTk4NjYxNzk3NTI0OTAwNjA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b63765988f1aa23d3388b61badafaf91102d70b7c185402772743aa7558a8f02 |
| hovercard-subject-tag | issue:1203275636 |
| 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/48667/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8cca37d320c9bfd79b6a6d6da711a5fcd6173d934a577059b1c0953d4ac35a48/microsoft/TypeScript/issues/48667 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8cca37d320c9bfd79b6a6d6da711a5fcd6173d934a577059b1c0953d4ac35a48/microsoft/TypeScript/issues/48667 |
| og:image:alt | Bug Report If you enable useDefineForClassFields then a new error is possible TS26126 If you have code that trigger TS2612 Property 'xxx' will overwrite the base propert in 'yyy'. It this is intent... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | amodiopescefaro |
| 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