Skip to content

[Bug]: jest-runtime@28.1.1 has incorrect build/index.d.ts #12948

@blixt

Description

@blixt

Version

28.1.1

Steps to reproduce

  1. Install jest in a TypeScript project
    a. mkdir jest-bug && cd jest-bug
    b. yarn init (hit enter until done)
    c. yarn add typescript jest
    d. yarn run tsc --init
    e. Open your favorite editor that can use the LSP of the currently installed TS
  2. Open node_modules/jest-runtime/build/index.d.ts
  3. Note that there is a type error in this file

Expected behavior

No type errors.

Actual behavior

The code in the .d.ts file has:

import type * as JestGlobals from '@jest/globals';

// …

declare class Runtime {
  // …
  setGlobalsForRuntime(globals: JestGlobals): void;
}

This is a type error because the import becomes a namespace:

Screen Shot 2022-06-17 at 19 03 48

Additional context

This happens with TypeScript 4.7.3 at least. It's failing type checks in one of our projects (though I suspect we have a misconfiguration to fail on third-party code types like this).

Environment

System:
    OS: macOS 12.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 18.3.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^28.1.1 => 28.1.1

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