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

AbortController has reference to interface in ErrorWithCause which doesn't appear to be valid #4210

Closed
2 tasks done
Jerbell opened this issue Nov 11, 2022 · 7 comments · Fixed by #4212
Closed
2 tasks done
Labels

Comments

@Jerbell
Copy link

Jerbell commented Nov 11, 2022

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

On upgrading from Uppy 3.2.2 to 3.3.0 I'm getting an error:
node_modules/@uppy/utils/types/index.d.ts(253,64): error TS2304: Cannot find name 'ErrorOptions'.
Looking at the code in this file:

...
declare module '@uppy/utils/lib/AbortController' {
  export const AbortController: typeof globalThis.AbortController
  export const AbortSignal: typeof globalThis.AbortSignal
  export function createAbortError(message?: string, options?: ErrorOptions): DOMException
}
...
declare module '@uppy/utils/lib/ErrorWithCause' {
  interface ErrorOptions {
    cause?: unknown;
  }

  export default class ErrorWithCause extends Error {
    cause: any

    isNetworkError?: true

    constructor (message: string, options?: ErrorOptions)
  }
}
---

Is this error valid or am I doing something wrong? To me the error seems correct, but I'm also a TS noob.

TIA

Expected behavior

No error

Actual behavior

node_modules/@uppy/utils/types/index.d.ts(253,64): error TS2304: Cannot find name 'ErrorOptions'.

@sergeykosik
Copy link

I am experiencing the same issue even using 3.2.2.

@jcompagner
Copy link

i have the same problem when using the latest version on our angular project:

✖ Compiling with Angular sources in Ivy partial compilation mode.
node_modules/@uppy/utils/types/index.d.ts:253:64 - error TS2304: Cannot find name 'ErrorOptions'.

253 export function createAbortError(message?: string, options?: ErrorOptions): DOMException
~~~~~~~~~~~~

our project fails to compile.

@jcompagner
Copy link

as far as i see this line:

interface ErrorOptions {

is just an interface declared in that module, its not exported. but it is used in that module:

constructor (message: string, options?: ErrorOptions)

but then it is also used here:

export function createAbortError(message?: string, options?: ErrorOptions): DOMException

but that module has no reference to that internal interface

if you look at for example AbortSignal which is used here:

export default function delay (ms:number, opts?: {signal: AbortSignal}): Promise<void>

and that one is exported here:

export const AbortSignal: typeof globalThis.AbortSignal

so i think for ErrorOptions that should work the same

@aduh95
Copy link
Contributor

aduh95 commented Nov 11, 2022

A fix is to add ES2021.Promise and ES2022.Error to your lib in tsconfig.json – or even directly ES2022.

@jcompagner
Copy link

ah so are we targeting that already in Uppy?
why do we have that own interface then also there i wonder.
But yes: https://github.com/microsoft/TypeScript/blob/main/src/lib/es2022.error.d.ts

that has ErrorOptions..
which is exactly the same as:

interface ErrorOptions {

@aduh95
Copy link
Contributor

aduh95 commented Nov 11, 2022

ah so are we targeting that already in Uppy?

I should clarify that this slip through the review process, we didn't mean to change anything for TS consumers. I think we can release a patch for it early next week, but if you want to get unblock until then, changing your TS config is one way of doing it.

@Jerbell
Copy link
Author

Jerbell commented Nov 12, 2022

A patch would be great. Thanks!

@aduh95 aduh95 linked a pull request Nov 13, 2022 that will close this issue
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.

4 participants