Skip to content

Cannot extend Console in node 10 rc.0 #20157

@SimenB

Description

@SimenB
  • Version:
    10.0.0-rc.0
  • Platform:
    macOS
  • Subsystem:
    console

See the following file:

const {Console} = require('console');

class MyConsole extends Console {
  hello() {}
}

const cons = new MyConsole(process.stdout);

console.log(cons.hello)

This will log [Function: hello] in node 8 and node 9, but undefined in the RC.

I'm not sure if it's supposed to happen - my only guess from looking at the changelog is #17708, but I'm not sure if it's it?

This completely breaks Jest (which I wanted to test using the RC) as it extends Console for its own logging. See https://github.com/facebook/jest/blob/ef8f9ce4e02397dc75bdd510079bbfb36ad06728/packages/jest-util/src/buffered_console.js#L164-L166 which is undefined, meaning Jest errors out on an internal error here: https://github.com/facebook/jest/blob/ef8f9ce4e02397dc75bdd510079bbfb36ad06728/packages/jest-runner/src/run_test.js#L137

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.regressionIssues related to regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions