Skip to content

Unwrap promises - #42575

Merged
sheetalkamat merged 1 commit into
DefinitelyTyped:masterfrom
jablko:patch-1
Feb 25, 2020
Merged

sheetalkamat merged 1 commit into
DefinitelyTyped:masterfrom
jablko:patch-1

Conversation

@jablko

@jablko jablko commented Feb 23, 2020

Copy link
Copy Markdown
Contributor

Reopen #41960

// even through a double promise.
(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.evaluate(() => Promise.resolve(document.body.innerHTML)).then(s => {
    console.log('body html has length', s.length);
  });
});

Before

page.evaluate() returned a Promise<Promise<string>> ❌

Error in puppeteer
Error: /home/travis/build/DefinitelyTyped/DefinitelyTyped/types/puppeteer/puppeteer-tests.ts:554:43
ERROR: 554:43  expect  TypeScript@next compile error: 
Property 'length' does not exist on type 'Promise<string>'.
ERROR: 626:10  expect  TypeScript@next compile error: 

After

It returns a Promise<string> ✔️

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback Unmerged The author did not merge the PR when it was ready. labels Feb 24, 2020
@typescript-bot

typescript-bot commented Feb 24, 2020 •

Copy link
Copy Markdown
Contributor

@jablko Thank you for submitting this PR!

🔔 @marvinhagemeister @cdeutsch @ksm2 @SimonSchick @serbanghita @JasonKaz @davecardwell @angrykoala @karol-majewski - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot

Copy link
Copy Markdown
Contributor

After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience!

@sheetalkamat
sheetalkamat merged commit 8fb86da into DefinitelyTyped:master Feb 25, 2020
@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/puppeteer@2.0.1 to npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Popular package This PR affects a popular package (as counted by NPM download counts). Unmerged The author did not merge the PR when it was ready.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants