René's URL Explorer Experiment


Title: Using for-await-of should resolve the Promise? · Issue #21115 · microsoft/TypeScript · GitHub

Open Graph Title: Using for-await-of should resolve the Promise? · Issue #21115 · microsoft/TypeScript

X Title: Using for-await-of should resolve the Promise? · Issue #21115 · microsoft/TypeScript

Description: TypeScript Version: typescript@2.6.2 typescript@2.7.0-dev.20180110 Code declare function require(name:string); ( Symbol).asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator"); const fetchlike = function(url) { /...

Open Graph Description: TypeScript Version: typescript@2.6.2 typescript@2.7.0-dev.20180110 Code declare function require(name:string); ( Symbol).asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterato...

X Description: TypeScript Version: typescript@2.6.2 typescript@2.7.0-dev.20180110 Code declare function require(name:string); (<any> Symbol).asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.a...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using for-await-of should resolve the Promise?","articleBody":"**TypeScript Version:**\r\n- typescript@2.6.2\r\n- typescript@2.7.0-dev.20180110\r\n\r\n**Code**\r\n\r\n```ts\r\ndeclare function require(name:string);\r\n\r\n(\u003cany> Symbol).asyncIterator = Symbol.asyncIterator || Symbol.for(\"Symbol.asyncIterator\");\r\n\r\nconst fetchlike = function(url) {\r\n  // return new pending promise\r\n  return new Promise((resolve, reject) => {\r\n    // select http or https module, depending on reqested url\r\n    const lib = url.startsWith('https') ? require('https') : require('http');\r\n    const request = lib.get(url, (response) => {\r\n      // handle http errors\r\n      if (response.statusCode \u003c 200 || response.statusCode > 299) {\r\n         reject(new Error('Failed to load page, status code: ' + response.statusCode));\r\n       }\r\n      // temporary data holder\r\n      const body = [];\r\n      // on every content chunk, push it to the data array\r\n      response.on('data', (chunk) => body.push(chunk));\r\n      // we are done, resolve promise with those joined chunks\r\n      response.on('end', () => resolve(body.join('')));\r\n    });\r\n    // handle connection errors of the request\r\n    request.on('error', (err) => reject(err))\r\n    })\r\n};\r\n\r\nasync function example() {\r\n  const arrayOfFetchPromises = [\r\n    fetchlike('http://example.com'),\r\n    fetchlike('http://example.com'),\r\n  ];\r\n\r\n  // Regular iterator:\r\n  for (const item of arrayOfFetchPromises) {\r\n    console.log(item); // Logs a promise\r\n  }\r\n\r\n  // for-await-of iterator:  \r\n  for await (const item of arrayOfFetchPromises) {\r\n    console.log(item); // Logs a response\r\n  }\r\n}\r\n\r\nexample()\r\n```\r\n\r\n`tsc --lib es2017,esnext.asynciterable,dom Untitled-1.ts && node Untitled-1.js`\r\n\r\n**Actual behavior:**\r\n\r\n`item` is a Promise in the for-await-of iterator block\r\n\r\n![imgur](https://i.imgur.com/PfhT7Fz.png)\r\n\r\nDoing this causes error:\r\n\r\n```ts\r\n  for await (const item of arrayOfFetchPromises) {\r\n    console.log(item.length); // TS error\r\n  }\r\n```\r\n\r\n```ts\r\n  for await (const item of arrayOfFetchPromises) {\r\n    console.log((item as any).length);\r\n    // not error because typecasted to any, logs valid result\r\n  }\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nIn the for-await-of iterator block,`item` should not be a Promise, because it's the actual value instead of a Promise\r\n","author":{"url":"https://github.com/luthfianto","@type":"Person","name":"luthfianto"},"datePublished":"2018-01-10T11:38:12Z","url":"https://github.com/microsoft/TypeScript/issues/21115"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:90d77606-8127-885c-793c-08fdcd3de5bf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE734:3F8A67:1EED3FE:2948D02:6B017BC0
html-safe-nonce0fd60ee597dea38c059bf4651ea881f6118857ac703af09198e57855eb3c9531
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzM0OjNGOEE2NzoxRUVEM0ZFOjI5NDhEMDI6NkIwMTdCQzAiLCJ2aXNpdG9yX2lkIjoiMTY5NDk2MjYzOTkwMzQ4ODk2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacbe66d8173b8da9f7ffa17714bb7f4b02b6a5f861514b45192263360c17ce9a81
hovercard-subject-tagissue:287403528
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/21115/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c9bc888f521c24081febb18a7b04654bf3cb0c31c3e0e4a6fa75458333f87741/microsoft/TypeScript/issues/21115
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c9bc888f521c24081febb18a7b04654bf3cb0c31c3e0e4a6fa75458333f87741/microsoft/TypeScript/issues/21115
og:image:altTypeScript Version: typescript@2.6.2 typescript@2.7.0-dev.20180110 Code declare function require(name:string); ( Symbol).asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterato...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameluthfianto
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/21115#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F21115
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F21115
Sign uphttps://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/21115
Reloadhttps://github.com/microsoft/TypeScript/issues/21115
Reloadhttps://github.com/microsoft/TypeScript/issues/21115
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/21115
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/21115
#24474https://github.com/microsoft/TypeScript/pull/24474
Using for-await-of should resolve the Promise?https://github.com/microsoft/TypeScript/issues/21115#top
#24474https://github.com/microsoft/TypeScript/pull/24474
https://github.com/rbuckton
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
TypeScript 2.9.2https://github.com/microsoft/TypeScript/milestone/73
https://github.com/luthfianto
Rizky Luthfianto (luthfianto)https://github.com/luthfianto
on Jan 10, 2018https://github.com/microsoft/TypeScript/issues/21115#issue-287403528
https://camo.githubusercontent.com/c2bbbdf19e4f87c65d480d102d3b8183c1905ce0c068f9be807351a716433d13/68747470733a2f2f692e696d6775722e636f6d2f5066685437467a2e706e67
QuestionAn issue which isn't directly actionable in codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Question%22
on Jan 10, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1418143959
https://github.com/Jessidhia
Jessica Franco (Jessidhia)https://github.com/Jessidhia
on Jan 11, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-356793605
Andy (Andrewkraft) (@Andy-MS)https://github.com/Andy-MS
GetIteratorhttps://tc39.github.io/proposal-async-iteration/#sec-getiterator
CreateAsyncFromSyncIteratorhttps://tc39.github.io/proposal-async-iteration/#sec-createasyncfromsynciterator
%AsyncFromSyncIteratorPrototype%.nexthttps://tc39.github.io/proposal-async-iteration/#sec-%asyncfromsynciteratorprototype%.next
QuestionAn issue which isn't directly actionable in codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Question%22
on Jan 11, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1418906207
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Jan 11, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1418906259
https://github.com/luthfianto
Rizky Luthfianto (luthfianto)https://github.com/luthfianto
on Jan 11, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-356823587
/src/lib/esnext.asynciterable.d.ts#L14https://github.com/Microsoft/TypeScript/blob/master/src/lib/esnext.asynciterable.d.ts#L14
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
Ron Buckton (rbuckton)https://github.com/rbuckton
on Jan 11, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1420273528
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.8https://github.com/microsoft/TypeScript/milestone/61
on Jan 11, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1420273627
https://github.com/Jamesernator
James Browning (Jamesernator)https://github.com/Jamesernator
on Jan 13, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-357403722
enforcedhttps://tc39.github.io/proposal-async-iteration/#table-async-iterator-required
#7993https://github.com/microsoft/TypeScript/issues/7993
https://github.com/simonbuchan
Simon Buchan (simonbuchan)https://github.com/simonbuchan
on Feb 1, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-362424339
https://github.com/rbuckton
Ron Buckton (rbuckton)https://github.com/rbuckton
on Feb 1, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-362425614
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.8https://github.com/microsoft/TypeScript/milestone/61
TypeScript 2.9https://github.com/microsoft/TypeScript/milestone/67
on Mar 9, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1514258663
https://github.com/rbuckton
Ron Buckton (rbuckton)https://github.com/rbuckton
on May 9, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-387895894
https://github.com/luthfianto
Rizky Luthfianto (luthfianto)https://github.com/luthfianto
on May 10, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-387969877
/src/lib/esnext.asynciterable.d.ts#L14https://github.com/Microsoft/TypeScript/blob/master/src/lib/esnext.asynciterable.d.ts#L14
https://github.com/Jamesernator
James Browning (Jamesernator)https://github.com/Jamesernator
on May 10, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-388013597
Ron Buckton (@rbuckton)https://github.com/rbuckton
riluthttps://github.com/rilut
riluthttps://github.com/rilut
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.9https://github.com/microsoft/TypeScript/milestone/67
TypeScript 3.0https://github.com/microsoft/TypeScript/milestone/70
on May 10, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1620231546
Ron Buckton (rbuckton)https://github.com/rbuckton
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#24474https://github.com/microsoft/TypeScript/pull/24474
on May 30, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1652430302
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
on May 30, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1653974624
Ron Buckton (rbuckton)https://github.com/rbuckton
TypeScript 3.0https://github.com/microsoft/TypeScript/milestone/70
TypeScript 2.9.2https://github.com/microsoft/TypeScript/milestone/73
on Jun 7, 2018https://github.com/microsoft/TypeScript/issues/21115#event-1669708620
https://github.com/jesseschalken
Jesse Schalken (jesseschalken)https://github.com/jesseschalken
on Nov 25, 2018https://github.com/microsoft/TypeScript/issues/21115#issuecomment-441434010
#27271https://github.com/microsoft/TypeScript/pull/27271
#24474https://github.com/microsoft/TypeScript/pull/24474
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/21115#event-20415573227
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/21115
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/21115
Ron Buckton (rbuckton)https://github.com/rbuckton
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
TypeScript 2.9.2https://github.com/microsoft/TypeScript/milestone/73
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.