Title: Using private or protected make type checking nominal instead of structural · Issue #7755 · microsoft/TypeScript · GitHub
Open Graph Title: Using private or protected make type checking nominal instead of structural · Issue #7755 · microsoft/TypeScript
X Title: Using private or protected make type checking nominal instead of structural · Issue #7755 · microsoft/TypeScript
Description: From typings/typings#380. It's definitely unexpected and I can't understand why, but I see in the specification it's intentional. For example: export class Test { private method () {} } export class Test2 { private method () {} } export ...
Open Graph Description: From typings/typings#380. It's definitely unexpected and I can't understand why, but I see in the specification it's intentional. For example: export class Test { private method () {} } export clas...
X Description: From typings/typings#380. It's definitely unexpected and I can't understand why, but I see in the specification it's intentional. For example: export class Test { private method () {} }...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7755
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using private or protected make type checking nominal instead of structural","articleBody":"From https://github.com/typings/typings/issues/380. It's definitely unexpected and I can't understand why, but I see in the specification it's intentional. For example:\n\n``` ts\nexport class Test {\n private method () {}\n}\n\nexport class Test2 {\n private method () {}\n}\n\nexport function compare (t: Test) {}\n\ncompare(new Test2())\n```\n\n**Expected behavior:**\n\nNo error, they are structurally the same. Private and protected methods can not be used outside of the class, so it shouldn't affect assignability.\n\n**Actual behavior:** \n\n```\nindex.ts(11,9): error TS2345: Argument of type 'Test2' is not assignable to parameter of type 'Test'.\n Types have separate declarations of a private property 'method'.\n```\n\nEdit: From the issue in `typings`, I also linked to https://github.com/Microsoft/TypeScript/issues/6496 and https://github.com/Microsoft/TypeScript/issues/6365 which appear to describe the issue but only dive into workarounds instead of validating why this is happening.\n","author":{"url":"https://github.com/blakeembrey","@type":"Person","name":"blakeembrey"},"datePublished":"2016-03-31T22:19:35Z","url":"https://github.com/microsoft/TypeScript/issues/7755"}
| 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:8d2609e6-0fcd-9511-c7b8-97aca9ffe745 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA50:2679E9:1BB4D19:24EA8FD:6B0163CA |
| html-safe-nonce | d83962bbf369417763134c416cae80eb391318dc716abac75a02d57e1e2ac45a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTUwOjI2NzlFOToxQkI0RDE5OjI0RUE4RkQ6NkIwMTYzQ0EiLCJ2aXNpdG9yX2lkIjoiNzI0NTI0NTIzNDY2ODQ2MzA1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | da77e5afbd96d4813e5a364a5c628293eb1c444835e8b1d9f813b513cc5a554d |
| hovercard-subject-tag | issue:145034052 |
| 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/7755/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8df60d6320322a9c19b87712646ffc251c0a99a4effeba390921d8a804cab61c/microsoft/TypeScript/issues/7755 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8df60d6320322a9c19b87712646ffc251c0a99a4effeba390921d8a804cab61c/microsoft/TypeScript/issues/7755 |
| og:image:alt | From typings/typings#380. It's definitely unexpected and I can't understand why, but I see in the specification it's intentional. For example: export class Test { private method () {} } export clas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | blakeembrey |
| 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