Skip to content

TypeScript error due to missing Performance type in Node environments (since v15.3) #566

@mrmonat

Description

@mrmonat

Starting with version 15.3.2, @sinonjs/fake-timers introduces a TypeScript compilation error in Node.js-only environments:

Error: node_modules/@sinonjs/fake-timers/types/fake-timers-src.d.ts(109,19): error TS2304: Cannot find name 'Performance'.

Environment

  • @sinonjs/fake-timers: ≥ 15.3.2
  • TypeScript: reproducible with recent versions
  • Runtime: Node.js (no DOM)

Steps to reproduce

  1. Use @sinonjs/fake-timers in a TypeScript project
  2. Configure tsconfig.json without DOM types:
{
  "compilerOptions": {
    "lib": ["ES2022"]
  }
}
  1. Run the TypeScript compiler

Actual behavior

The compiler fails because Performance is referenced in the type definitions but not available in a Node.js-only type environment.

Expected behavior

The package should compile in a Node.js environment without requiring DOM types.

Workarounds

The issue can currently be worked around by:

  • Enabling skipLibCheck:
{
  "compilerOptions": {
    "skipLibCheck": true
  }
}
  • Adding "DOM" to lib:
{
  "compilerOptions": {
    "lib": ["ES2022", "DOM"]
  }
}

Why this is a problem

  • skipLibCheck disables type checking for all dependencies and may hide real issues.
  • Adding "DOM" introduces browser-specific globals into a Node.js project, which is undesirable and semantically incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions