{"id":18873,"library":"typescript-compare","title":"typescript-compare","description":"Typescript-compare is a utility library providing TypeScript generic types for comparing types at compile time. Version 0.0.2 offers type-level comparison operators (e.g., eq, lt, gt) and helpers like compare and strictEqual. It enables conditional types based on type equality, ordering, and more, useful for building complex type functions. The library is lightweight, with no runtime dependencies, and is intended for advanced TypeScript type programming. It is released on an as-needed cadence.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/ksxnodemodules/typescript-compare","tags":["javascript","compare","generic","typescript","types"],"install":[{"cmd":"npm install typescript-compare","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-compare","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-compare","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for type definitions; requires TypeScript 2.4+.","package":"typescript","optional":true}],"imports":[{"note":"Named import for type-level equality check.","wrong":"import eq from 'typescript-compare'","symbol":"eq","correct":"import { eq } from 'typescript-compare'"},{"note":"compare takes two types and returns -1, 0, or 1 at type level.","wrong":"","symbol":"compare","correct":"import { compare } from 'typescript-compare'"},{"note":"ESM-only; does not support CommonJS require.","wrong":"const strictEqual = require('typescript-compare').strictEqual","symbol":"strictEqual","correct":"import { strictEqual } from 'typescript-compare'"}],"quickstart":{"code":"import { eq, compare, strictEqual } from 'typescript-compare'\n\n// Check if two types are equal\ntype TestEqual = eq<number, number> // true\ntype TestNotEqual = eq<number, string> // false\n\n// Compare types for ordering (e.g., in conditional types)\ntype CompareResult = compare<number, string> // -1 | 0 | 1 (depending on type order)\n\n// Strict equality (no coercion)\ntype Strict = strictEqual<true, true> // true\ntype NotStrict = strictEqual<true, boolean> // false","lang":"typescript","description":"Shows basic usage of type comparison functions eq, compare, and strictEqual for compile-time type checking."},"warnings":[{"fix":"Use only in type contexts (e.g., in type aliases, conditional types).","message":"Only works at compile time; no runtime values are exported.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider alternatives like ts-essentials or type-fest for more stable type utilities.","message":"The package may be considered experimental and not widely used.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Ensure TypeScript version is at least 2.4.","message":"TypeScript version compatibility: requires TypeScript 2.4+.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Make sure to import eq as a named import: import { eq } from 'typescript-compare'","cause":"Missing or incorrect import statement.","error":"error TS2304: Cannot find name 'eq'."},{"fix":"Run npm install typescript-compare --save-dev and ensure tsconfig.json includes node_modules.","cause":"Package not installed or TypeScript cannot resolve it.","error":"error TS2307: Cannot find module 'typescript-compare' or its corresponding type declarations."},{"fix":"Use type syntax: type Result = eq<A, B>; not eq(A, B);","cause":"Using compare or eq incorrectly on runtime values instead of types.","error":"error TS2554: Expected 1 arguments, but got 2."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}