Typecheck more packages in CI

This commit is contained in:
Jordan Eldredge 2025-07-06 16:23:57 -07:00
parent f9f892bde1
commit 8abcf9d139
9 changed files with 114 additions and 3 deletions

View file

@ -121,7 +121,7 @@ jobs:
- name: Lint
run: |
pnpm lint
pnpm --filter webamp type-check
pnpm type-check
# Test job - runs in parallel
test:

103
docs/typescript-checking.md Normal file
View file

@ -0,0 +1,103 @@
# 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.
### Package Status
#### ✅ Passing Packages
- **webamp**: Clean TypeScript compilation
- **ani-cursor**: Clean TypeScript compilation
- **webamp-docs**: Clean TypeScript compilation (after adding webamp workspace dependency)
#### ❌ Failing Packages (Need fixes)
- **skin-database**: 172 TypeScript errors (missing types, test setup issues)
- **webamp-modern**: 390+ TypeScript errors (conflicting type definitions, target issues)
## Convention
### Package-level Scripts
Each TypeScript package should have:
```json
{
"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:
```json
{
"scripts": {
"type-check": "pnpm --filter webamp type-check && pnpm --filter ani-cursor type-check && pnpm --filter webamp-docs type-check"
}
}
```
### CI Integration
The CI workflow (`.github/workflows/ci.yml`) runs the centralized type-check command:
```yaml
- name: Lint
run: |
pnpm lint
pnpm type-check
```
## Adding New Packages
When adding a new TypeScript package to the type-check convention:
1. Add the `type-check` script to the package's `package.json`
2. Ensure the package passes type checking: `pnpm --filter <package-name> type-check`
3. Add the package to the root `type-check` script
4. Test the full suite: `pnpm type-check`
## Fixing Failing Packages
### Common Issues
1. **Missing Jest types** (`skin-database`):
- Install `@types/jest` and configure proper Jest setup
- Ensure test files are properly configured
2. **Conflicting type definitions** (`webamp-modern`):
- Multiple versions of `@types/node` causing conflicts
- Target configuration issues (ES5 vs ES2015+)
- Dependency type mismatches
3. **Missing dependencies**:
- Missing type definitions for imported modules
- Incorrect dependency references
### Recommended Fix Strategy
1. Start with packages that have fewer errors
2. Focus on one category of errors at a time
3. Update TypeScript compiler target if needed (many errors require ES2015+)
4. 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-check` command 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

View file

@ -11,6 +11,7 @@
"scripts": {
"test": "jest",
"lint": "eslint . --ext ts,tsx,js,jsx --rulesdir=packages/webamp-modern/tools/eslint-rules",
"type-check": "pnpm --filter webamp type-check && pnpm --filter ani-cursor type-check && pnpm --filter webamp-docs type-check",
"deploy": "sh deploy.sh",
"format": "prettier --write '**/*.{js,ts,tsx}'"
},

View file

@ -21,6 +21,7 @@
"homepage": "https://github.com/captbaritone/webamp/tree/master/packages/ani-cursor",
"scripts": {
"build": "tsc",
"type-check": "tsc --noEmit",
"test": "jest",
"prepublish": "tsc"
},

View file

@ -51,6 +51,7 @@
"build": "next build",
"start": "next start",
"lint:next": "next lint",
"type-check": "tsc --noEmit",
"tweet": "ts-node --transpile-only ./cli.ts tweet",
"fetch-metadata": "ts-node --transpile-only ./cli.ts fetch-metadata",
"bot": "ts-node --transpile-only ./discord-bot/index.js",

View file

@ -12,6 +12,7 @@
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"type-check": "tsc",
"typecheck": "tsc"
},
"dependencies": {
@ -21,7 +22,8 @@
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
"react-dom": "^19.0.0",
"webamp": "workspace:*"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.8.1",

View file

@ -10,6 +10,7 @@
"minify": "snowpack build --config ./snowpack.x2nie.config.mjs",
"serve": "http-server ./build",
"lint": "eslint . --ext ts,js --rulesdir=./tools/eslint-rules --ignore-pattern=temp/",
"type-check": "tsc --noEmit",
"test": "jest",
"puppet1": "node tools/puppet1.js",
"extract-object-types": "node tools/extract-object-types.js",

View file

@ -42,7 +42,6 @@
"build": "vite build --emptyOutDir",
"build-library": "node ./scripts/rollup.mjs",
"prepublishOnly": "npm run build-library && npm run type-check",
"publish-next": "pnpm publish --new-version=\"0.0.0-next-$(git rev-parse --short HEAD)\" --tag next",
"serve": "http-server ./dist/demo-site",
"start": "vite",
"test": "jest --config=config/jest.unit.js",

3
pnpm-lock.yaml generated
View file

@ -504,6 +504,9 @@ importers:
react-dom:
specifier: ^19.0.0
version: 19.1.0(react@19.1.0)
webamp:
specifier: workspace:*
version: link:../webamp
devDependencies:
'@docusaurus/module-type-aliases':
specifier: 3.8.1