Skip to content

Cannot use defaultMeta option in TypeScript #1582

Description

@dsh

Please tell us about your environment:

  • winston version?
    • winston@2
    • [ x ] winston@3
  • node -v outputs: v10.15.0
  • Operating System? macOS 10.14.2
  • Language? TypeScript 3.2.4

What is the problem?

When using TypeScript cannot use the defaultMeta option without getting a type error.

import winston from 'winston';

const logger = winston.createLogger({
    defaultMeta: { service: 'my-service' },
});

Returns:

Argument of type '{ defaultMeta: { service: string; }; }' is not assignable to parameter of type 'LoggerOptions'.
  Object literal may only specify known properties, and 'defaultMeta' does not exist in type 'LoggerOptions'. [2345]

What do you expect to happen instead?

It should compile.

Other information

An appropriate type for defaultMeta? should be added at https://github.com/winstonjs/winston/blob/master/index.d.ts#L73

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions