Skip to content

fix: support ES2020 TypeScript consumers#246

Closed
saripovdenis wants to merge 1 commit into
sindresorhus:mainfrom
saripovdenis:fix/ts_error
Closed

fix: support ES2020 TypeScript consumers#246
saripovdenis wants to merge 1 commit into
sindresorhus:mainfrom
saripovdenis:fix/ts_error

Conversation

@saripovdenis

Copy link
Copy Markdown
Contributor

Summary

Fixes TypeScript consumers that compile with target: "ES2020" or "ES2021" and skipLibCheck: false.

p-queue re-exports TimeoutError from p-timeout. That makes TypeScript load p-timeout declarations when checking p-queue, even if the user never imports p-timeout directly.

p-timeout uses ErrorOptions, which comes from ES2022.Error. ES2020 projects may not have that lib loaded, so a plain import PQueue from 'p-queue' can fail with:

Cannot find name 'ErrorOptions'

Why fix this here?

The root type is in p-timeout, so an upstream fix there would also be useful. But p-queue re-exports that type as part of its public declaration surface, so p-queue consumers can hit the error without depending on or importing p-timeout.

This local fix shields p-queue users now and remains harmless if p-timeout later adds the same reference.

@sindresorhus

Copy link
Copy Markdown
Owner

Sorry, not interested in this. This package targets Node.js 20, which supports ES2022. So any consumer not having ES2022 have the incorrect TS config.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants