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
- Use
@sinonjs/fake-timers in a TypeScript project
- Configure
tsconfig.json without DOM types:
{
"compilerOptions": {
"lib": ["ES2022"]
}
}
- 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:
{
"compilerOptions": {
"skipLibCheck": true
}
}
{
"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.
Starting with version
15.3.2,@sinonjs/fake-timersintroduces a TypeScript compilation error in Node.js-only environments:Environment
@sinonjs/fake-timers: ≥ 15.3.2Steps to reproduce
@sinonjs/fake-timersin a TypeScript projecttsconfig.jsonwithout DOM types:{ "compilerOptions": { "lib": ["ES2022"] } }Actual behavior
The compiler fails because
Performanceis 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:
skipLibCheck:{ "compilerOptions": { "skipLibCheck": true } }"DOM"tolib:{ "compilerOptions": { "lib": ["ES2022", "DOM"] } }Why this is a problem
skipLibCheckdisables type checking for all dependencies and may hide real issues."DOM"introduces browser-specific globals into a Node.js project, which is undesirable and semantically incorrect.