diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16d9bcc6..18460af7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,7 +121,7 @@ jobs: - name: Lint run: | pnpm lint - pnpm --filter webamp type-check + pnpm type-check # Test job - runs in parallel test: diff --git a/docs/typescript-checking.md b/docs/typescript-checking.md new file mode 100644 index 00000000..fa8871ad --- /dev/null +++ b/docs/typescript-checking.md @@ -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 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 diff --git a/package.json b/package.json index 69c8443f..f55be73b 100644 --- a/package.json +++ b/package.json @@ -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}'" }, diff --git a/packages/ani-cursor/package.json b/packages/ani-cursor/package.json index c5832dd9..526ee0db 100644 --- a/packages/ani-cursor/package.json +++ b/packages/ani-cursor/package.json @@ -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" }, diff --git a/packages/skin-database/package.json b/packages/skin-database/package.json index aa0568bd..c4aa99d4 100644 --- a/packages/skin-database/package.json +++ b/packages/skin-database/package.json @@ -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", diff --git a/packages/webamp-docs/package.json b/packages/webamp-docs/package.json index d6872790..a2df40db 100644 --- a/packages/webamp-docs/package.json +++ b/packages/webamp-docs/package.json @@ -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", diff --git a/packages/webamp-modern/package.json b/packages/webamp-modern/package.json index 49291271..d1fdbf39 100644 --- a/packages/webamp-modern/package.json +++ b/packages/webamp-modern/package.json @@ -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", diff --git a/packages/webamp/package.json b/packages/webamp/package.json index 56b857c8..81780582 100644 --- a/packages/webamp/package.json +++ b/packages/webamp/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9f2bf5a9..75e8e6f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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