Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build with 4.1.392: error TS2304: Build:Cannot find name 'PromiseWithResolvers' #17932

Closed
Welchen opened this issue Apr 11, 2024 · 5 comments · Fixed by #18161
Closed
Labels

Comments

@Welchen
Copy link

Welchen commented Apr 11, 2024

Attach (recommended) or Link to PDF file here:

Configuration:

  • Visual Studio 2022 17.9.6
  • .NET 8 Blazor
  • PDF.js version: 4.1.392
  • Node 20.12.2

Updated to the newest version and unable to build with Typescript. Something changed between 4.0 and 4.1. Are there new dependencies needed?

@andreymyssak
Copy link

Small investigation from my side:
I've tested it on Node v20.11.1. The issue does not occur with pdfjs-dist v4.0.379. It only happens in v4.1.392, and I think this started after the changes made in #17854.

The method Promise.withResolvers is not yet supported by Node if you try to run it on the server side - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers#browser_compatibility

@Welchen
Copy link
Author

Welchen commented Apr 12, 2024

Small investigation from my side: I've tested it on Node v20.11.1. The issue does not occur with pdfjs-dist v4.0.379. It only happens in v4.1.392, and I think this started after the changes made in #17854.

The method Promise.withResolvers is not yet supported by Node if you try to run it on the server side - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers#browser_compatibility

Updated my post to include my node version. Using 20.12.2 (updated today after the issue started) and still seeing the issue as well.

I have not tried a non-LTS version.

When we revert back to v4.0.379 we also do not see the issue.

Looks like we are both seeing the same thing.

@Snuffleupagus
Copy link
Collaborator

Please use the legacy-build, note https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support

@tamuratak
Copy link
Contributor

tamuratak commented Apr 12, 2024

This issue seems related to TypeScript files under types/src/ bundled with pdfjs-dist. We can see PromiseWithResolvers at types/src/display/api.d.ts

The PromiseWithResolvers is a recently added type:

Users must set "lib": ["ESNext.Promise"] in their tsconfig.json to compile their project without errors.

A workaround on the users' side is to set "skipLibCheck": true in their tsconfig.json.

A fix on PDF.js' side would be to set "target": "ES2020" instead of ESNext in tsconfig.json. Then, the usage of PromiseWithResolvers can be avoided in the generated type files.

@acurrieclark
Copy link

While possibly not a long term fix with other potential breaking changes coming for node, there is a polyfill available for Promise.withResolvers() as part of core-js which is working nicely for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants