pinojs / pino-http

🌲 high-speed HTTP logger for Node.js
MIT License
527 stars 117 forks source link

This expression is not callable #341

Closed joeythomaschaske closed 2 months ago

joeythomaschaske commented 2 months ago

I am trying to import this into a typescript project and typescript is complaining that the library is not callable

import express from 'express';
import pino from 'pino-http';

const app = express();
app.use(pino());

This expression is not callable. Type 'typeof import("node_modules/pino-http/index")' has no call signatures.

Can this library be used with import syntax?

System info

pino-http: 10.1.0 node: 20.14.0 typescript: 5.4.3

joeythomaschaske commented 2 months ago

For whatever reason this works

import express from 'express'
import { pinoHttp } from 'pino-http';

const app = express();
app.use(pinoHttp());

I just don't understand why the original example doesn't work, the type definitions assign the default export to PinoHttp

export default PinoHttp;
export { PinoHttp as pinoHttp };
mcollina commented 2 months ago

it depends on some settings you have on your tsconfig.json.