Closed yukukotani closed 2 years ago
Looks like this comes from our isPlainObject
check, specifically where we check ctor instanceof ctor
. With an array, Array instanceof Array
comes back false it would seem. With this, our colorize
method tries to .toString()
the [{ key: 'obj array' }]
which results in [object Object]
like you're seeing. We can add an earlier check in the isPlainObject
method for Array.isArray(fn)
and return true if so, but I'm not sure what other implications that may have elsewhere in the internals
Following what @jmcdo29 wrote above, would you like to create a PR for this change @yukukotani?
@jmcdo29 @kamilmysliwiec Thanks for the explanation! Of course, I'll work on this.
Let's track this here https://github.com/nestjs/nest/pull/10291
Is there an existing issue for this?
Current behavior
ConsoleLogger prints an object correctly. But an array of an object is printed as
[object Object]
.Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-nglkvt?file=src%2Fapp.controller.ts
Steps to reproduce
No response
Expected behavior
An array of an object should be printed with
JSON.stringify
.Package
Other package
No response
NestJS version
No response
Packages versions
[System Information] OS Version : Linux 5.0 NodeJS Version : v16.14.2 NPM Version : 7.17.0
[Nest CLI] Nest CLI Version : 9.0.0
[Nest Platform Information] platform-express version : 9.0.0 schematics version : 9.0.0 testing version : 9.0.0 common version : 9.0.0 core version : 9.0.0 cli version : 9.0.0
Node.js version
No response
In which operating systems have you tested?
Other
No response