Title: Literal type not inferred correctly when using generics · Issue #10685 · microsoft/TypeScript · GitHub
Open Graph Title: Literal type not inferred correctly when using generics · Issue #10685 · microsoft/TypeScript
X Title: Literal type not inferred correctly when using generics · Issue #10685 · microsoft/TypeScript
Description: Version 2.0.2 type A = 'a' const z: A[] = ['a']; // fine as expected // how come 'a' cannot be inferred as type `A`? const x: A[] = Array.from(['a']) // Error: Type 'string' not assignable to 'a' // my workaround (without creating a vari...
Open Graph Description: Version 2.0.2 type A = 'a' const z: A[] = ['a']; // fine as expected // how come 'a' cannot be inferred as type `A`? const x: A[] = Array.from(['a']) // Error: Type 'string' not assignable to 'a' /...
X Description: Version 2.0.2 type A = 'a' const z: A[] = ['a']; // fine as expected // how come 'a' cannot be inferred as type `A`? const x: A[] = Array.from(['a']) // Error: Type ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/10685
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Literal type not inferred correctly when using generics","articleBody":"Version 2.0.2\n\n``` ts\ntype A = 'a'\nconst z: A[] = ['a']; // fine as expected\n\n// how come 'a' cannot be inferred as type `A`?\nconst x: A[] = Array.from(['a']) // Error: Type 'string' not assignable to 'a'\n\n// my workaround (without creating a variable):\nconst y: A[] = Array.from([_.identity\u003cA>('a')])\n```\n\nI think this may be related to https://github.com/Microsoft/TypeScript/pull/10676\n","author":{"url":"https://github.com/OliverJAsh","@type":"Person","name":"OliverJAsh"},"datePublished":"2016-09-02T16:21:53Z","url":"https://github.com/microsoft/TypeScript/issues/10685"}
| 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:0dbe9467-9211-7624-78cf-b4ceb8439517 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 936C:1A24FE:15C53C:1E7306:6AFBDE37 |
| html-safe-nonce | 8ffa3754c6176bb7d0fb97f7c094d7411b102bb6e6760e76586a7ffca748ac8d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzZDOjFBMjRGRToxNUM1M0M6MUU3MzA2OjZBRkJERTM3IiwidmlzaXRvcl9pZCI6IjQwMzUzNjEyMjk0MDM1Nzc5MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6d5dda35534673c4782037d24cfd588134f9abb74ee5d50aaffb095676f46fc0 |
| hovercard-subject-tag | issue:174797577 |
| 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/10685/issue_layout |
| twitter:image | https://opengraph.githubassets.com/62dd46cb857a3821308309bc66a9dc81efb32dc6b15e77e48bb4b59e11085f2f/microsoft/TypeScript/issues/10685 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/62dd46cb857a3821308309bc66a9dc81efb32dc6b15e77e48bb4b59e11085f2f/microsoft/TypeScript/issues/10685 |
| og:image:alt | Version 2.0.2 type A = 'a' const z: A[] = ['a']; // fine as expected // how come 'a' cannot be inferred as type `A`? const x: A[] = Array.from(['a']) // Error: Type 'string' not assignable to 'a' /... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | OliverJAsh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec |
| 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 | df859c48a4c8b4c0009c19bb4e82101aacb4b998 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width