Skip to content

[Bug]: importing from ts-jest automatically includes node ambient typings #5120

@backbone87

Description

@backbone87

Version

^29

Steps to reproduce

  • Create TS project with types: [] (no automatic ambient types)
  • Setup ts-jest according to docs

Expected behavior

Using __dirname in test files should cause a type error because no node ambient types are included

Actual behavior

__dirname does not cause a type error and @types/node is included in the compilation

Debug log

not applicable

Additional context

ts-jest uses bs-logger as a dep which is built with TS3 which automatically injects triple slash references into the declaration files which causes ambient node types to be included. this TS behavior has changed a while ago: see microsoft/TypeScript#57681

ts-jest is the only dep (in my package) that (indirectly) forces inclusion of ambient node types (through bs-logger).

Remediations (that i know of):

edit: i created the ticket here, because my package does not depend on bs-logger, but only ts-jest.

Environment

System:
    OS: macOS 26.0.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 22.21.1 - /usr/local/bin/node
    Yarn: 1.22.19 - ~/ws/<redacted>/node_modules/.bin/yarn
    npm: 10.9.4 - /usr/local/bin/npm
  npmPackages:
    jest: ^30.2.0 => 30.2.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions