oven-sh/bun

extra method shown in console.log

Open

#4,223 opened on Aug 20, 2023

View on GitHub
 (3 comments) (0 reactions) (1 assignee)Rust (4,486 forks)batch import
bugconfirmed buggood first issue

Repository metrics

Stars
 (90,348 stars)
PR merge metrics
 (Avg merge 1d 17h) (357 merged PRs in 30d)

Description

What version of Bun is running?

0.7.4

What platform is your computer?

Darwin 21.6.0 x86_64 i386

What steps can reproduce the bug?

class ImageSettings {
    a = 123;

    toJSON() {
        return { a: '456' };
    }
}

const imageSettings = new ImageSettings();
console.log(imageSettings);
console.log(JSON.stringify(imageSettings));
$ node src/poc.js
ImageSettings { a: 123 }
{"a":"456"}
$ bun run src/poc.js
[0.09ms] ".env"
{
  a: 123,
  toJSON: [Function: toJSON]
}
{"a":"456"}

What is the expected behavior?

toJSON: [Function: toJSON] not to be logged.

What do you see instead?

toJSON: [Function: toJSON] included in the logs.

Additional information

No response

Contributor guide