Registry / testing / typescript-misc

typescript-misc

JSON →
library1.3.0jsnpmunverified

A general-purpose TypeScript library providing utility types, runtime helpers, and testing matchers for projects using TypeScript ≥4.0. Current version 1.3.0, released April 2025; updates follow no strict cadence. Ships with full type declarations and includes peer dependencies on Jest utilities, making it a good fit for test suites that need extended matchers. Differentiator: first-class TypeScript support and integration with `jest-extended`, though its documentation is sparse.

npm install typescript-misc
INSTALL
IMPORT
SIG · TYPESCRIPT-MISC
T
typescript-misc
testingjavascriptv1.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

expect
✓ import { expect } from 'typescript-misc'
✗ import expect from 'typescript-misc'
Named export only; no default export exists in v1.x.
Timer
✓ import { Timer } from 'typescript-misc'
✗ const Timer = require('typescript-misc').Timer
CommonJS require also works but TypeScript may enforce ESM.
type MappedOptional
✓ import type { MappedOptional } from 'typescript-misc'
✗ import { MappedOptional } from 'typescript-misc'
Type-only imports recommended to avoid runtime overhead.

Shows usage of Timer, custom Jest matchers, and MappedOptional utility type.

import { expect, Timer, type MappedOptional } from 'typescript-misc'; // Use Timer for fake timers const timer = new Timer(); timer.useFakeTimers(); setTimeout(() => console.log('done'), 1000); timer.runAllTimers(); // Use custom matchers const { matchers } = expect; expect.extend(matchers); expect('hello').toBeOneOf(['hello', 'world']); // Use mapped optional type type Original = { a: number; b?: string }; type Optional = MappedOptional<Original>; // Optional: { a?: number; b?: string }
Debug
Known issues
breakingImports changed from 'typescript-misc/testing' to 'typescript-misc' in v1.0.0.
fix
Update imports to use the main package entry.
affects: <1.0.0
deprecatedClass 'Timer' constructor changed signature in v1.2.0: fourth parameter is now optional.
fix
Remove the fourth argument or pass undefined.
affects: >=1.2.0
gotchaPackage requires Node.js >=16 and uses ESM; CJS require() works only with Node's --experimental-require-module flag.
fix
Use import syntax or upgrade to Node 22.
affects: >=1.0.0
gotchaPeer dependency '@sinonjs/fake-timers' must be installed manually for timer features.
fix
Run: npm install @sinonjs/fake-timers
affects: >=1.0.0
gotchaCustom matchers (e.g., toBeOneOf) are only available if jest-extended is also installed as a peer.
fix
Install jest-extended: npm install jest-extended
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'typescript-misc' or its corresponding type declarations.
Package not installed or TypeScript resolution missing.
fix
Run 'npm install typescript-misc' and ensure tsconfig includes node_modules.
Module 'typescript-misc' has no exported member 'expect'.
Using default import instead of named import.
fix
Change to: import { expect } from 'typescript-misc'.
TypeError: Timer is not a constructor
Importing Timer as default export from incorrect path.
fix
Use: import { Timer } from 'typescript-misc' (named export).
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
@jest/expect-utilsrequiredRequired for custom Jest matchers
@sinonjs/fake-timersrequiredUsed in timer mocking utilities
jest-extendedoptionalProvides additional Jest matchers
jest-matcher-utilsrequiredUsed for Jest matcher implementation
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources