{"id":42169,"library":"typescript-misc","title":"TypeScript Misc","description":"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.","status":"active","version":"1.3.0","language":"javascript","source_language":"en","source_url":"git://github.com/iliubinskii/typescript-misc","tags":["javascript","typescript"],"install":[{"cmd":"npm install typescript-misc","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-misc","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-misc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for custom Jest matchers","package":"@jest/expect-utils","optional":false},{"reason":"Used in timer mocking utilities","package":"@sinonjs/fake-timers","optional":false},{"reason":"Provides additional Jest matchers","package":"jest-extended","optional":true},{"reason":"Used for Jest matcher implementation","package":"jest-matcher-utils","optional":false}],"imports":[{"note":"Named export only; no default export exists in v1.x.","wrong":"import expect from 'typescript-misc'","symbol":"expect","correct":"import { expect } from 'typescript-misc'"},{"note":"CommonJS require also works but TypeScript may enforce ESM.","wrong":"const Timer = require('typescript-misc').Timer","symbol":"Timer","correct":"import { Timer } from 'typescript-misc'"},{"note":"Type-only imports recommended to avoid runtime overhead.","wrong":"import { MappedOptional } from 'typescript-misc'","symbol":"type MappedOptional","correct":"import type { MappedOptional } from 'typescript-misc'"}],"quickstart":{"code":"import { expect, Timer, type MappedOptional } from 'typescript-misc';\n\n// Use Timer for fake timers\nconst timer = new Timer();\ntimer.useFakeTimers();\nsetTimeout(() => console.log('done'), 1000);\ntimer.runAllTimers();\n\n// Use custom matchers\nconst { matchers } = expect;\nexpect.extend(matchers);\nexpect('hello').toBeOneOf(['hello', 'world']);\n\n// Use mapped optional type\ntype Original = { a: number; b?: string };\ntype Optional = MappedOptional<Original>;\n// Optional: { a?: number; b?: string }","lang":"typescript","description":"Shows usage of Timer, custom Jest matchers, and MappedOptional utility type."},"warnings":[{"fix":"Update imports to use the main package entry.","message":"Imports changed from 'typescript-misc/testing' to 'typescript-misc' in v1.0.0.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Remove the fourth argument or pass undefined.","message":"Class 'Timer' constructor changed signature in v1.2.0: fourth parameter is now optional.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Use import syntax or upgrade to Node 22.","message":"Package requires Node.js >=16 and uses ESM; CJS require() works only with Node's --experimental-require-module flag.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run: npm install @sinonjs/fake-timers","message":"Peer dependency '@sinonjs/fake-timers' must be installed manually for timer features.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install jest-extended: npm install jest-extended","message":"Custom matchers (e.g., toBeOneOf) are only available if jest-extended is also installed as a peer.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.3.0':24 '2025':27 '4.0':21 'april':26 'cadenc':32 'class':60 'current':22 'declar':37 'depend':41 'differenti':57 'document':71 'extend':55,68 'first':59 'first-class':58 'fit':49 'follow':29 'full':35 'general':5 'general-purpos':4 'good':48 'helper':13 'includ':39 'integr':64 'javascript':74 'jest':43,67 'jest-extend':66 'librari':8 'make':45 'matcher':16,56 'misc':2 'need':54 'peer':40 'project':18 'provid':9 'purpos':6 'releas':25 'runtim':12 'ship':33 'spars':73 'strict':31 'suit':52 'support':62 'test':15,51 'though':69 'type':11,36 'typescript':1,7,20,61,75 'updat':28 'use':19 'util':10,44 'version':23","created_at":"2026-06-04T18:55:56.991739+00:00","updated_at":"2026-06-04T18:55:56.991739+00:00","problems":[{"fix":"Run 'npm install typescript-misc' and ensure tsconfig includes node_modules.","cause":"Package not installed or TypeScript resolution missing.","error":"Cannot find module 'typescript-misc' or its corresponding type declarations."},{"fix":"Change to: import { expect } from 'typescript-misc'.","cause":"Using default import instead of named import.","error":"Module 'typescript-misc' has no exported member 'expect'."},{"fix":"Use: import { Timer } from 'typescript-misc' (named export).","cause":"Importing Timer as default export from incorrect path.","error":"TypeError: Timer is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/iliubinskii/typescript-misc","github":"git://github.com/iliubinskii/typescript-misc","docs":null,"changelog":null,"pypi":null,"npm":"typescript-misc","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}