jordanbtucker
jordanbtucker4mo ago

Default export has no call signatures

I'm trying to import the default export from npm:@feathersjs/express, but Deno complains that the default export has no call signatures.
// main.ts
import express from "npm:@feathersjs/express";
const app = express();
// main.ts
import express from "npm:@feathersjs/express";
const app = express();
$ deno check main.ts
error: TS2349 [ERROR]: This expression is not callable.
Type 'typeof import("file:///.../node_modules/.deno/@feathersjs+express@5.0.26/node_modules/@feathersjs/express/lib/index.d.ts")' has no call signatures.
const app = express();
~~~~~~~
$ deno check main.ts
error: TS2349 [ERROR]: This expression is not callable.
Type 'typeof import("file:///.../node_modules/.deno/@feathersjs+express@5.0.26/node_modules/@feathersjs/express/lib/index.d.ts")' has no call signatures.
const app = express();
~~~~~~~
However, running main.ts works without issue. The referenced index.d.ts contains this:
export default function feathersExpress<S = any, C = any>(feathersApp?: FeathersApplication<S, C>, expressApp?: Express): Application<S, C>;
export default function feathersExpress<S = any, C = any>(feathersApp?: FeathersApplication<S, C>, expressApp?: Express): Application<S, C>;
So Deno should see its default export. The strange thing is that the following works when checking the file and running it.
import express from "npm:@feathersjs/express";
const app = express.default();
// ^^^^^^^
import express from "npm:@feathersjs/express";
const app = express.default();
// ^^^^^^^
And the following check returns true:
console.log(express === express.default); // true
console.log(express === express.default); // true
So why doesn't Deno like it when I use express() instead of express.default()?
1 Reply
Deno AI Helper
Deno AI Helper4mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the error message and the code snippet you've provided, it seems like there might be an issue with how the default export is being handled. In TypeScript, when you import a default export, you're importing the default property of the module. The error message suggests that Deno is not recognizing the default export as a callable function, even though it is defined as such in the index.d.ts file. The fact that express === express.default returns true indicates that the default export is indeed the function you're trying to call, but for some reason, Deno's type checking is not interpreting it correctly. As a workaround, explicitly calling express.default() seems to resolve the issue, as you've discovered. This is not an ideal solution, but it might be necessary until the underlying issue with the type checking is resolved. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. It might also be helpful to look for similar issues in the Deno repository on GitHub or to ask for help from the community to see if others have encountered and resolved this problem.