|
| 1 | +# Angular 21 Migration Notes |
| 2 | + |
| 3 | +## Issues Resolved |
| 4 | + |
| 5 | +### 1. **Dependency Conflict - TypeScript Version** |
| 6 | + - **Problem**: `@angular-devkit/build-angular@21` requires `typescript >=5.9 <6.0`, but the project had `typescript ^5.6.3` |
| 7 | + - **Solution**: Updated TypeScript to `^5.9.3` |
| 8 | + |
| 9 | +### 2. **Jest/Testing Framework Compatibility** |
| 10 | + - **Problem**: `jest-preset-angular@14.4.2` only supports `@angular/compiler-cli@>=15.0.0 <21.0.0`, incompatible with Angular 21 |
| 11 | + - **Solution**: Updated to compatible versions: |
| 12 | + - `jest-preset-angular` → `^16.1.1` (supports Angular 21) |
| 13 | + - `jest` → `^30.2.0` |
| 14 | + - `jest-environment-jsdom` → `^30.2.0` (explicitly added, required by Jest 30) |
| 15 | + - `@types/jest` → `^30.0.0` |
| 16 | + - `ts-jest` → `^29.4.6` |
| 17 | + |
| 18 | +### 3. **Type Definition Errors: Missing Angular Modules** |
| 19 | + - **Problem**: Errors like: |
| 20 | + - `Cannot find module '@angular/core/primitives/di'` |
| 21 | + - `Cannot find module '@angular/common/http'` |
| 22 | + - **Root Cause**: `codelyzer@6.0.2` and `protractor@7.0.0` depend on Angular 9 type definitions, causing version conflicts |
| 23 | + - **Solution**: |
| 24 | + - Removed `codelyzer` (deprecated, replaced by ESLint which is already configured) |
| 25 | + - Removed `protractor` (deprecated, replaced by modern testing tools) |
| 26 | + - Added `skipLibCheck: true` to all tsconfig files to suppress type errors in dependencies |
| 27 | + |
| 28 | +### 4. **TSConfig Updates** |
| 29 | + Updated all TypeScript configuration files to include: |
| 30 | + - `skipLibCheck: true` - Skips type checking of declaration files to prevent errors from incompatible type definitions |
| 31 | + - `forceConsistentCasingInFileNames: true` - Ensures file name consistency across platforms |
| 32 | + |
| 33 | +## Files Modified |
| 34 | + |
| 35 | +1. **package.json** |
| 36 | + - Removed: `codelyzer`, `protractor`, `tslint` |
| 37 | + - Updated: `typescript`, `jest`, `jest-preset-angular`, `@types/jest`, `ts-jest`, `jest-environment-jsdom` |
| 38 | + |
| 39 | +2. **tsconfig.json** |
| 40 | + - Added: `skipLibCheck`, `forceConsistentCasingInFileNames` |
| 41 | + |
| 42 | +3. **projects/ng-sortgrid/tsconfig.lib.json** |
| 43 | + - Added: `skipLibCheck` |
| 44 | + |
| 45 | +4. **projects/ng-sortgrid/tsconfig.spec.json** |
| 46 | + - Added: `skipLibCheck` |
| 47 | + |
| 48 | +5. **projects/ng-sortgrid-demo/tsconfig.app.json** |
| 49 | + - Added: `skipLibCheck` |
| 50 | + |
| 51 | +## Build/Test Commands |
| 52 | + |
| 53 | +All the following commands should now work without type errors: |
| 54 | + |
| 55 | +```bash |
| 56 | +npm install # Install dependencies |
| 57 | +npm run build:lib # Build the library |
| 58 | +npm run test:lib # Run library tests |
| 59 | +npm run lint # Run ESLint |
| 60 | +npm run start # Start demo app dev server |
| 61 | +``` |
| 62 | + |
| 63 | +## Notes |
| 64 | + |
| 65 | +- Engine warnings about Node.js version are expected with Node v23.6.0. Angular 21 officially supports Node 20.19.0, 22.12.0, or >=24.0.0 |
| 66 | +- If you want to avoid engine warnings, consider using nvm to switch to Node 22.x or higher |
| 67 | +- The `skipLibCheck` setting is safe and commonly used in production Angular projects to suppress spurious type errors from dependencies |
| 68 | + |
| 69 | +## Deprecation Warnings |
| 70 | + |
| 71 | +The following warnings are expected from npm and are safe to ignore: |
| 72 | +- `tslint` (replaced by ESLint) |
| 73 | +- `protractor` (replaced by Cypress, Playwright, or native Angular testing) |
| 74 | +- Various deprecated npm packages like `rimraf@2`, `glob@7` |
| 75 | + |
| 76 | +These come from transitive dependencies and don't affect your build or tests. |
| 77 | + |
0 commit comments