Title: Incorrect overload is used for composed function inside `pipe` · Issue #25637 · microsoft/TypeScript · GitHub
Open Graph Title: Incorrect overload is used for composed function inside `pipe` · Issue #25637 · microsoft/TypeScript
X Title: Incorrect overload is used for composed function inside `pipe` · Issue #25637 · microsoft/TypeScript
Description: TypeScript Version: 2.9.2 Search Terms: generic function pipe contextual type wrong overload Code These examples are stripped down versions of Node's parse function in the querystring module and Lodash's values and fromPairs functions. T...
Open Graph Description: TypeScript Version: 2.9.2 Search Terms: generic function pipe contextual type wrong overload Code These examples are stripped down versions of Node's parse function in the querystring module and Lo...
X Description: TypeScript Version: 2.9.2 Search Terms: generic function pipe contextual type wrong overload Code These examples are stripped down versions of Node's parse function in the querystring module an...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/25637
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect overload is used for 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:** generic function pipe contextual type wrong overload\r\n\r\n**Code**\r\n\r\nThese examples are stripped down versions of Node's `parse` function in the `querystring` module and Lodash's `values` and `fromPairs` functions.\r\n\r\nThese are issues we ran into when trying to use these functions with a `pipe` function.\r\n\r\n```ts\r\ndeclare function pipe\u003cA, B, C\u003e(ab: (a: A) =\u003e B, bc: (b: B) =\u003e C): (a: A) =\u003e C;\r\n\r\n{\r\n type ParsedUrlQuery = { [index: string]: string };\r\n declare function parsedUrlQueryString(str: string): ParsedUrlQuery;\r\n declare function parsedUrlQueryString\u003cT extends {}\u003e(str: string): T;\r\n\r\n declare const stringToString: (s: string) =\u003e string;\r\n\r\n // $ExpectType (a: string) =\u003e ParsedUrlQuery\r\n // but got (a: string) =\u003e {}\r\n // Note: if we comment out the last overload for `parsedUrlQueryString`, we get the expected\r\n // type.\r\n const fn = pipe(\r\n stringToString,\r\n parsedUrlQueryString,\r\n );\r\n}\r\n\r\n{\r\n declare function values\u003cT\u003e(object: { [index: string]: T } | null | undefined): T[];\r\n declare function values\u003cT extends object\u003e(object: T | null | undefined): Array\u003cT[keyof T]\u003e;\r\n declare function values(object: any): any[];\r\n\r\n declare const stringDictToStringDict: (\r\n sd: { [index: string]: string },\r\n ) =\u003e { [index: string]: string };\r\n\r\n // $ExpectType (a: { [index: string]: string; }) =\u003e string[]\r\n // but got (a: { [index: string]: string; }) =\u003e any[]\r\n // Note: if we comment out the last two overloads for `values`, we get the expected type.\r\n const fn = pipe(\r\n stringDictToStringDict,\r\n values,\r\n );\r\n}\r\n\r\n{\r\n declare function fromPairs\u003cT\u003e(pairs: [string, T][] | null | undefined): { [index: string]: T };\r\n declare function fromPairs(pairs: any[][] | null | undefined): { [index: string]: any };\r\n\r\n // $ExpectType (a: {}) =\u003e { [index: string]: number; }\r\n // but got (a: {}) =\u003e { [index: string]: any; }\r\n // Note: if we comment out the last overload for `fromPairs`, we get the expected type.\r\n const fn = pipe(\r\n ({ }: {}): [string, number][] =\u003e [['foo', 1]],\r\n fromPairs,\r\n );\r\n}\r\n```","author":{"url":"https://github.com/OliverJAsh","@type":"Person","name":"OliverJAsh"},"datePublished":"2018-07-13T11:07:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":19},"url":"https://github.com/25637/TypeScript/issues/25637"}
| 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:39e561dd-9769-6643-849f-236964b58938 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8F82:90F18:1DDAA0:29183B:6A626730 |
| html-safe-nonce | 9db1a95a9682f8c932482745b11c2fa0404d0106d232d53158ee975588e08a1e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjgyOjkwRjE4OjFEREFBMDoyOTE4M0I6NkE2MjY3MzAiLCJ2aXNpdG9yX2lkIjoiODY0NjE5MTc2NzY0NDk1NjQ2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bc16a25f5edd191cdbee3272d9a7c6c3fe4995b726bfd07d8a9ee972a169a262 |
| hovercard-subject-tag | issue:340978104 |
| 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/25637/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e8ebe49ec190820106e2ae6b3c1e59e51b4b7641bba1d06117af71998e4a9c5e/microsoft/TypeScript/issues/25637 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e8ebe49ec190820106e2ae6b3c1e59e51b4b7641bba1d06117af71998e4a9c5e/microsoft/TypeScript/issues/25637 |
| og:image:alt | TypeScript Version: 2.9.2 Search Terms: generic function pipe contextual type wrong overload Code These examples are stripped down versions of Node's parse function in the querystring module and Lo... |
| 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 | 194bddaed53c0eb07047629c520853f4208e77a17ff57428346485cc202e39f2 |
| 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 | c2862cf2db52f0c7f6cba3de21ffeeafe7c5456e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width