Title: TS ^4 does not recognize array methods on (T[] | T[][]) as callable · Issue #40157 · microsoft/TypeScript · GitHub
Open Graph Title: TS ^4 does not recognize array methods on (T[] | T[][]) as callable · Issue #40157 · microsoft/TypeScript
X Title: TS ^4 does not recognize array methods on (T[] | T[][]) as callable · Issue #40157 · microsoft/TypeScript
Description: TypeScript Version: 4.0.2, 4.1.0-dev.20200820 Search Terms: union, array methods Code The following example uses every method, but the bug affects all other methods as well (map, reduce, etc.). const a: string[] | string[][] = []; a.ever...
Open Graph Description: TypeScript Version: 4.0.2, 4.1.0-dev.20200820 Search Terms: union, array methods Code The following example uses every method, but the bug affects all other methods as well (map, reduce, etc.). con...
X Description: TypeScript Version: 4.0.2, 4.1.0-dev.20200820 Search Terms: union, array methods Code The following example uses every method, but the bug affects all other methods as well (map, reduce, etc.). con...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/40157
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS ^4 does not recognize array methods on (T[] | T[][]) as callable","articleBody":"**TypeScript Version:** 4.0.2, 4.1.0-dev.20200820\r\n\r\n**Search Terms:** union, array methods\r\n\r\n**Code**\r\n\r\nThe following example uses `every` method, but the bug affects all other methods as well (`map`, `reduce`, etc.).\r\n\r\n```ts\r\nconst a: string[] | string[][] = [];\r\n\r\na.every(b => console.log(b)); // TS-2349: This expression is not callable.\r\n\r\n// Attempt №1: suppress TS-7006\r\na.every((b: string | string[]) => console.log(b)); // TS-2349: This expression is not callable.\r\n\r\n// Attempt №2: rewrite as typeguard (as in https://github.com/microsoft/TypeScript/blob/v4.0-beta/lib/lib.es5.d.ts#L1319)\r\na.every((b: string | string[]): b is string => typeof b === 'string'); // TS-2349: This expression is not callable.\r\n```\r\n\r\n**Expected behavior:** No errors, code should compile.\r\n\r\n**Actual behavior:** Error `TS-2349: This expression is not callable.`\r\n\r\n**Playground Link:** https://www.typescriptlang.org/play?ts=4.1.0-dev.20200819#code/MYewdgzgLgBAhgLhtATgSzAcwNoF0YA+yU6WeeMAvDHgNwBQ9cAdAKYBurKAngBQBGVAHwxQkEABtWzCSEwCAlAoZM2nHrwFJUGTIWKkcuBcNHgIk6bPn8lKlhy58tB3fp1ljSQWgiusplDcAA6sIABmMIKUMTAA5B6Yccr0QA\r\n\r\n**Related Issues:** I didn't find anything similar.\r\n","author":{"url":"https://github.com/dkamyshov","@type":"Person","name":"dkamyshov"},"datePublished":"2020-08-20T17:22:25Z","url":"https://github.com/microsoft/TypeScript/issues/40157"}
| 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:b9ac3125-92d8-70b7-df5d-25870e69b77c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEFA:2454CC:7CC33D:A05994:6B00E7A5 |
| html-safe-nonce | b54e0b53a8b758116f779b5108d6932484944706a0391ae8fc7a31427294b120 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRUZBOjI0NTRDQzo3Q0MzM0Q6QTA1OTk0OjZCMDBFN0E1IiwidmlzaXRvcl9pZCI6IjE2MjE5MTEwNDAxMDkzNzMzNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6a88a0dadf3a027fa3ea9a8ad660de605b14bf6fc75e903b13e8020936939b90 |
| hovercard-subject-tag | issue:682937187 |
| 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/40157/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0258affa84b33066cef7e11d1c310eeec3f178e45260995577d77473802e22f3/microsoft/TypeScript/issues/40157 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0258affa84b33066cef7e11d1c310eeec3f178e45260995577d77473802e22f3/microsoft/TypeScript/issues/40157 |
| og:image:alt | TypeScript Version: 4.0.2, 4.1.0-dev.20200820 Search Terms: union, array methods Code The following example uses every method, but the bug affects all other methods as well (map, reduce, etc.). con... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dkamyshov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width