sidequest icon indicating copy to clipboard operation
sidequest copied to clipboard

Please export logger type from `sidequest` package

Open frederikheld opened this issue 10 months ago • 3 comments

I'd like to pass the logger as a parameter into my functions.

Right now, the only way to type the parameter seems to be like this:

const someFunction(log: ReturnType<typeof logger>) {}

This feels a bit clunky and hides the actual type.

I would prefer to type is as winston.Logger, which is the return type of the logger function but I'd also like to avoid to install Winston separately just to get the type (let alone the issues TypeScript has with using types across packages).

So this is how I'd like to use it:

import type { winston } from 'sidequest'

const someFunction(log: winston.Logger) {}

Or maybe even shorter just like this:

import type { Logger } from 'sidequest'

const someFunction(log: Logger) {}

The latter would allow you to internally replace the logger if you want to move away from winston at some point.

What do you think?

frederikheld avatar Jan 24 '26 09:01 frederikheld

That's something we can do, but isn't winston already in your node_modules when you install Sidequest? Therefore, this will work:

import type {Logger} from "winston"
import {logger} from "sidequest"

function test(logger: Logger){
    logger.info("test")
}

test(logger("Sidequest"))

GiovaniGuizzo avatar Jan 26 '26 13:01 GiovaniGuizzo

This should work, but it doesn't feel clean. I'm interacting with Sidequest and I'm only little interested in what happens behind the scenes to make Sidequest do its magic. The need for importing stuff from a different package just to make the actual package work doesn't feel right to me because I need internal knowledge about Sidequest that I shouldn't need to know. I think we had a similar discussion in a different context already...

frederikheld avatar Jan 27 '26 10:01 frederikheld

:tada: This issue has been resolved in version 1.13.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sidequest-release[bot] avatar Feb 02 '26 13:02 sidequest-release[bot]