#This expression is not callable. Type 'typeof import("anylogger") has no call signatures.

8 messages · Page 1 of 1 (latest)

faint onyx
#

When I updated my config to be moduleResolution: Node16 (or NodeNext) https://npm.im/anylogger stopped working. I'm getting the error from the title

Needless to say, it is inaccurate. The type declaration of anylogger is like this (tl;dr;)

export interface AnyLogger<L extends BaseLevels, T extends BaseLogger<L> = Logger<L>> {
  /**
   * @param name The name of the new logger.
   * @param config An optional config object.
   * @returns A logger with the given `name` and `config`.
   */
  (name: string, config?: object | undefined): T

  // more overloads
}

declare const anylogger: AnyLogger<BaseLevels>

export default anylogger

None of the other overloads work either (including new ())

sly chasm
#

are you missing a .default perhaps? export default is not equivalent to the old CommonJS behavior where you'd directly assign to exports or whatever

faint onyx
#

Hm, this is not a runtime error. And the package also includes esm but may need some fixed in package.json

sly chasm
#

actually maybe i'm assuming too much: are you trying to build a program that uses CommonJS modules or ESM or something else?

faint onyx
#

well, technically anylogger is indeed CJS. it does bundle the ESM source, which I tried exposing with the module package keyword but the problem is indeed in the type declaration. I think that since there is no type: "module", the types do not match:

-export default anylogger
+export = anylogger