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/tsc

v1.0.19

Published

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

Readme

@mcswift/tsc

English | 中文


中文

提供基于 TypeScript 的声明文件生成工具,方便在打包构建等流程中快速生成 .d.ts 声明文件。

安装

npm install @mcswift/tsc
# or
pnpm add @mcswift/tsc

注意: 使用该包需要在运行环境中已经安装了 typescript 并确保在 node_modules/.bin 下能够找到 tsc 命令。

使用指南及接口文档

你可以使用 generatorDeclare 快速为指定目录生成 TypeScript 声明文件,底层会自动查找并调用 tsc。

1. 生成类型声明文件

默认会读取当前工作目录下的 tsconfig.json 并只输出声明文件(--emitDeclarationOnly)。

import { generatorDeclare } from "@mcswift/tsc";

async function buildDeclarations() {
  // 指定源码输入目录和声明文件输出目录
  await generatorDeclare("src", "types");
  console.log("声明文件生成完毕!");
}

buildDeclarations();

2. 自定义执行目录与配置文件

如果你的项目结构比较复杂,你可以指定执行的根目录和配置文件的路径:

import { generatorDeclare } from "@mcswift/tsc";

async function build() {
  const rootDir = process.cwd(); // 或者指定特定的包目录
  const tsconfigPath = "./tsconfig.build.json";
  
  await generatorDeclare("src", "dist/types", rootDir, tsconfigPath);
}

类型注释:

const generatorDeclare: (
  inputDir: string,
  outDir: string,
  root?: string,
  tsconfig?: string
) => Promise<void>;

English

Provides a TypeScript-based declaration file generation tool, making it easy to quickly generate .d.ts declaration files during bundling and build processes.

Installation

npm install @mcswift/tsc
# or
pnpm add @mcswift/tsc

Note: Using this package requires typescript to be installed in your runtime environment, and ensuring the tsc command can be found under node_modules/.bin.

Usage Guide & API Documentation

You can use generatorDeclare to quickly generate TypeScript declaration files for a specified directory. It automatically locates and invokes tsc under the hood.

1. Generate Type Declaration Files

By default, it reads the tsconfig.json in the current working directory and only emits declaration files (--emitDeclarationOnly).

import { generatorDeclare } from "@mcswift/tsc";

async function buildDeclarations() {
  // Specify the source input directory and the declaration file output directory
  await generatorDeclare("src", "types");
  console.log("Declaration files generated successfully!");
}

buildDeclarations();

2. Custom Execution Directory and Configuration File

If your project structure is complex, you can specify the root directory for execution and the path to the configuration file:

import { generatorDeclare } from "@mcswift/tsc";

async function build() {
  const rootDir = process.cwd(); // Or specify a specific package directory
  const tsconfigPath = "./tsconfig.build.json";
  
  await generatorDeclare("src", "dist/types", rootDir, tsconfigPath);
}

Type Annotations:

const generatorDeclare: (
  inputDir: string,
  outDir: string,
  root?: string,
  tsconfig?: string
) => Promise<void>;