npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ts-gems

v4.0.4

Published

Valuable typing extensions for TypeScript

Readme

ts-gems

NPM Version NPM Downloads CI Tests

Think of it as lodash — but every function operates on types, not values, and runs at compile time for free.

Quick question: what's the type of Partial<{ user: { name: string } }>['user']?

If you guessed { name?: string }, that's the intuitive answer — and it's wrong. TypeScript's built-in Partial<T> only reaches the first level. The real answer is { name: string } — still fully required underneath, still ready to blow up at runtime the moment you try to build one incrementally.

type Config = { user: { name: string; age: number } };

type Shallow = Partial<Config>;
// { user?: { name: string; age: number } }   <- still required inside!

type Deep = DeepPartial<Config>;
// { user?: { name?: string; age?: number } }  <- actually usable

That one gap is the whole reason this library exists. Partial, Required, Readonly, and Pick/Omit all share the same blind spot: they stop at the surface. ts-gems finishes what TypeScript started — and then keeps going into places you didn't know needed a type yet.

A few things that might surprise you

Freeze a config tree, arrays included, in one line:

import type { DeeperReadonly } from 'ts-gems';

type FrozenConfig = DeeperReadonly<{
  servers: { host: string; port: number }[];
}>;
// every level is readonly — including inside the array elements

Turn any interface into an API-safe DTO — no functions, no symbols, recursively:

import type { DTO } from 'ts-gems';

class User {
  name = '';
  greet() {}
  [Symbol.iterator]() {}
}

type UserResponse = DTO<User>;
// { name: string } — methods and symbol keys are gone, nested objects too

Stop mixing up two numbers that were never meant to meet:

import type { Opaque } from 'ts-gems';

type UserId = Opaque<number, 'UserId'>;
type OrderId = Opaque<number, 'OrderId'>;

function cancelOrder(id: OrderId) {
  /* ... */
}

declare const userId: UserId;
cancelOrder(userId); // ✗ compile error — nominally different, even though both are `number`

Merge types without the intersection trap:

type A = { name: string };
type B = { name: Date }; // overlapping key, different type

type Bad = A & B; // name: string & Date — a type nothing can satisfy. Oops.
type Good = Combine<A, B>; // { name: string } — A simply wins

None of this is magic. It's ~60 small, focused utility types, each solving one specific gap — composable, dependency-free, and fully documented with runnable examples.

Explore the full toolkit

📖 Browse the complete API reference →

| Category | What it does | | --- | --- | | Deep* / Deeper* family | Mutable, Readonly, Partial, Required, Nullish — that finally reach nested objects and arrays | | DTO / PartialDTO / PatchDTO | Turn any class or interface into a clean transfer-object shape | | Pick / Omit family | Select by key, by function-vs-data, or by matching value type | | Opaque | Nominal typing / branded primitives for TypeScript's structural type system | | Combine | Merge types without the & intersection trap | | 20+ type guards | IfAny, IfNever, IfEquals, IfTuple, IfCompatible, and more, for building your own conditional types | | And / Or | Compile-time boolean logic to combine several guards into one |

Installation

npm install ts-gems --save
import { DeepPartial, DTO, Opaque, StrictOmit } from 'ts-gems';

Everything is exported from the package root — no sub-path imports, no runtime cost. It's types all the way down (with twelve tiny as* cast helpers thrown in, purely for ergonomics).

Node Compatibility

  • node >= 16.x

License

ts-gems is available under the MIT license.