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

@mcswift/types

v1.0.19

Published

[English](#english) | [中文](#中文)

Readme

@mcswift/types

English | 中文


中文

提供了一系列基础的 TypeScript 类型定义,包括通用的 JSON 数据结构以及 NPM package.json 的强类型约束。

安装

npm install @mcswift/types -D
# or
pnpm add @mcswift/types -D

使用指南及接口文档

你可以直接导入该库中的类型,并在你的 TypeScript 代码中使用它们来提供更严格的类型约束。

1. JSON 类型

提供了标准的 JSON 数据结构类型:

import type { JSONValue, JSONArray, JSONRecord, JSONBaseValue } from "@mcswift/types";

const data: JSONRecord = {
  name: "mcswift",
  age: 18,
  hobbies: ["coding", "reading"],
};

const arr: JSONArray = [1, "2", true, null];

类型注释:

export type JSONBaseValue = string | number | boolean | null;

export interface JSONRecord {
  [key: string]: JSONValue;
}

export type JSONValue = JSONBaseValue | JSONRecord | JSONValue[];

export type JSONArray = JSONValue[];

2. NPM Package 类型

提供了强类型的 package.json 约束:

import type { NPM } from "@mcswift/types";

const packageJson: NPM.Package = {
  name: "my-package",
  version: "1.0.0",
  type: "module",
  scripts: {
    build: "tsc"
  },
  dependencies: {
    "lodash": "^4.17.21"
  }
};

类型注释:

export namespace NPM {
  export interface Package {
    name?: string;
    version?: string;
    description?: string;
    scripts?: Record<string, string>;
    dependencies?: Record<string, string>;
    devDependencies?: Record<string, string>;
    peerDependencies?: Record<string, string>;
    type?: "module" | "commonjs";
    // ... 包含完整的 package.json 字段定义
  }
}

3. String 拓展类型

提供了一些基础的字符串模板类型约束,如电子邮件:

import type { EmailUrl } from "@mcswift/types";

const email: EmailUrl = "[email protected]";

类型注释:

export type EmailUrl = `${string}@${string}.${string}`;

English

Provides a series of fundamental TypeScript type definitions, including standard JSON data structures and strictly-typed constraints for NPM's package.json.

Installation

npm install @mcswift/types -D
# or
pnpm add @mcswift/types -D

Usage Guide & API Documentation

You can import types directly from this library and use them in your TypeScript code to enforce stricter type constraints.

1. JSON Types

Provides standard JSON data structure types:

import type { JSONValue, JSONArray, JSONRecord, JSONBaseValue } from "@mcswift/types";

const data: JSONRecord = {
  name: "mcswift",
  age: 18,
  hobbies: ["coding", "reading"],
};

const arr: JSONArray = [1, "2", true, null];

Type Annotations:

export type JSONBaseValue = string | number | boolean | null;

export interface JSONRecord {
  [key: string]: JSONValue;
}

export type JSONValue = JSONBaseValue | JSONRecord | JSONValue[];

export type JSONArray = JSONValue[];

2. NPM Package Types

Provides strictly-typed constraints for package.json:

import type { NPM } from "@mcswift/types";

const packageJson: NPM.Package = {
  name: "my-package",
  version: "1.0.0",
  type: "module",
  scripts: {
    build: "tsc"
  },
  dependencies: {
    "lodash": "^4.17.21"
  }
};

Type Annotations:

export namespace NPM {
  export interface Package {
    name?: string;
    version?: string;
    description?: string;
    scripts?: Record<string, string>;
    dependencies?: Record<string, string>;
    devDependencies?: Record<string, string>;
    peerDependencies?: Record<string, string>;
    type?: "module" | "commonjs";
    // ... Contains complete package.json field definitions
  }
}

3. String Extension Types

Provides basic string template type constraints, such as email addresses:

import type { EmailUrl } from "@mcswift/types";

const email: EmailUrl = "[email protected]";

Type Annotations:

export type EmailUrl = `${string}@${string}.${string}`;