Registry / type-stubs / typescript-type-utils

typescript-type-utils

JSON →
library0.1.0jsnpmunverified

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.

npm install typescript-type-utils
INSTALL
IMPORT
SIG · TYPESCRIPT-TYPE-UT
T
typescript-type-utils
type-stubsjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

ExpectTrue
import type { ExpectTrue } from 'typescript-type-utils'
import { ExpectTrue } from 'typescript-type-utils'
As this library ships only type declarations, `import type` is the correct syntax to prevent accidental runtime imports and ensure type-only usage.
Equal
import type { Equal } from 'typescript-type-utils'
const Equal = require('typescript-type-utils').Equal
This package is a pure type library and does not export any runtime values, making CommonJS `require` unsuitable for its types.
TupleToUnion
import type { TupleToUnion } from 'typescript-type-utils'
import TupleToUnion from 'typescript-type-utils'
All utility types are named exports. There is no default export from this library.

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.

import type { Equal, ExpectTrue, TupleToUnion } from 'typescript-type-utils'; // Example 1: Basic equality check at compile time type StringIsString = ExpectTrue<Equal<string, string>>; // This type assertion will pass // type StringIsNumber = ExpectTrue<Equal<string, number>>; // Uncommenting this line would cause a compile-time error // Example 2: Using Equal for structural type comparison interface User { id: number; name: string; } type UserAlias = { id: number; name: string; }; type UserTypesAreEqual = ExpectTrue<Equal<User, UserAlias>>; // Asserts structural equality // Example 3: Transforming tuple types to union types type MyTuple = [1, 'hello', true]; type UnionFromTuple = TupleToUnion<MyTuple>; // UnionFromTuple will be 1 | "hello" | true // The types ensure correctness at compile-time. No runtime code is executed. console.log("All type assertions passed at compile time if there are no errors in your IDE/console.");
Debug
Known issues
breakingChanges 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.
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.
affects: >=0.1.0
gotchaAttempting 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.
fix
Always use `import type { ... } from 'typescript-type-utils'` for importing utility types from this library to explicitly declare a type-only import.
affects: >=0.1.0
gotchaAs 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.
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.
affects: >=0.1.0
Errors
Common errors & fixes
Module 'typescript-type-utils' has no exported member 'MyType'. Did you mean to use 'import type'?
Attempting to import a type using a standard ES module import without the 'type' keyword, leading TypeScript to expect a runtime export.
fix
Change `import { MyType }` to `import type { MyType }` to specify a type-only import.
Cannot find name 'ExpectTrue'. Did you mean to import it from 'typescript-type-utils'?
A utility type from the library was used in TypeScript code without being imported first, or with an incorrect name.
fix
Add the necessary type import at the top of your TypeScript file: `import type { ExpectTrue } from 'typescript-type-utils';`.
TS2307: Cannot find module 'typescript-type-utils' or its corresponding type declarations.
The package is not installed, or TypeScript cannot correctly locate its declaration files based on the project's `tsconfig.json` configuration.
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.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
22
Amazon
1
OpenAI (training)
1
Resources
typescript-type-utils — npm install typescript-type-utils · libregistry