Skip to content

util.inspect getters ignored on class instance #30183

Closed
@75lb

Description

@75lb
  • Version: v12.12.0
  • Platform: Darwin mba4.local 18.7.0 Darwin Kernel Version 18.7.0
  • Subsystem: util.inspect

getters:true works correctly on a plain object:

const util = require('util')
util.inspect.defaultOptions.getters = true

const object = {
  get test () {
    return 'test'
  }
}
console.log(object)

Output:

{ test: [Getter: 'test'] }

But the same operation on a class instance fails to print the getter.

class Something {
  get test () {
    return 'test'
  }
}

const something = new Something()
console.log(something)

Output:

Something {}

The output I expect to see is:

Something { test: [Getter: 'test'] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.feature requestIssues that request new features to be added to Node.js.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions