Skip to content

[Bug]: Reporter interface typing is too strong? #14427

@liamjones

Description

@liamjones

Version

29.6.2

Steps to reproduce

  1. Write a custom reporter in JavaScript that only implements onRunComplete, as documented here: https://jestjs.io/docs/configuration/#custom-reporters.
  2. Check reporter works fine with Jest.
  3. Migrate JS to TypeScript and implement Reporter (see https://codesandbox.io/s/sharp-babbage-6v54kc?file=/src/index.ts for example)

Expected behavior

No TypeScript errors

Actual behavior

TypeScript error:

Class 'CustomReporter' incorrectly implements interface 'Reporter'.
   Type 'CustomReporter' is missing the following properties from type 'Reporter': onRunStart, getLastErrorts(2420)

Additional context

No response

Environment

System:
    OS: macOS 13.5.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 18.17.0 - ~/Library/Caches/fnm_multishells/11306_1692352089946/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/11306_1692352089946/bin/yarn
    npm: 9.8.1 - ~/Library/Caches/fnm_multishells/11306_1692352089946/bin/npm
  npmPackages:
    jest: ^29.2.1 => 29.6.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions