`type-samurai` is a TypeScript library offering a collection of advanced utility types designed to extend TypeScript's native type manipulation capabilities. Currently at version 1.1.1, the package provides types for arithmetic operations (e.g., `Sum`), logical statements (`If`, `And`, `Or`), string manipulations, and type introspection (`IsAny`, `IsUnknown`, `IsNever`). It differentiates itself by providing complex, often recursive, type-level computations that are not available in the standard TypeScript utility types. While there's no explicit release cadence mentioned, the library appears to be actively maintained, providing a robust toolkit for highly intricate type-safe programming patterns. This library is entirely focused on compile-time type checking and does not include any runtime code, making it a zero-runtime dependency.
npm install type-samuraiVerified import paths — ran on the pinned version, not inferred.
Demonstrates type-level arithmetic, conditional type evaluation, and type introspection, showcasing the library's compile-time utility without generating runtime code.
Refactor complex type logic into smaller, composable types. Consider if the complexity is truly necessary or if a simpler runtime check could suffice.
Monitor compilation times. Use these advanced types judiciously for critical type safety needs rather than for every minor type manipulation. Consider creating simpler type aliases for common patterns.
Always consult the library's GitHub releases or `package.json`'s `peerDependencies` (if any) for the officially supported TypeScript version. Pin your TypeScript version to avoid unexpected breaking changes in type inference.
Simplify the type arguments passed to `type-samurai` utilities, or break down a single complex type into multiple intermediate types. Increase TypeScript's `maxNodeModuleJsDepth` (though this is often a band-aid).
Restructure the types to produce less expansive union types. Consider if the full range of values needs to be strictly typed at compile-time or if some runtime checks are more appropriate.
Ensure `type-samurai` is installed using `npm install --save-dev type-samurai`, and `tsconfig.json` includes `node_modules` in its `include` or `files` array, or that `typeRoots` is correctly configured if custom paths are used.
No dependency data recorded yet.