Title: react-redux type inference is broken since v3.1 · Issue #30874 · microsoft/TypeScript · GitHub
Open Graph Title: react-redux type inference is broken since v3.1 · Issue #30874 · microsoft/TypeScript
X Title: react-redux type inference is broken since v3.1 · Issue #30874 · microsoft/TypeScript
Description: TypeScript Version: 3.1.0-dev.20180810 Search Terms: react-redux connect type inference I've noticed this issue while upgrading from v3.0.3. Type inferrence got broken on some of redux's connect calls. I was able to isolate the issue (se...
Open Graph Description: TypeScript Version: 3.1.0-dev.20180810 Search Terms: react-redux connect type inference I've noticed this issue while upgrading from v3.0.3. Type inferrence got broken on some of redux's connect ca...
X Description: TypeScript Version: 3.1.0-dev.20180810 Search Terms: react-redux connect type inference I've noticed this issue while upgrading from v3.0.3. Type inferrence got broken on some of redux's co...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/30874
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"react-redux type inference is broken since v3.1","articleBody":"\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.1.0-dev.20180810\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** react-redux connect type inference\r\n\r\nI've noticed this issue while upgrading from v3.0.3. Type inferrence got broken on some of redux's `connect` calls. I was able to isolate the issue (see the code below). The issue is reproducible on `@next` and `@latest`. I ran some regression tests and was able to narrow it down to `3.1.0-dev.20180810` where the bug was introduced. The last version where the code works as expected was `3.1.0-dev.20180809`.\r\n\r\n**Code**\r\n\r\n```ts\r\ntype MapStateToProps\u003cTStateProps> = () => TStateProps;\r\n\r\ntype MergeProps\u003cTStateProps, TMergedProps> = (stateProps: TStateProps) => TMergedProps;\r\n\r\nfunction connect\u003cTStateProps = {}, TMergedProps = {}>(\r\n mapStateToProps: MapStateToProps\u003cTStateProps>,\r\n mergeProps: MergeProps\u003cTStateProps, TMergedProps>) {\r\n}\r\n\r\nconnect(() => ({ time: 123 }), ({ time }) => ({\r\n time,\r\n doSomething() {\r\n },\r\n}))\r\n```\r\n\r\n**Expected behavior:** compiles without errors\r\n\r\n**Actual behavior:** `error TS2459: Type 'TStateProps' has no property 'time' and no string index signature.`\r\n\r\n**Playground Link:** [here](https://www.typescriptlang.org/play/#src=type%20MapStateToProps%3CTStateProps%3E%20%3D%20()%20%3D%3E%20TStateProps%3B%0D%0A%0D%0Atype%20MergeProps%3CTStateProps%2C%20TMergedProps%3E%20%3D%20(stateProps%3A%20TStateProps)%20%3D%3E%20TMergedProps%3B%0D%0A%0D%0Afunction%20connect%3CTStateProps%20%3D%20%7B%7D%2C%20TMergedProps%20%3D%20%7B%7D%3E(%0D%0A%20%20%20mapStateToProps%3A%20MapStateToProps%3CTStateProps%3E%2C%0D%0A%20%20%20mergeProps%3A%20MergeProps%3CTStateProps%2C%20TMergedProps%3E)%20%7B%0D%0A%7D%0D%0A%0D%0Aconnect(()%20%3D%3E%20(%7B%20time%3A%20123%20%7D)%2C%20(%7B%20time%20%7D)%20%3D%3E%20%7B%0D%0A%20%20%20return%20%7B%0D%0A%20%20%20%20%20%20time%2C%0D%0A%20%20%20%20%20%20doSomething()%20%7B%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%7D%0D%0A%7D)%0D%0A%0D%0Aconnect(()%20%3D%3E%20(%7B%20time%3A%20123%20%7D)%2C%20(%7B%20time%20%7D)%20%3D%3E%20(%7B%0D%0A%20%20%20doSomething()%20%7B%0D%0A%20%20%20%7D%2C%0D%0A%7D))%0D%0A%0D%0A%0D%0Aconnect(()%20%3D%3E%20(%7B%20time%3A%20123%20%7D)%2C%20(%7B%20time%20%7D)%20%3D%3E%20(%7B%0D%0A%20%20%20time%2C%0D%0A%20%20%20doSomething%3A%20()%20%3D%3E%20%7B%0D%0A%20%20%20%7D%2C%0D%0A%7D))%0D%0A%0D%0A%0D%0Aconnect(()%20%3D%3E%20(%7B%20time%3A%20123%20%7D)%2C%20(%7B%20time%20%7D)%20%3D%3E%20(%7B%0D%0A%20%20%20time%2C%0D%0A%20%20%20doSomething()%20%7B%0D%0A%20%20%20%7D%2C%0D%0A%7D))%0D%0A)\r\n\r\nSomehow these examples compile without problem though:\r\n```ts\r\n// no 'expression body' in C# terms\r\nconnect(() => ({ time: 123 }), ({ time }) => {\r\n return {\r\n time,\r\n doSomething() {\r\n },\r\n }\r\n})\r\n\r\n// no 'time' on TMergedProps\r\nconnect(() => ({ time: 123 }), ({ time }) => ({\r\n doSomething() {\r\n },\r\n}))\r\n\r\n// property instead of a function\r\nconnect(() => ({ time: 123 }), ({ time }) => ({\r\n time,\r\n doSomething: () => {\r\n },\r\n}))\r\n```","author":{"url":"https://github.com/Torvin","@type":"Person","name":"Torvin"},"datePublished":"2019-04-12T00:17:51Z","url":"https://github.com/microsoft/TypeScript/issues/30874"}
| 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:97cf64e8-6071-f0be-6ad9-8bfb804c84ca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8370:172B92:28380EC:359A3B6:6B01B458 |
| html-safe-nonce | 97ab367d107f446e3f67af308b960e9402d0e845abf2196f03a9ffc04e01a66a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzcwOjE3MkI5MjoyODM4MEVDOjM1OUEzQjY6NkIwMUI0NTgiLCJ2aXNpdG9yX2lkIjoiNTQ2MTEzNzg3NDU2NzE0ODYzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f67e9411cdc785de3829d2f449bee492f9636ee03ee91bc9c7326794f553c207 |
| hovercard-subject-tag | issue:432334206 |
| 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/30874/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eb0c136c615141553ef88e7aa114ed12e32197c9cde4d682e5c5e0b4fd50595d/microsoft/TypeScript/issues/30874 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eb0c136c615141553ef88e7aa114ed12e32197c9cde4d682e5c5e0b4fd50595d/microsoft/TypeScript/issues/30874 |
| og:image:alt | TypeScript Version: 3.1.0-dev.20180810 Search Terms: react-redux connect type inference I've noticed this issue while upgrading from v3.0.3. Type inferrence got broken on some of redux's connect ca... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Torvin |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width