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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cfp-studio/type-analyzer

v10.1.8

Published

`@cfp-studio/type-analyzer` 提供 TypeScript 类型静态分析、类型结构抽象与类型生成工具,支持类型收集、推断、序列化、去重、声明生成等能力。

Readme

@cfp-studio/type-analyzer

@cfp-studio/type-analyzer 提供 TypeScript 类型静态分析、类型结构抽象与类型生成工具,支持类型收集、推断、序列化、去重、声明生成等能力。

主要功能

  • TypeScript 类型收集、推断与结构化(AST → 类型树)
  • 支持泛型、交叉/联合类型、映射类型、内置类型等
  • 类型去重、依赖分析、未使用类型剔除
  • 类型声明生成与类型值生成
  • 适用于低代码、可视化、schema 生成等场景

架构与核心模块

  • src/analyzer.ts:类型分析主流程,AST 解析与类型收集
  • src/definitions.ts:类型系统核心定义
  • src/dereference.ts:类型引用解包
  • src/generate-type-declarations.ts:类型声明生成
  • src/generate-type.ts:类型值生成
  • src/strip-unused-types.ts:未使用类型剔除
  • src/type-parameters.ts:泛型与类型参数推断
  • src/helpers/:辅助工具
  • src/index.ts:主入口,导出全部 API

主要导出 API

  • analyzeTypes(reader, entryFiles, options):收集并分析类型
  • dereferenceType(type, types):类型引用解包
  • generateTypeDeclarations(types):类型声明生成
  • generateType(type, types):类型值生成
  • stripUnusedTypes(types, used):剔除未用类型
  • isValid(type):类型合法性校验
  • evaluateType(type, params):泛型推断

典型用法

import { analyzeTypes, dereferenceType, generateTypeDeclarations } from '@cfp-studio/type-analyzer';

const { types } = await analyzeTypes(reader, entryFiles, options);
const [resolved] = dereferenceType(type, types);
const decls = generateTypeDeclarations(types);

依赖

  • typescript:AST 解析
  • @cfp-studio/vfs:虚拟文件系统
  • es-toolkitglobbyprettier

构建与测试

  • pnpm build:TypeScript 编译与打包
  • pnpm test:Vitest 单元测试

License

MIT