Title: TS2345 when generic function calls itself. · Issue #41714 · microsoft/TypeScript · GitHub
Open Graph Title: TS2345 when generic function calls itself. · Issue #41714 · microsoft/TypeScript
X Title: TS2345 when generic function calls itself. · Issue #41714 · microsoft/TypeScript
Description: TypeScript Version: 4.1.2 Code /** * function illustrates typescript compile error. Generic function recursively * calls itself. Get error TS2345 on statement where function calls itself. * This code compiles without error using typescri...
Open Graph Description: TypeScript Version: 4.1.2 Code /** * function illustrates typescript compile error. Generic function recursively * calls itself. Get error TS2345 on statement where function calls itself. * This co...
X Description: TypeScript Version: 4.1.2 Code /** * function illustrates typescript compile error. Generic function recursively * calls itself. Get error TS2345 on statement where function calls itself. * This co...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/41714
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS2345 when generic function calls itself.","articleBody":"\u003c!--\r\nPlease try to reproduce the issue with the latest published version. It may have already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n-->\r\n**TypeScript Version:** 4.1.2\r\n\r\n**Code**\r\n```\r\n/**\r\n * function illustrates typescript compile error. Generic function recursively\r\n * calls itself. Get error TS2345 on statement where function calls itself. \r\n * This code compiles without error using typescript version 4.0.5 or lower.\r\n * The compile fails at typescript version 4.1.2\r\n * @param arr1 \r\n * @param arr2 \r\n */\r\nexport function genericArrayProblem\u003cT>(arr1: T[], arr2: T[]): boolean \r\n{\r\n for( let ix = 0 ; ix \u003c arr1.length ; ++ix )\r\n {\r\n if ( ix \u003c arr2.length )\r\n {\r\n const item1 = arr1[ix];\r\n const item2 = arr2[ix];\r\n \r\n if (Array.isArray(item1) && Array.isArray(item2))\r\n {\r\n const res = genericArrayProblem(item1, item2);\r\n }\r\n }\r\n }\r\n\r\n return true ;\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nExpecting code to compile. It compiles successfully using typescript version 4.0.5 or lower. \r\n\r\n**Actual behavior:**\r\nget compile error:\r\n```\r\nerror TS2345: Argument of type 'T & (T extends readonly any[] ? unknown extends T \r\n? never : readonly any[] : any[])' is not assignable to parameter of type 'any[]'.\r\n\r\n const res = genericArrayProblem(item1, item2);\r\n```\r\n\r\n","author":{"url":"https://github.com/lae0901","@type":"Person","name":"lae0901"},"datePublished":"2020-11-28T17:45:03Z","url":"https://github.com/microsoft/TypeScript/issues/41714"}
| 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:16501929-40d3-5b22-1a0d-97030aea91f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E706:1EC9BC:2CB7284:390697B:6B01BCEB |
| html-safe-nonce | 89e993332ed477e3fd05a0032a41bbcda928f7d1c7541a5298049b7d4a9cc5d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzA2OjFFQzlCQzoyQ0I3Mjg0OjM5MDY5N0I6NkIwMUJDRUIiLCJ2aXNpdG9yX2lkIjoiMjMyODUzMDcwMzMwMzY4NzQwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4bce4c2a5fc911f49ddd2d6843ad1fd5fb868649a02e8d94072c535330c6787a |
| hovercard-subject-tag | issue:752731795 |
| 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/41714/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a55eb42ca717ae8355aed3ecf95581fb19e7e88d8cc509fcad5a1d353e63e2e/microsoft/TypeScript/issues/41714 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a55eb42ca717ae8355aed3ecf95581fb19e7e88d8cc509fcad5a1d353e63e2e/microsoft/TypeScript/issues/41714 |
| og:image:alt | TypeScript Version: 4.1.2 Code /** * function illustrates typescript compile error. Generic function recursively * calls itself. Get error TS2345 on statement where function calls itself. * This co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lae0901 |
| 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