3.5 KiB
TypeScript Checking Convention
This document describes the TypeScript checking convention established for the Webamp monorepo.
Current Status
Each TypeScript-enabled package in the monorepo now has a consistent type-check script that performs type checking without emitting files.
Progress: 4 out of 5 packages now passing! 🎉
Package Status
✅ Passing Packages
- webamp: Clean TypeScript compilation
- ani-cursor: Clean TypeScript compilation
- skin-database: Clean TypeScript compilation (fixed JSZip types, Jest types, and Buffer compatibility issues)
- webamp-docs: Clean TypeScript compilation
❌ Failing Packages (Need fixes)
- webamp-modern: 390+ TypeScript errors (conflicting type definitions, target issues)
Convention
Package-level Scripts
Each TypeScript package should have:
{
"scripts": {
"type-check": "tsc --noEmit"
}
}
Important: Always use tsc --noEmit to avoid accidentally creating JavaScript files in source directories.
Root-level Script
The root package.json contains a centralized script that runs type checking for all currently passing packages:
{
"scripts": {
"type-check": "pnpm --filter webamp type-check && pnpm --filter ani-cursor type-check && pnpm --filter skin-database type-check && pnpm --filter webamp-docs type-check"
}
}
CI Integration
The CI workflow (.github/workflows/ci.yml) runs the centralized type-check command:
- name: Lint
run: |
pnpm lint
pnpm type-check
Adding New Packages
When adding a new TypeScript package to the type-check convention:
- Add the
type-checkscript to the package'spackage.json - Ensure the package passes type checking:
pnpm --filter <package-name> type-check - Add the package to the root
type-checkscript - Test the full suite:
pnpm type-check
Fixing Failing Packages
Common Issues
-
Missing Jest types (Fixed in
skin-database):- Install
@types/jestand configure proper Jest setup - Ensure test files are properly configured
- Install
-
Missing package types (Fixed in
skin-database):- Install missing dependencies like
jszip,react-redux,express - Install corresponding
@types/packages where needed - Note: Some packages like JSZip provide their own types
- Install missing dependencies like
-
Buffer compatibility issues (Fixed in
skin-database):- Newer TypeScript versions require explicit casting for
fs.writeFileSync - Use
new Uint8Array(buffer)instead of rawBufferobjects
- Newer TypeScript versions require explicit casting for
-
Conflicting type definitions (
webamp-modern):- Multiple versions of
@types/nodecausing conflicts - Target configuration issues (ES5 vs ES2015+)
- Dependency type mismatches
- Multiple versions of
Recommended Fix Strategy
- Start with packages that have fewer errors
- Focus on one category of errors at a time
- Update TypeScript compiler target if needed (many errors require ES2015+)
- Ensure proper dependency management to avoid type conflicts
Benefits
- Consistency: All packages use the same type-checking approach
- CI Integration: Automatic type checking prevents type errors from being merged
- Developer Experience: Simple
pnpm type-checkcommand for full project validation - Incremental: Only includes packages that currently pass, allowing gradual improvement
Future Work
- Fix remaining packages to include them in the type-check suite
- Consider stricter TypeScript configurations for better type safety
- Investigate automated type checking in development workflow