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

Promise.withResolvers causes type check error #440

Open
uriva opened this issue Nov 23, 2024 · 1 comment
Open

Promise.withResolvers causes type check error #440

uriva opened this issue Nov 23, 2024 · 1 comment

Comments

@uriva
Copy link

uriva commented Nov 23, 2024

I'm seeing this:

[dnt] Type checking ESM...
src/_dnt.test_polyfills.ts:1:9 - error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.

1 declare global {
          ~~~~~~
src/_dnt.test_polyfills.ts:13:13 - error TS2339: Property 'withResolvers' does not exist on type 'PromiseConstructor'.

13 if (Promise.withResolvers === undefined) {
               ~~~~~~~~~~~~~
src/_dnt.test_polyfills.ts:14:11 - error TS2339: Property 'withResolvers' does not exist on type 'PromiseConstructor'.

14   Promise.withResolvers = () => {
             ~~~~~~~~~~~~~
src/src/taskBouncer.test.ts:38:8 - error TS2339: Property 'withResolvers' does not exist on type 'PromiseConstructor'.

38       .withResolvers<void>();
          ~~~~~~~~~~~~~

error: Uncaught (in promise) Error: Had 4 diagnostics.
          throw new Error(`Had ${diagnostics.length} diagnostics.`);
                ^
    at getProgramAndMaybeTypeCheck (https://jsr.io/@deno/dnt/0.41.3/mod.ts:468:17)
    at build (https://jsr.io/@deno/dnt/0.41.3/mod.ts:354:17)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async file:///home/uri/uriva/abstract-bot-api/build_npm.ts:8:1
@uriva
Copy link
Author

uriva commented Nov 23, 2024

meanwhile poly-filling it myself worked

// https://github.com/denoland/dnt/issues/440
const promiseWithResolver = () => {
  const obj = {};
  // @ts-expect-error no typing
  obj.promise = new Promise<void>((resolve) => {
    // @ts-expect-error no typing
    obj.resolve = resolve;
  });
  return obj as { promise: Promise<void>; resolve: () => void };
};

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

No branches or pull requests

1 participant