three-versions-types
Use when publishing type declarations. Use when dealing with version conflicts. Use when libraries have types. Use when managing @types packages. Use when debugging type mismatches.
How do I install this agent skill?
npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill three-versions-typesIs this agent skill safe to install?
- Gen Agent Trust Hubpass
This skill is a purely educational guide concerning TypeScript version management. It contains no malicious code, commands, or data exfiltration patterns. The provided examples use standard package management practices and well-known libraries.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerpass
1 file scanned · No issues
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
Understand the Three Versions Involved in Type Declarations
Overview
When working with TypeScript types, three versions must align: the version of the package you're using, the version of its type declarations (@types), and the version of TypeScript itself. Misalignment between these versions can cause confusing type errors even when the code works at runtime.
Understanding these three versions helps diagnose and prevent type compatibility issues.
The Three Versions
- Package version - The runtime library (e.g., lodash@4.17.21)
- @types version - Type declarations (e.g., @types/lodash@4.14.191)
- TypeScript version - Your TypeScript compiler (e.g., typescript@5.2.2)
When to Use This Skill
- Publishing type declarations
- Debugging version conflicts
- Working with @types packages
- Managing library dependencies
- Type errors that don't match runtime behavior
The Iron Rule
Keep package, @types, and TypeScript versions compatible. Update them together to avoid mysterious type errors.
Common Version Issues
// Package updated but @types not updated
import { newFeature } from 'library'; // Runtime works
// Error: Module 'library' has no exported member 'newFeature'
// TypeScript too old for new type features
// Error: Type instantiation is excessively deep
// (Newer @types use features old TS doesn't support)
// @types too new for package version
// Types reference features not in actual package
Best Practices
// package.json
{
"dependencies": {
"lodash": "^4.17.21"
},
"devDependencies": {
"@types/lodash": "^4.14.191",
"typescript": "^5.2.2"
}
}
Checking Versions
# Check all three versions
npm ls lodash @types/lodash typescript
# Check for outdated packages
npm outdated
# Update together
npm update lodash @types/lodash typescript
Reference
- Effective TypeScript, 2nd Edition by Dan Vanderkam
- Item 66: Understand the Three Versions Involved in Type Declarations
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/marius-townhouse/effective-typescript-skills/three-versions-types">View three-versions-types on skillZs</a>