Title: T[K] should be never when T is never · Issue #23005 · microsoft/TypeScript · GitHub
Open Graph Title: T[K] should be never when T is never · Issue #23005 · microsoft/TypeScript
X Title: T[K] should be never when T is never · Issue #23005 · microsoft/TypeScript
Description: TypeScript Version: 2.9.0-dev.20180329 Search Terms: indexed access type, index type never Code type Example
Open Graph Description: TypeScript Version: 2.9.0-dev.20180329 Search Terms: indexed access type, index type never Code type Example
X Description: TypeScript Version: 2.9.0-dev.20180329 Search Terms: indexed access type, index type never Code type Example<T extends Record<'a', string>> = T['a'] type Result1 = Examp...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23005
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"T[K] should be never when T is never","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 -->\r\n\u003c!--\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the CONTRIBUTING guidelines: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n-->\r\n\r\n\u003c!-- If you have a QUESTION:\r\n THIS IS NOT A FORUM FOR QUESTIONS.\r\n Ask questions at http://stackoverflow.com/questions/tagged/typescript\r\n or https://gitter.im/Microsoft/TypeScript\r\n-->\r\n\r\n\u003c!-- If you have a SUGGESTION:\r\n Most suggestion reports are duplicates, please search extra hard before logging a new suggestion.\r\n See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md\r\n-->\r\n\r\n\u003c!-- If you have a BUG:\r\n Please fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 2.9.0-dev.20180329\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** \r\nindexed access type, index type never\r\n\r\n**Code**\r\n```ts\r\ntype Example\u003cT extends Record\u003c'a', string>> = T['a']\r\n\r\ntype Result1 = Example\u003c{ a: \"x\" } | { a: \"y\" }> // type of Result1 is \"x\" | \"y\"\r\ntype Result2 = Example\u003c{ a: \"x\" }> // type of Result2 is \"x\"\r\ntype Result3 = Example\u003cnever> // type of Result3 is any \r\n```\r\n\r\n**Expected behavior:**\r\nType of `Result3` to be `never`\r\n\r\n**Actual behavior:**\r\nType of `Result3` is `any`\r\n\r\n**Playground Link:** \r\n[Link](https://www.typescriptlang.org/play/#src=type%20Example%3CT%20extends%20Record%3C'a'%2C%20string%3E%3E%20%3D%20T%5B'a'%5D%0D%0A%0D%0Atype%20Result1%20%3D%20Example%3C%7B%20a%3A%20%22x%22%20%7D%20%7C%20%7B%20a%3A%20%22y%22%20%7D%3E%20%2F%2F%20type%20of%20Result1%20is%20%22x%22%20%7C%20%22y%22%0D%0Atype%20Result2%20%3D%20Example%3C%7B%20a%3A%20%22x%22%20%7D%3E%20%2F%2F%20type%20of%20Result2%20is%20%20%22x%22%0D%0Atype%20Result3%20%3D%20Example%3Cnever%3E%20%2F%2F%20type%20of%20Result3%20is%20any%20)\r\n\r\n**Workaround**\r\nNow that #22042 is resolved this can be worked around with \r\n```ts\r\ntype Workaround\u003cT extends Record\u003c'a', string>> = T[(keyof T) & 'a']\r\ntype Result4 = Workaround\u003cnever> // type of Result4 is never in typescript@next\r\n```\r\n\r\n**Related Issues:**\r\nSimilar to #22042. That was about type of `T[K]` when `K` was `never` while this is about when `T` is `never`. \r\n","author":{"url":"https://github.com/kpdonn","@type":"Person","name":"kpdonn"},"datePublished":"2018-03-29T22:36:05Z","url":"https://github.com/microsoft/TypeScript/issues/23005"}
| 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:120909b8-46d9-140c-de95-361754626acf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A966:1C1B6D:BF4B00:10EAEA8:6B04605C |
| html-safe-nonce | 445edba2dde564d422939656316111ac3ba0bac93d54c7a597d7625a5a22170d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTY2OjFDMUI2RDpCRjRCMDA6MTBFQUVBODo2QjA0NjA1QyIsInZpc2l0b3JfaWQiOiI0NDY4MDAwODkxNTE3Mjk2NzMyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f9e2100e7d620e11d2509f562ebf28af22228d84771710f68d60624397abe66f |
| hovercard-subject-tag | issue:309925234 |
| 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/23005/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3a29a681bd741a94b1528c3a8f37cfe5d4647f4a2be66d7885b21fe9f5357dfc/microsoft/TypeScript/issues/23005 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3a29a681bd741a94b1528c3a8f37cfe5d4647f4a2be66d7885b21fe9f5357dfc/microsoft/TypeScript/issues/23005 |
| og:image:alt | TypeScript Version: 2.9.0-dev.20180329 Search Terms: indexed access type, index type never Code type Example |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kpdonn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| 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 | 03e114520787ad27289207f153520ef97461127c |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width