I'm looking to enhance an existing exported type with a new method, without causing any disruption to the current usage in production.
import * as BunyanLogger from 'bunyan';
import init from './logger';
export type Logger = BunyanLogger;
I attempted using an interface instead of the type but found that I would need to implement all methods from BunyanLogger
.
My goal is to extend the Logger
type with an additional method. I tried using intersection like this, but it didn't work:
export type Logger = BunyanLogger & {
debugInPlace: (featureRole?:string, ...params: any[]) => void;
};
Is there a way to add a new method to the Logger
type without having to fully re-implement or delegate to methods in the BunyanLogger
type?