Title: TS demands that abstract properties with type never are implemented · Issue #55121 · microsoft/TypeScript · GitHub
Open Graph Title: TS demands that abstract properties with type never are implemented · Issue #55121 · microsoft/TypeScript
X Title: TS demands that abstract properties with type never are implemented · Issue #55121 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms abstract property inheritance never 🕗 Version & Regression Information Current nightly v5.2.0-dev.20230720 ⏯ Playground Link Playground 💻 Code abstract class P { abstract foo: never } class C extends P {} // err...
Open Graph Description: Bug Report 🔎 Search Terms abstract property inheritance never 🕗 Version & Regression Information Current nightly v5.2.0-dev.20230720 ⏯ Playground Link Playground 💻 Code abstract class P { abstract ...
X Description: Bug Report 🔎 Search Terms abstract property inheritance never 🕗 Version & Regression Information Current nightly v5.2.0-dev.20230720 ⏯ Playground Link Playground 💻 Code abstract class P { abstr...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/55121
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS demands that abstract properties with type never are implemented","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\nabstract property inheritance never\r\n\r\n### 🕗 Version & Regression Information\r\n\r\nCurrent nightly v5.2.0-dev.20230720\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground](https://www.typescriptlang.org/play?#code/IYIwzgLgTsDGEAJYBthjAgCgg3gKAQVEhngQDMB7SgLgQDsBTAN0ajwF888U0MBhBIwAeERvQAmGbDg4IA9PKFQolKAkETKjDPUqIAlgFsADskZHxiKpW690CACJDR4qVlwEK1Ok1brFLFUTNggATwQAchtIhAALNAZKBAN6AwgDYGQDAC82IkkU3X0ECUZyVPTGZAi+AwBzJgkU+gQIOMYkSnoSAFd4NQA6TiA)\r\n\r\n### 💻 Code\r\n\r\n```ts\r\nabstract class P {\r\n abstract foo: never\r\n}\r\n\r\nclass C extends P {} // error C does not implement foo\r\n\r\nclass D extends P {\r\n foo: never // Property 'foo' has no initializer and is not definitely assigned in the constructor.\r\n}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nError in class C, TS demands foo to be implemented.\r\n\r\n### 🙂 Expected behavior\r\n\r\nclass C should not produce an error. Absence of foo matches the type constraint in P.\r\n\r\n### Comments\r\n\r\nI suppose this is a bug - certainly I did not expect TS to ask me to implement a property with type never. A function with a type never argument would not let me pass it, and I expected abstract properties to be similar.\r\n\r\n```ts\r\nfunction f(a: never) {}\r\nf(true) // error\r\n```\r\n\r\n\"Fixing\" this provides the benefit of being able to create optional abstract properties, e.g. \r\n\r\n```ts\r\nabstract class P {\r\n abstract foo: boolean | never\r\n}\r\n\r\nclass C extends P {} // TS should allow this child class, because of the never option.\r\n```\r\n\r\nRelates to [#40635](https://github.com/microsoft/TypeScript/issues/40635) (Optional abstract properties)","author":{"url":"https://github.com/RobertSandiford","@type":"Person","name":"RobertSandiford"},"datePublished":"2023-07-23T21:37:57Z","url":"https://github.com/microsoft/TypeScript/issues/55121"}
| 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:5ebadaf2-f6d0-df91-9193-cf4c4b033553 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB30:158DF1:ED3839:13970F5:6B01D3C1 |
| html-safe-nonce | ba2443418aea21086f7136e3057f279ddcea87346b04757a19a2e9ffbff35d5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjMwOjE1OERGMTpFRDM4Mzk6MTM5NzBGNTo2QjAxRDNDMSIsInZpc2l0b3JfaWQiOiIzMTY2MzAxMDkyNzExNjE3NDczIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ea1db0212766b602380a142de945e91db08410b276112053b231aab076a33f55 |
| hovercard-subject-tag | issue:1817304179 |
| 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/55121/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8cbcfaed7cc307f30a0060c77e12bb299d27471ed03113986e382a80308f1b70/microsoft/TypeScript/issues/55121 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8cbcfaed7cc307f30a0060c77e12bb299d27471ed03113986e382a80308f1b70/microsoft/TypeScript/issues/55121 |
| og:image:alt | Bug Report 🔎 Search Terms abstract property inheritance never 🕗 Version & Regression Information Current nightly v5.2.0-dev.20230720 ⏯ Playground Link Playground 💻 Code abstract class P { abstract ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RobertSandiford |
| 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