Skip to content

JavaScript bigint are printed as {} #334

@matbour

Description

@matbour

Consider this script:

// demo-logger.ts 
import { Logger } from 'tslog';

const logger = new Logger();
const obj = { name: 'John Doe', balance: 100n };

logger.info(obj);

With the default settings, it will output:

node ./demo-logger.ts 
2026-01-22 15:32:55.411 INFO   demo-logger.ts:6        {
  name: 'John Doe',
  balance: 
   {
   
   } 
}

Which of course cause the 100n value to be lost.

I am wondering what's the best approach:

  • Is the empty object the intended behavior?
  • If not, what should be the intended format? 100n, '100n'. something else?
  • Is there any for me to define a custom formatter for bigint?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions