Module '"@uppy/core"' has no exported member 'debugLogger'

I’m trying to start up a new project in vanilla typescript with uppy but I keep getting an import error:

Module ‘“@uppy/core”’ has no exported member ‘debugLogger’. Did you mean to use ‘import debugLogger from “@uppy/core”’ instead?

I’m following the docs and example sandboxes.

Here’s a sandbox that errors and won’t start up. What am I doing wrong here?

Hi, this error is emitted by TypeScript because the types of @uppy/core do not list debugLogger as a valid export – but unfortunately the types are wrong, @uppy/core does have a debugLogger export. Until a new version of Uppy is released with a fix, you can use @ts-expect-error to tell TS to ignore the error.

The root of the issue is that Uppy was historically written in JavaScript, and types have been added separately, which results in discrepancies between the types and the actual code. We, the Uppy team, have started refactoring the codebase to TypeScript in preparation for Uppy 4.x, but in the mean time, I’ll go and update the manual types.

1 Like

Thanks for your super fast reply. That’s really helpful!

@aduh95 do you happen to know why the codingsandbox does not want to work with uppy and typescript?

I just can’t get it to complie correctly.

Sandbox

Hum that looks like a bug in the tool that transpiles TS into JS, if you look at the end of the output file, you can see that

declare module "@uppy/core" {
  export const debugLogger: any;
}

has been transpiled to

declare;
"@uppy/core";
{
  src_f10117fe_1.debugLogger;
}
},{"../dist/src.f10117fe":"dist/src.f10117fe.js","./styles.css":"src/styles.css"}]

which is not correct JavaScript. Note that Parcel v1 is no longer maintained, as mentioned in Migration, maybe updating that would solve the issue.

By the way, you could get better typings using the following instead:

import type { Logger } from '@uppy/core';

declare module "@uppy/core" {
  export const debugLogger: Logger;
}
1 Like