Title: Inference bug · Issue #3038 · microsoft/TypeScript · GitHub
Open Graph Title: Inference bug · Issue #3038 · microsoft/TypeScript
X Title: Inference bug · Issue #3038 · microsoft/TypeScript
Description: export function keyOf(value: { key: a; }): a { return value.key; } export interface Data { key: number; value: Date; } var data: Data[] = []; export function toKeys(values: a[], toKey: (value: a) => string): string[] { return undef...
Open Graph Description: export function keyOf(value: { key: a; }): a { return value.key; } export interface Data { key: number; value: Date; } var data: Data[] = []; export function toKeys(values: a[], toKey: (value...
X Description: export function keyOf<a>(value: { key: a; }): a { return value.key; } export interface Data { key: number; value: Date; } var data: Data[] = []; export function toKeys<a>(values: a[], t...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/3038
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inference bug","articleBody":"``` typescript\nexport function keyOf\u003ca\u003e(value: { key: a; }): a {\n return value.key;\n}\nexport interface Data {\n key: number;\n value: Date;\n}\n\nvar data: Data[] = [];\n\nexport function toKeys\u003ca\u003e(values: a[], toKey: (value: a) =\u003e string): string[] {\n return undefined;\n}\n\ntoKeys(data, keyOf); // \u003c-- actual ok, expected error, since `keyOf` should be inferred as `number` rather than `string`\n```\n\n\n\nReproduced at playground: http://www.typescriptlang.org/Playground#src=export%20function%20keyOf%3Ca%3E(value%3A%20%7B%20key%3A%20a%3B%20%7D)%3A%20a%20%7B%0A%09return%20value.key%3B%0A%7D%0Aexport%20interface%20Data%20%7B%0A%09key%3A%20number%3B%0A%09value%3A%20Date%3B%0A%7D%0A%0Avar%20data%3A%20Data%5B%5D%20%3D%20%5B%5D%3B%0A%0Aexport%20function%20toKeys%3Ca%3E(values%3A%20a%5B%5D%2C%20toKey%3A%20(value%3A%20a)%20%3D%3E%20string)%3A%20string%5B%5D%20%7B%0A%09return%20undefined%3B%0A%7D%0A%0AtoKeys(data%2C%20keyOf)%3B%20%2F%2F%20%3C--%20expected%20compile%20error%2C%20since%20keyOf%20should%20have%20inferred%20a%20as%20%60number%60%20rather%20than%20%60string%60%0A\n","author":{"url":"https://github.com/zpdDG4gta8XKpMCd","@type":"Person","name":"zpdDG4gta8XKpMCd"},"datePublished":"2015-05-05T15:29:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/3038/TypeScript/issues/3038"}
| 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:8909c200-57da-f7b9-536d-1a222e23c270 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C00:877C4:1495700:1CE4BF8:6A61C9DB |
| html-safe-nonce | 84833369b9a5172ba09142522f471c36b38134e4080c0fb362fa0a05248bfcbf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzAwOjg3N0M0OjE0OTU3MDA6MUNFNEJGODo2QTYxQzlEQiIsInZpc2l0b3JfaWQiOiIzNDA3NTM0MTQ1Njk4NjQ2NDkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5ac82b8ed703a1252b32703532849376be1d19c68b26ad1370a4c15c12799c3c |
| hovercard-subject-tag | issue:73346636 |
| 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/3038/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c99cff9b58fd3c6600315de5e4edf667adb11433e86115af4cb1ef5860f469f8/microsoft/TypeScript/issues/3038 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c99cff9b58fd3c6600315de5e4edf667adb11433e86115af4cb1ef5860f469f8/microsoft/TypeScript/issues/3038 |
| og:image:alt | export function keyOf(value: { key: a; }): a { return value.key; } export interface Data { key: number; value: Date; } var data: Data[] = []; export function toKeys(values: a[], toKey: (value... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zpdDG4gta8XKpMCd |
| hostname | github.com |
| expected-hostname | github.com |
| None | b2de8c74e5e61e893155ba46ee41bc66170c1644cb795adefa8386d490f7781c |
| 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 | d1866027ded575df8a15c731dd8b9986c9483ceb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width