Title: Unexpected error/bad inference for generic composed function inside `pipe` · Issue #25791 · microsoft/TypeScript · GitHub
Open Graph Title: Unexpected error/bad inference for generic composed function inside `pipe` · Issue #25791 · microsoft/TypeScript
X Title: Unexpected error/bad inference for generic composed function inside `pipe` · Issue #25791 · microsoft/TypeScript
Description: TypeScript Version: 2.9.2 Search Terms: index signature pipe generic lost dictionary Code declare function pipe
Open Graph Description: TypeScript Version: 2.9.2 Search Terms: index signature pipe generic lost dictionary Code declare function pipe
X Description: TypeScript Version: 2.9.2 Search Terms: index signature pipe generic lost dictionary Code declare function pipe<V0, T1, T2, T3>( fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) =&g...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/25791
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpected error/bad inference for generic composed function inside `pipe`","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\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 FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n--\u003e\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --\u003e\r\n**TypeScript Version:** 2.9.2\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) --\u003e\r\n**Search Terms:** index signature pipe generic lost dictionary\r\n\r\n**Code**\r\n\r\n```ts\r\ndeclare function pipe\u003cV0, T1, T2, T3\u003e(\r\n fn0: (x: V0) =\u003e T1,\r\n fn1: (x: T1) =\u003e T2,\r\n fn2: (x: T2) =\u003e T3,\r\n): (x: V0) =\u003e T3;\r\n\r\ndeclare function getStringDict(): { [index: string]: string };\r\n\r\ndeclare function stringDictIdentity\u003cT\u003e(stringDict: {\r\n [index: string]: T;\r\n}): { [index: string]: T };\r\n\r\n/*\r\nWithout strict enabled:\r\nExpected type (x: {}) =\u003e { [index: string]: string; }\r\nActual type (x: {}) =\u003e { [index: string]: {}; }\r\n\r\nWith strict enabled, unexpected type error:\r\nArgument of type '\u003cT\u003e(stringDict: { [index: string]: T; }) =\u003e { [index: string]: T; }' is not assignable to parameter of type '(x: {}) =\u003e { [index: string]: {}; }'.\r\n Types of parameters 'stringDict' and 'x' are incompatible.\r\n Type '{}' is not assignable to type '{ [index: string]: {}; }'.\r\n Index signature is missing in type '{}'.\r\n */\r\nconst fn = pipe(\r\n getStringDict,\r\n x =\u003e x,\r\n stringDictIdentity,\r\n);\r\n\r\n//\r\n// Workarounds\r\n//\r\n\r\ndeclare function identity\u003cT\u003e(a: T): T;\r\nconst fn2 = pipe(\r\n getStringDict,\r\n identity,\r\n stringDictIdentity,\r\n);\r\n\r\nconst fn3 = pipe(\r\n getStringDict,\r\n x =\u003e x,\r\n x =\u003e stringDictIdentity(x),\r\n);\r\n```\r\n","author":{"url":"https://github.com/OliverJAsh","@type":"Person","name":"OliverJAsh"},"datePublished":"2018-07-19T09:51:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/25791/TypeScript/issues/25791"}
| 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:768bf3d5-2566-6455-0657-30e8763975bc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE04:5C27C:3051:41E2:6A61CE87 |
| html-safe-nonce | 406528b91e61702fc48acb68f9b6870cd0ff79b1ffc2c6c70bb4e3ec7b682a1c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTA0OjVDMjdDOjMwNTE6NDFFMjo2QTYxQ0U4NyIsInZpc2l0b3JfaWQiOiI2ODUxNjMwMTUyMjAyNDQwMzI4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 293f5b95bd8043e74f4f0a6d294a36d042e0f390b9b9de61a023d3dac9b27aac |
| hovercard-subject-tag | issue:342658128 |
| 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/25791/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0143fb97df7e71c3a59f5872b54ee02b872b210a021fbcd71c60cbd42a0161f7/microsoft/TypeScript/issues/25791 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0143fb97df7e71c3a59f5872b54ee02b872b210a021fbcd71c60cbd42a0161f7/microsoft/TypeScript/issues/25791 |
| og:image:alt | TypeScript Version: 2.9.2 Search Terms: index signature pipe generic lost dictionary Code declare function pipe |
| 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 | 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