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

yup-type-support

v1.0.6

Published

A typescript support for yup. Able to infer the yup schema from a typescript interface.

Readme

Yup Type Support

A typescript compiler plugin that infers yup schema object from a typescript type or interface.

Installation

Use the package manager npm to install Yup Type Support.

npm i yup-type-support -D

Usage

Yup Type Support requires ttypescript. You can install the ttypescript using:

npm i ttypescript -D

Next you need to edit the tsconfig file to add the plugin to the compiler options.

{
  "compilerOptions": {
    "plugins": [{ "transform": "yup-type-support", "type": "program" }],
  }
}

To use the yup type support to generate yup schema object at the compile time automatically, you simply need to put a comment annotation in the yup.object() function call.

Example:

import * as yup from 'yup'

export interface simpleAccount {
    id: number;
    name: string;
    checking: boolean;
    notes?: string;
}

/* this will generate the following schema at compile time
 * exports.simpleAccountSchema = yup.object({
 *    id: yup.number().required(),
 *    name: yup.string().required(),
 *    checking: yup.boolean().required(),
 *    note: yup.string().optional()
 * });
 */
export const simpleAccountSchema: yup.SchemaOf<simpleAccount> = yup.object(/* guess schema */);

Currently, the plugin only supports number and string type, as well as the optional mark. More features are still under development. You also need to follow the format in the example closely (mainly how you declare the schema that will get changed in compile time), more flexible format support is also under development.

Now you can compile your typescript file using (or you can add the command to your package.json file):

ttsc

Supported functions

1. Types

Currently, the yup-type-support supports all three primitive types in typescript. Support for array, enum and other types are still under development.

1.1. string

interface myInterface {
    key: string
}

// The interface above generates the following schema
const myInterfaceSchema: yup.SchemaOf<myInterface> = yup.object({
    key: yup.string().required(),
});

1.2. number

interface myInterface {
    key: number
}

// The interface above generates the following schema
const myInterfaceSchema: yup.SchemaOf<myInterface> = yup.object({
    key: yup.number().required(),
});

1.3. boolean

interface myInterface {
    key: boolean
}

// The interface above generates the following schema
const myInterfaceSchema: yup.SchemaOf<myInterface> = yup.object({
    key: yup.boolean().required(),
});

2. Properties

Currently, the yup-type-support supports requried and optional property of yup. Support for nullable is still under development.

2.1. optional

interface myInterface {
    key?: string
}

// The interface above generates the following schema
const myInterfaceSchema: yup.SchemaOf<myInterface> = yup.object({
    key: yup.string().optional(),
});

3. Roadmap for more functions

The development for now will focus on supporting more types, including array, enum, etc. For properties, nullable will be supported soon. The next major goal is to support nested types and convert them to the nested schema for yup.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT