{"id":12262,"library":"typescript-type-utils","title":"TypeScript Type Utils","description":"typescript-type-utils is a lightweight, zero-runtime collection of TypeScript utility types designed to enhance type safety and enable advanced type manipulations within projects. At version 0.1.0, it provides a set of 'test-kit' types for compile-time API signature verification (e.g., `ExpectTrue`, `Equal`) and 'tuple-utils' for advanced tuple type transformations (e.g., `TupleToUnion`, `ReduceTupleOn`). A key differentiator is its strict design principle: the package explicitly contains only `.d.ts` declaration files, meaning it ships no actual JavaScript code, thereby ensuring zero runtime footprint and no potential for runtime errors. Its release cadence is likely infrequent given its stable, pure-type nature and early version number, focusing on robust and broadly applicable type definitions rather than rapid feature additions.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install typescript-type-utils","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-type-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-type-utils","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"As this library ships only type declarations, `import type` is the correct syntax to prevent accidental runtime imports and ensure type-only usage.","wrong":"import { ExpectTrue } from 'typescript-type-utils'","symbol":"ExpectTrue","correct":"import type { ExpectTrue } from 'typescript-type-utils'"},{"note":"This package is a pure type library and does not export any runtime values, making CommonJS `require` unsuitable for its types.","wrong":"const Equal = require('typescript-type-utils').Equal","symbol":"Equal","correct":"import type { Equal } from 'typescript-type-utils'"},{"note":"All utility types are named exports. There is no default export from this library.","wrong":"import TupleToUnion from 'typescript-type-utils'","symbol":"TupleToUnion","correct":"import type { TupleToUnion } from 'typescript-type-utils'"}],"quickstart":{"code":"import type { Equal, ExpectTrue, TupleToUnion } from 'typescript-type-utils';\n\n// Example 1: Basic equality check at compile time\ntype StringIsString = ExpectTrue<Equal<string, string>>; // This type assertion will pass\n// type StringIsNumber = ExpectTrue<Equal<string, number>>; // Uncommenting this line would cause a compile-time error\n\n// Example 2: Using Equal for structural type comparison\ninterface User { id: number; name: string; }\ntype UserAlias = { id: number; name: string; };\ntype UserTypesAreEqual = ExpectTrue<Equal<User, UserAlias>>; // Asserts structural equality\n\n// Example 3: Transforming tuple types to union types\ntype MyTuple = [1, 'hello', true];\ntype UnionFromTuple = TupleToUnion<MyTuple>; // UnionFromTuple will be 1 | \"hello\" | true\n\n// The types ensure correctness at compile-time. No runtime code is executed.\nconsole.log(\"All type assertions passed at compile time if there are no errors in your IDE/console.\");\n","lang":"typescript","description":"Demonstrates how to import and use utility types like `Equal`, `ExpectTrue`, and `TupleToUnion` for compile-time type assertions and transformations, highlighting the library's zero-runtime nature."},"warnings":[{"fix":"Review compilation errors and adjust your code to the new type definitions. It is recommended to pin exact versions or use tilde (~) for minor version updates if strict type stability is crucial.","message":"Changes to core utility type definitions can lead to compile-time errors in consuming projects. Since this library contains only types, any modification to a type's signature is a breaking change for type consumers.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Always use `import type { ... } from 'typescript-type-utils'` for importing utility types from this library to explicitly declare a type-only import.","message":"Attempting to import types using standard JavaScript import syntax (e.g., `import { Type } from 'pkg'`) or CommonJS `require()` will result in build errors or runtime failures, as this library explicitly contains no runnable JavaScript code.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider pinning exact versions for critical projects (`\"typescript-type-utils\": \"0.1.0\"`) or contribute to discussions to stabilize desired APIs if you require long-term stability for specific type shapes.","message":"As a 0.1.0 package, while stable in concept, the specific API surface and type definitions might evolve rapidly in future minor versions. Relying on specific internal type structures could be fragile.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `import { MyType }` to `import type { MyType }` to specify a type-only import.","cause":"Attempting to import a type using a standard ES module import without the 'type' keyword, leading TypeScript to expect a runtime export.","error":"Module 'typescript-type-utils' has no exported member 'MyType'. Did you mean to use 'import type'?"},{"fix":"Add the necessary type import at the top of your TypeScript file: `import type { ExpectTrue } from 'typescript-type-utils';`.","cause":"A utility type from the library was used in TypeScript code without being imported first, or with an incorrect name.","error":"Cannot find name 'ExpectTrue'. Did you mean to import it from 'typescript-type-utils'?"},{"fix":"Ensure the package is installed via npm or yarn (`npm install typescript-type-utils` or `yarn add typescript-type-utils`). Verify that your `tsconfig.json` has `moduleResolution` set to a modern value like `NodeNext` or `Bundler` if applicable.","cause":"The package is not installed, or TypeScript cannot correctly locate its declaration files based on the project's `tsconfig.json` configuration.","error":"TS2307: Cannot find module 'typescript-type-utils' or its corresponding type declarations."}],"ecosystem":"npm"}