Title: Array not assignable to ReadonlyArray with subclass items · Issue #10368 · microsoft/TypeScript · GitHub
Open Graph Title: Array not assignable to ReadonlyArray with subclass items · Issue #10368 · microsoft/TypeScript
X Title: Array not assignable to ReadonlyArray with subclass items · Issue #10368 · microsoft/TypeScript
Description: TypeScript Version: 2.0.0 Code class A { a: string; } class B extends A { b: string; } function f(a: ReadonlyArray): void { } f([new A()]); // OK f([new A(), new B()]); // OK f([new B()]); // Error Expected behavior: To compile. Actua...
Open Graph Description: TypeScript Version: 2.0.0 Code class A { a: string; } class B extends A { b: string; } function f(a: ReadonlyArray): void { } f([new A()]); // OK f([new A(), new B()]); // OK f([new B()]); // Er...
X Description: TypeScript Version: 2.0.0 Code class A { a: string; } class B extends A { b: string; } function f(a: ReadonlyArray<A>): void { } f([new A()]); // OK f([new A(), new B()]); // OK f([new B()]);...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/10368
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Array not assignable to ReadonlyArray with subclass items","articleBody":"**TypeScript Version:** 2.0.0\n\n**Code**\n\n``` ts\nclass A {\n a: string;\n}\nclass B extends A {\n b: string;\n}\nfunction f(a: ReadonlyArray\u003cA>): void { }\nf([new A()]); // OK\nf([new A(), new B()]); // OK\nf([new B()]); // Error\n```\n\n**Expected behavior:**\nTo compile.\n\n**Actual behavior:** \nerror TS2345: Argument of type 'B[]' is not assignable to parameter of type 'ReadonlyArray\u003cA>'.\n Types of property 'concat' are incompatible.\n Type '(...items: (B | B[])[]) => B[]' is not assignable to type '{ \u003cU extends ReadonlyArray\u003cA>>(...items: U[]): A[]; (...items: A[]): A[]; }'.\n Types of parameters 'items' and 'items' are incompatible.\n Type 'A' is not assignable to type 'B | B[]'.\n Type 'A' is not assignable to type 'B[]'.\n Property 'length' is missing in type 'A'.\n","author":{"url":"https://github.com/stephanedr","@type":"Person","name":"stephanedr"},"datePublished":"2016-08-16T15:15:22Z","url":"https://github.com/microsoft/TypeScript/issues/10368"}
| 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:dbc055f2-063f-70be-8f4e-32f102206e43 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBAA:3F4253:D69EAE:11E7F30:6B01026D |
| html-safe-nonce | 33781642c8bd51451f6152b6b20f8d60d5b89bfab62c71c6d701b60700b73ea0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkFBOjNGNDI1MzpENjlFQUU6MTFFN0YzMDo2QjAxMDI2RCIsInZpc2l0b3JfaWQiOiI1MTY0ODI4NTUzMjYyNDY1NjQ1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8311d77aa6b96a688dbb9827d45e715d34dbee6e9c5e46455455ee4c4556cc48 |
| hovercard-subject-tag | issue:171441205 |
| 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/10368/issue_layout |
| twitter:image | https://opengraph.githubassets.com/76da05bf45d728d33e414694f6b1297cb0fb32231f4d056e95536bd1801ce633/microsoft/TypeScript/issues/10368 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/76da05bf45d728d33e414694f6b1297cb0fb32231f4d056e95536bd1801ce633/microsoft/TypeScript/issues/10368 |
| og:image:alt | TypeScript Version: 2.0.0 Code class A { a: string; } class B extends A { b: string; } function f(a: ReadonlyArray): void { } f([new A()]); // OK f([new A(), new B()]); // OK f([new B()]); // Er... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stephanedr |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width