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

@saco/types

v1.0.3

Published

Global TypeScript utility types for saco

Readme

@saco/types

全局 TypeScript 工具类型。安装后无需 import,直接使用。

本文档由 npm run build 根据 src/*.d.ts 注释生成,请勿手改。

安装

npm i @saco/types

tsconfig.json

{
  "compilerOptions": {
    "types": ["@saco/types"]
  }
}

已有 types 数组时,追加 "@saco/types" 即可。

类型

AnyObj

任意键值的对象

例如:
    const obj: Record<string, any> = { a: 'x' }
任意:
    const obj: AnyObj = { a: 'x' }
    const obj: AnyObj<number> = { a: 1 }

any-obj.d.ts

HTMLAttributes

允许任意 data-*

若在 vue 定义,需与 tsconfig vueCompilerOptions.dataAttributes 同步

interface HTMLAttributes

html.d.ts

InputHTMLAttributes

选文件夹上传(非标准属性,DOM 有、Vue 类型未收录)

interface InputHTMLAttributes

html.d.ts

Intersection

交集

A = { a: string, b: number }
B = { a: number, b: number, c: boolean }
Intersection<A, B> => { a: string, b: number } | { a: number, b: number }

intersection.d.ts

Joint

联合类型:将多个类型联合起来,形成一个新的类型

Joint<[A, B]> => A | B

joint.d.ts

Keys

获取对象键名(排除数字和符号),得到键名数组

例如:
    const obj = { a: '1' }
    Object.keys(obj).forEach(key => {
      const item = obj[key as keyof typeof obj]
    })
获取后:
    (Object.keys(obj) as Keys<typeof obj>).forEach(key => {
      const item = obj[key]
    })

keys.d.ts

pdfjs-dist

兼容pdfjs-dist提示

declare module 'pdfjs-dist'

pdfjs-dist.d.ts

Range

生成 0 到 N-1 的数字联合(不是元组,也不含 N)

Range<5> => 0 | 1 | 2 | 3 | 4

range.d.ts

SetOptional

将对象指定键设为可选(K 为 T 的键)

例如:
    type A = { a: string; b: number };
可选后:
    type Rust = SetOptional<A, 'a'>;
     鼠标悬停 Rust 显示:{ a?: string; b: number }

set-optional.d.ts

SetRequired

将对象指定键设为必选(K 为 T 的键)

例如:
    type A = { a?: string; b?: number };
必选后:
    type Rust = SetRequired<A, 'a'>;
     鼠标悬停 Rust 显示:{ a: string; b?: number }

set-required.d.ts

Simplify

简化类型

例如:
    type A = { a: string };
    type B = { b: number };
    type Rust = A & B & { c: boolean };
     鼠标悬停 Rust 显示:A & B & { c: boolean }
简化:
    type Rust = Simplify<A & B & { c: boolean }>
     鼠标悬停 Rust 显示:{ a: string, b: number, c: boolean }

simplify.d.ts