GitShow/antfu/tsnapi
antfu

tsnapi

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

by antfu
snapshotsnapshot-testing
Star on GitHubForknpm

TypeScript

199 stars3 forks4 contributorsActive · 20h agoSince 2026v1.4.0MIT

Meet the team

See all 4 on GitHub →
antfu
antfu61 contributions
antfubot
antfubot4 contributions
jycouet
jycouet3 contributions

Languages

View on GitHub →
TypeScript81.5%
Vue16.7%
JavaScript1.3%
CSS0.4%
HTML0.1%

Commit activity

Last 12 weeks · 18 commits

Full graph →

Community health

5 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template✓PR Template

Recent fixes

View closed PRs →
jycouet
Namespace members lose their signatures in DTS snapshotsClosedIssue

Given: the DTS snapshot renders: The signature of is dropped (and nested namespaces lose everything below the first level), so changes to namespace member signatures don't invalidate the snapshot. Context: trying tsnapi in sveltejs/cli (sveltejs/cli#1162), where exposes most of its API through namespaces (, ...) - none of those signatures end up guarded.

jycouet · 1mo ago
jycouet
Unexported types referenced by exports are not inlinedClosedIssue

Given: the DTS snapshot only shows - the shape of is absent, so changing it doesn't invalidate the snapshot even though it changes the public contract. Would you consider inlining (or additionally emitting) declarations reachable from exports, possibly behind an option? Context: trying tsnapi in sveltejs/cli (sveltejs/cli#1162). Related but separate from #31.

jycouet · 1mo ago
antfu
feat: guard snapshot updates against breaking API changes for VitestMergedPR

Summary Extends the breaking-changes guard from #33 to the Vitest integration. delegated entirely to Vitest's , which overwrites snapshot files unconditionally on . A removed or narrowed export would slip through silently — exactly what the guard the CLI and rolldown plugin already have is meant to prevent. Changes Guard in the Vitest integration: runs before each , detecting update mode via Vitest's snapshot state (). On a removed/narrowed export it throws — failing the test and leaving the snapshot file on disk untouched. option added to (inherited by ). New exported — a pure, Vitest-independent helper (caller supplies + existing content), reusable for custom snapshot flows. README: new "Breaking changes guard" subsection under Vitest. Note on the escape hatch Vitest's CLI (cac) rejects unknown flags, so cannot be passed through . For the Vitest integration the escape hatches are the env var or the option — documented explicitly. Verification Unit tests in (9 cases, both surfaces). Also verified end-to-end against live runs: Breaking change → tests fail with , snapshot on disk unchanged. Additive change → passes through and updates (this repo's own run confirms it). → breaking update allowed through. Full suite (145), typecheck, and lint all pass. 🤖 Generated with Claude Code

antfu · 1mo ago
Structured data for AI agents

Repository: antfu/tsnapi. Description: Library public API snapshot testing for runtime exports and type declarations. Stars: 199, Forks: 3. Primary language: TypeScript. Languages: TypeScript (81.5%), Vue (16.7%), JavaScript (1.3%), CSS (0.4%), HTML (0.1%). License: MIT. Topics: snapshot, snapshot-testing. Latest release: v1.4.0 (20h ago). Open PRs: 0, open issues: 0. Last activity: 20h ago. Community health: 85%. Top contributors: antfu, antfubot, jycouet.

·@ofershap

Replace github.com with gitshow.dev