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

@loydjs/types

v1.1.0

Published

Loyd types — zero-runtime inference

Readme

CI License Bundle TypeScript npm downloads


Overview

@loydjs/types is a type-only package — it ships zero runtime code. It provides TypeScript utility types for inferring the input and output types of any Loyd schema, and helper types for building type-safe applications on top of Loyd.


Installation

npm install @loydjs/types

Requires @loydjs/core · TypeScript ≥ 5.4 · "strict": true in tsconfig.json


API

Infer<TSchema>

Infers the output type of a schema — the type of result.data after a successful safeParse.

import { object, string, number, array, optional } from "@loydjs/schema";
import type { Infer } from "@loydjs/types";

const UserSchema = object({
  id:      number().int().min(1),
  name:    string().minLength(2),
  email:   string().email(),
  age:     optional(number().int().min(0)),
  roles:   array(string()),
});

type User = Infer<typeof UserSchema>;
// {
//   id:    number
//   name:  string
//   email: string
//   age?:  number | undefined
//   roles: string[]
// }

InferOutput<TSchema>

Alias for Infer. Explicit name for cases where you want to be clear about direction.

import type { InferOutput } from "@loydjs/types";

type UserOutput = InferOutput<typeof UserSchema>;
// same as Infer<typeof UserSchema>

InferInput<TSchema>

Infers the input type — what the schema accepts before validation and transformation. Differs from the output type when transforms are applied (e.g. .trim(), .toLowerCase()).

import { string } from "@loydjs/schema";
import type { InferInput, InferOutput } from "@loydjs/types";

const NameSchema = string().trim().toLowerCase();

type NameInput  = InferInput<typeof NameSchema>;  // string
type NameOutput = InferOutput<typeof NameSchema>; // string (transformed)

SchemaMap

The type used for object() shape definitions.

import type { SchemaMap } from "@loydjs/types";
import type { LoydSchema } from "@loydjs/core";

function buildForm<T extends SchemaMap>(shape: T) {
  return object(shape);
}

InferSchemaMap<TShape>

Infers the output type of an object shape directly.

import type { InferSchemaMap } from "@loydjs/types";

const shape = {
  name:  string(),
  email: string().email(),
};

type FormData = InferSchemaMap<typeof shape>;
// { name: string; email: string }

Usage patterns

API route types

import type { Infer } from "@loydjs/types";

const CreatePostSchema = object({
  title:   string().minLength(3).maxLength(200),
  body:    string().minLength(10),
  tags:    array(string()).max(10),
  published: boolean(),
});

type CreatePostInput = Infer<typeof CreatePostSchema>;

async function createPost(data: CreatePostInput) {
  // data is fully typed
  const post = await db.posts.create(data);
  return post;
}

Generic validators

import type { Infer } from "@loydjs/types";
import type { LoydSchema } from "@loydjs/core";
import { safeParse } from "@loydjs/core";

function validate<T extends LoydSchema<unknown>>(
  schema: T,
  input: unknown
): Infer<T> {
  const result = safeParse(schema, input);
  if (!result.success) throw new Error(result.issues[0].code);
  return result.data as Infer<T>;
}

Dependencies

| Package | Role | |:---|:---| | @loydjs/core | LoydSchema base type for type inference |

@loydjs/types has zero runtime dependencies and ships no JavaScript.


Documentation

loyddev-psi.vercel.app


License

MIT © b3nito404