[Bug]: Add timestamp to TransformableInfo interface
Closed this issue · 4 comments
jpramos123 commented
The problem
Created a winston
log format using typescript:
const logFormat = printf(({ timestamp, level, message }) => {
return `${timestamp} ${level}: ${message}`;
})
When I try running tsc
it returns:
src/logger/logger.ts:28:29 - error TS2339: Property 'timestamp' does not exist on type 'TransformableInfo'.
28 const logFormat = printf(({ timestamp, level, message }) => {
My guess is that it is missing in the Interface at: https://github.com/winstonjs/logform/blob/master/index.d.ts#L8-L15
I modified my local TransformableInfo
interface under node_modules/logform/index.d.ts
to the code below, and worked just fine:
export interface TransformableInfo {
level: string;
message: any;
timestamp: any;
[LEVEL]?: string;
[MESSAGE]?: any;
[SPLAT]?: any;
[key: string | symbol]: any;
}
What version of Logform presents the issue?
v2.5.1
What version of Node are you using?
v16.19.0
If this worked in a previous version of Logform, which was it?
No response
Minimum Working Example
- Install
winston
- Create a
logger.ts
file with:
import { createLogger, format, transports } from 'winston'
import config from 'config'
const levels = {
error: 0,
warn: 1,
info: 2,
http: 3,
debug: 4,
}
const { combine, timestamp, printf } = format;
const logFormat = printf(({ timestamp, level, message }) => {
return `${timestamp} ${level}: ${message}`;
})
export const Logger = createLogger({
level: config.get("LOG_LEVEL"),
levels,
format: combine(
timestamp(),
logFormat,
format.json()
),
transports: [new transports.Console()]
})
- Run
tsc
command
Additional information
No response
🔎 Search Terms
TransformableInfo, logform
wbt commented
What version of TypeScript are you using when observing this?
wbt commented
Closing for issue maintenance based on linked PR and the assumption that the answer is <4.4, but we can reopen if that's an incorrect assumption.
jpramos123 commented
@wbt The version being used is: ^4.4.4
wbt commented
What version specifically is it that's running? (tsc -v
)