antfu

antfu / tsnapi

Public

Library public API snapshot testing for runtime exports and type declarations.

54
0
100% credibility
Found Apr 10, 2026 at 54 stars -- GitGems finds repos before they trend. Get early access to the next one.
Sign Up Free
AI Analysis
TypeScript
AI Summary

tsnapi captures snapshots of a TypeScript library's public runtime exports and type declarations into readable files for detecting unintended API changes during development.

How It Works

1
πŸ“š Discover tsnapi

While building a helpful tool that others use, you learn about a simple way to capture and protect its public features exactly as they are.

2
πŸ› οΈ Add it to your project

You easily bring tsnapi into your workspace so it watches your tool's outer layer.

3
✨ Run your first check

You prepare your tool once, and tsnapi creates clear pictures of what it offers to users – both how it works and its shapes.

4
πŸ’Ύ Save the pictures

You keep these picture files right with your code, like a photo album of your tool's promises.

5
πŸ” Check on future changes

Each time you update your tool, tsnapi compares the new pictures to the old ones and alerts you if something shifted unexpectedly.

6
βœ… Review and update

You look at the differences, decide if they're good, and refresh the pictures to match when ready.

πŸŽ‰ Stable tool interface

Now your tool's public side stays reliable, so users always know what to expect without surprises.

Sign up to see the full architecture

5 more

Sign Up Free

Star Growth

See how this repo grew from 54 to 54 stars Sign Up Free
Repurpose This Repo

Repurpose is a Pro feature

Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.

Unlock Repurpose
AI-Generated Review

What is tsnapi?

tsnapi is a TypeScript library for snapshot testing your package's public API, capturing runtime exports into `.snapshot.js` files and type declarations into `.snapshot.d.ts` files you commit to your github library repository. It scans package.json exports, parses dist files, and generates human-readable snapshots that highlight unintended changes like renamed functions or broken types in git diffs. Like Vitest snapshots but for your library's public API surface, it integrates as a Rolldown/tsdown plugin, standalone CLI (`tsnapi -u` to update), Vitest helper, or direct API call.

Why is it gaining traction?

Unlike manual export checks or brittle type tests, tsnapi fails builds on API drifts with colored diffs, catching removes, signature tweaks, or leaks early. Devs love the zero-config plugin for bundlers and CLI for quick scans of any github library api, plus Vitest integration for inline snapshots. It handles re-exports and multi-entry packages seamlessly, making public api declarations regression-proof without custom scripts.

Who should use this?

TypeScript library authors publishing npm packages, especially those with complex exports or frequent refactors. Ideal for maintainers of github library projects like prompt library github tools or api wrappers who want git diffs to flag public api changes. Skip if you're not shipping dist builds or don't care about type stability.

Verdict

Solid pick for TS lib devsβ€”54 stars and 1.0% credibility score show it's early but battle-tested by antfu; docs are crisp with examples. Adopt if you bundle with Rolldown; otherwise, prototype via CLI before full integration. (187 words)

Sign up to read the full AI review Sign Up Free

Similar repos coming soon.