Title: Allow default methods/instance variables in interfaces · Issue #3536 · microsoft/TypeScript · GitHub
Open Graph Title: Allow default methods/instance variables in interfaces · Issue #3536 · microsoft/TypeScript
X Title: Allow default methods/instance variables in interfaces · Issue #3536 · microsoft/TypeScript
Description: This would be epic to have. Java itself had a problem with forcing the implementing class to implement the abstract methods, and solved it with default interface implementations. Sometimes, multiple inheritance is necessary to have. For ...
Open Graph Description: This would be epic to have. Java itself had a problem with forcing the implementing class to implement the abstract methods, and solved it with default interface implementations. Sometimes, multipl...
X Description: This would be epic to have. Java itself had a problem with forcing the implementing class to implement the abstract methods, and solved it with default interface implementations. Sometimes, multipl...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/3536
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow default methods/instance variables in interfaces","articleBody":"This would be epic to have. Java itself had a problem with forcing the implementing class to implement the abstract methods, and solved it with default interface implementations. Sometimes, multiple inheritance is necessary to have. For example, I have a sea of crisscrossing is-a relationships to handle, with a ton of things like the following:\n\n``` ts\nclass Identifier extends Node implements Assignable, ImportPatternEntry,\n IdentifierLike, PropertyLike, Subtypable {\n // stuff...\n}\n\nclass MemberExpression extends Node implements Assignable,\n IdentifierLike, PropertyLike, Subtypable {\n // stuff...\n}\n```\n\nIt's not pretty, but I also have to check many of these relationships at runtime as well. I can't use traditional single inheritance for this, either, because none of these are mutually exclusive. I would love to have ways to set default properties on these classes, to where I don't have to make a build script to generate all this. (I have 30+ base classes and 20+ interfaces with very intertwined relationships like the above.)\n\nWhat I was thinking of was something like this:\n\n``` ts\ninterface IFoo {\n bar = true;\n}\n\nclass Foo {}\n\nclass Bar implements IFoo {}\n\nnew Foo().bar; // undefined\nnew Bar().bar; // true\n```\n","author":{"url":"https://github.com/dead-claudia","@type":"Person","name":"dead-claudia"},"datePublished":"2015-06-17T06:48:41Z","url":"https://github.com/microsoft/TypeScript/issues/3536"}
| 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:1b2fd62f-292c-0db0-f8fa-e119a780352c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C114:A20F9:70081B:97487B:6B00D758 |
| html-safe-nonce | 0dc8d843f55aee1f6c83be652697da537446e794bd22d3eac973193d0a16a56d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTE0OkEyMEY5OjcwMDgxQjo5NzQ4N0I6NkIwMEQ3NTgiLCJ2aXNpdG9yX2lkIjoiMzcxMzQzOTkxODYwMTU5MDYxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bb8b64c56c9e5b7810ca111cdbb55c812fd9057d52267c835bb67434b7ce4eb3 |
| hovercard-subject-tag | issue:88930408 |
| 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/3536/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ebad975cbbda764f1fc20f5750ec65c862e5b2e2add4f72e371c7f7d08ff16d9/microsoft/TypeScript/issues/3536 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ebad975cbbda764f1fc20f5750ec65c862e5b2e2add4f72e371c7f7d08ff16d9/microsoft/TypeScript/issues/3536 |
| og:image:alt | This would be epic to have. Java itself had a problem with forcing the implementing class to implement the abstract methods, and solved it with default interface implementations. Sometimes, multipl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dead-claudia |
| hostname | github.com |
| expected-hostname | github.com |
| None | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| 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 | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width