René's URL Explorer Experiment


Title: Trying to flatten an array with unknown depth causes a type error · Issue #44408 · microsoft/TypeScript · GitHub

Open Graph Title: Trying to flatten an array with unknown depth causes a type error · Issue #44408 · microsoft/TypeScript

X Title: Trying to flatten an array with unknown depth causes a type error · Issue #44408 · microsoft/TypeScript

Description: Bug Report Trying to flatten an array with unknown depth causes a type error. 🔎 Search Terms flat Infinity 🕗 Version & Regression Information Errors in version 4.2.4 This changed between versions 3.6.2 and 3.7.5 (but probably just becaus...

Open Graph Description: Bug Report Trying to flatten an array with unknown depth causes a type error. 🔎 Search Terms flat Infinity 🕗 Version & Regression Information Errors in version 4.2.4 This changed between versions 3...

X Description: Bug Report Trying to flatten an array with unknown depth causes a type error. 🔎 Search Terms flat Infinity 🕗 Version & Regression Information Errors in version 4.2.4 This changed between versio...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/44408

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Trying to flatten an array with unknown depth causes a type error","articleBody":"# Bug Report\r\n\r\nTrying to flatten an array with unknown depth causes a type error.\r\n\r\n### 🔎 Search Terms\r\n\r\n\u003c!--\r\n  What search terms did you use when trying to find an existing bug report?\r\n  List them here so people in the future can find this one more easily.\r\n--\u003e\r\n * `flat`\r\n * `Infinity`\r\n\r\n### 🕗 Version \u0026 Regression Information\r\n\r\n- Errors in version 4.2.4\r\n- This changed between versions 3.6.2 and 3.7.5 (but probably just because the type definitions aren't supported prior)\r\n\r\nThe PR https://github.com/microsoft/TypeScript/pull/32131 provides a definition for `FlatArray` that has this issue.\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?target=99\u0026ts=4.3.2\u0026filetype=ts#code/PTAEDMEsCcGcBdQBMCmUB2LQENSYSkqADaQKgDuk8AFjtAEbXTbQCeyKADrQFDxsuWAHIoCSADwAVAHygAvKAAUU0AB9Qo8dJkBKANoBdANy9eAYwD26cq2gAuTWPiEJ6AK4BbBimhzF+gCMADT6AEyhAMyGMaa8ICSW5tjExGzBoLRkoEyI4NiQxLAQltCgnlhKAG6+sJDWoAAsAHRhzY268cBdlNR02OigvtCloADkAETQKObu0BNjoNnT4L4o6OaEyDAz8Gmgo5DoSDvmexxHS-DFlhSDAkI46OiW8Njw9ejNFtbk07CODzeXxGBT0aDNcDEd5KACS6Aw1DYujiCTYlncoGSgyQlhwoAAju5IOYANaUUqk1gY444YrgSypW4An42RD-MKArw+aCgxRKOx0p5sIy6SHQ+BwhFHJEoswJBjuPKjWCWCqgabYVWDBq0LBSQQoADK5mgkB4oC40LYAHMRu5aVlirixOgxnkCsQMorEOjMdihp53BKsNQegwOO46ugbZkaFgGUyqDHOIiPrqaO8lsUUETIFUUutEPA8XqDphLSMqpBUERLmWEAMkKwiKQGCx2PYejR4PAuACQDa+u4GM0rJ5gJ4SSNVeB4MADUITWaeMAGMRLAxgEgABwoACc4AAbPuAKyBfcX7CRRoAdgYDECp9PDH3kR32FPAAYv0fwPu0GwB9b1vHdgDbcDIFHMQwi-C9mjsbA2GaJBmmuABiAAZMJAn4Q1QAAMQlABBaAWDYMIJFI6AMgAEW4WghgADxcY5iiBHl-FAABvXhQH40AJlxTAJkcajgj4gSphmOZRNAajmNYpBigAJRQbBhLSaikIkI5VjKeFMGgaiZEkgSBIAfkIkiyKQyjDN8cTQH0ABaEJQC-DJ3IiUBIgyRoMlPDIjwyW8Mh3DJ9y8zzQECdzAh8wI-NigLYqC2KQtisLYoi2KotAWDDH0eieBoQxTPM8yxLI3gAF9ioYugUBY9ZlNANzQCsoTrBQCZQEcaTZnmEx5TAZIozEfEHiwYZSkcSZpiGhZsw1NA1g2LYTkW84DjKI4tt2fZLmoG47kyfCBheN50y+PDHikZwiPeHQwSe+BtIoiQtBcSRZAyabLHAUB4TTNgZCAA)\r\n\r\n### 💻 Code\r\n\r\n```ts\r\n// first define a nested list with arbitrary depth\r\ntype Nested\u003cT\u003e = (T | Nested\u003cT\u003e)[];\r\n\r\nconst arr: Nested\u003cnumber\u003e = [1,[2,[3]]];\r\n\r\n// locally, this bit fails for me (version 4.2.4)\r\n//\r\n// with an error '\"recur\"' is referenced directly or indirectly in its own type annotation.\r\nconst res: number[] = arr.flat(Infinity);\r\n\r\n// you can do a quick workaround as follows:\r\nconst res2: number[] = (arr as any[]).flat(Infinity);\r\n\r\n// but for some reason on the TypeScript playground this doesn't fail, but you can emulate it\r\n// by using the following definition that is equivalent to the one provided in the standard library:\r\n// https://github.com/microsoft/TypeScript/blob/d8e9f6951919a347bb155b938a5006f9efabb778/lib/lib.es2019.array.d.ts#L21\r\ntype FlatArray2\u003cArr, Depth extends number\u003e = {\r\n    \"done\": Arr,\r\n    \"recur\": Arr extends ReadonlyArray\u003cinfer InnerArr\u003e\r\n        ? FlatArray2\u003cInnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]\u003e\r\n        : Arr\r\n}[Depth extends -1 ? \"done\" : \"recur\"];\r\n\r\n// causes a type error: '\"recur\"' is referenced directly or indirectly in its own type annotation.\r\ntype TestFlat\u003cT\u003e = FlatArray2\u003cNested\u003cT\u003e, typeof Infinity\u003e\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nThe code errors with `'\"recur\"' is referenced directly or indirectly in its own type annotation.`\r\n\r\n### 🙂 Expected behavior\r\n\r\nThe code to pass typechecking.\r\n","author":{"url":"https://github.com/GuiltyDolphin","@type":"Person","name":"GuiltyDolphin"},"datePublished":"2021-06-03T11:07:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/44408/TypeScript/issues/44408"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0880a025-2af5-0265-fec8-7fa383d915e5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBDD0:BDBC8:224C3D:2F42DE:6A6267F9
html-safe-nonce291ef30bc7674cd4af4bb2e5643699d5f5cf0b79f49998b7803f15d118ef5be6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREQwOkJEQkM4OjIyNEMzRDoyRjQyREU6NkE2MjY3RjkiLCJ2aXNpdG9yX2lkIjoiNTM5ODA2MDM2OTkzOTk0OTU2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac03a853f4b914c98e8563f9c1ce6be49750bf27c6724303447efe4085388a1db2
hovercard-subject-tagissue:910383125
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/44408/issue_layout
twitter:imagehttps://opengraph.githubassets.com/859810921e211e506fad4c28c5b7b3073b711dce24441d5fde543811c24c44c7/microsoft/TypeScript/issues/44408
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/859810921e211e506fad4c28c5b7b3073b711dce24441d5fde543811c24c44c7/microsoft/TypeScript/issues/44408
og:image:altBug Report Trying to flatten an array with unknown depth causes a type error. 🔎 Search Terms flat Infinity 🕗 Version & Regression Information Errors in version 4.2.4 This changed between versions 3...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameGuiltyDolphin
hostnamegithub.com
expected-hostnamegithub.com
None194bddaed53c0eb07047629c520853f4208e77a17ff57428346485cc202e39f2
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec2862cf2db52f0c7f6cba3de21ffeeafe7c5456e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/44408#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F44408
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F44408
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/44408
Reloadhttps://github.com/microsoft/TypeScript/issues/44408
Reloadhttps://github.com/microsoft/TypeScript/issues/44408
Please reload this pagehttps://github.com/microsoft/TypeScript/issues/44408
microsoft https://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Notifications https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Fork 13.6k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Star 110k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Code https://github.com/microsoft/TypeScript
Issues 5k+ https://github.com/microsoft/TypeScript/issues
Pull requests 21 https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality 0 https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Code https://github.com/microsoft/TypeScript
Issues https://github.com/microsoft/TypeScript/issues
Pull requests https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Trying to flatten an array with unknown depth causes a type errorhttps://github.com/microsoft/TypeScript/issues/44408#top
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/GuiltyDolphin
GuiltyDolphinhttps://github.com/GuiltyDolphin
on Jun 3, 2021https://github.com/microsoft/TypeScript/issues/44408#issue-910383125
#32131https://github.com/microsoft/TypeScript/pull/32131
Playground link with relevant codehttps://www.typescriptlang.org/play?target=99&ts=4.3.2&filetype=ts#code/PTAEDMEsCcGcB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BcSRZAyabLHAUB4TTNgZCAA
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
BacklogNo due datehttps://github.com/microsoft/TypeScript/milestone/29
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.