Skip to content

Commit bddc4cd

Browse files
authored
Angular 20 upgrade (#132)
* update typescript, angular-builders/jest and typescript-eslint packages * Update yarn lock file * Update @angular/core@20 @angular/cli@20 * Use field injections instead of constructor injections * Update peer dependencies * Update peer dependencies
1 parent 94f2be4 commit bddc4cd

11 files changed

Lines changed: 2937 additions & 1872 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ npm install angular-cc-library --save
3232
## Version Compatibility
3333

3434
| Angular | Library |
35-
| ------- | ------- |
35+
|---------|---------|
36+
| 20.x | 3.6.x |
3637
| 19.x | 3.5.x |
3738
| 18.x | 3.4.x |
3839
| 17.x | 3.3.x |

angular.json

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@
5959
"prefix": "app",
6060
"architect": {
6161
"build": {
62-
"builder": "@angular-devkit/build-angular:browser",
62+
"builder": "@angular-devkit/build-angular:application",
6363
"options": {
64-
"outputPath": "dist/example",
64+
"outputPath": {
65+
"base": "dist/example"
66+
},
6567
"index": "projects/example/src/index.html",
66-
"main": "projects/example/src/main.ts",
67-
"polyfills": "projects/example/src/polyfills.ts",
68+
"polyfills": [
69+
"projects/example/src/polyfills.ts"
70+
],
6871
"tsConfig": "projects/example/tsconfig.app.json",
6972
"assets": [
7073
"projects/example/src/favicon.ico",
@@ -74,12 +77,11 @@
7477
"projects/example/src/styles.css"
7578
],
7679
"scripts": [],
77-
"vendorChunk": true,
7880
"extractLicenses": false,
79-
"buildOptimizer": false,
8081
"sourceMap": true,
8182
"optimization": false,
82-
"namedChunks": true
83+
"namedChunks": true,
84+
"browser": "projects/example/src/main.ts"
8385
},
8486
"configurations": {
8587
"production": {
@@ -94,8 +96,6 @@
9496
"sourceMap": false,
9597
"namedChunks": false,
9698
"extractLicenses": true,
97-
"vendorChunk": false,
98-
"buildOptimizer": true,
9999
"budgets": [
100100
{
101101
"type": "initial",
@@ -152,5 +152,31 @@
152152
}
153153
}
154154
}
155+
},
156+
"schematics": {
157+
"@schematics/angular:component": {
158+
"type": "component"
159+
},
160+
"@schematics/angular:directive": {
161+
"type": "directive"
162+
},
163+
"@schematics/angular:service": {
164+
"type": "service"
165+
},
166+
"@schematics/angular:guard": {
167+
"typeSeparator": "."
168+
},
169+
"@schematics/angular:interceptor": {
170+
"typeSeparator": "."
171+
},
172+
"@schematics/angular:module": {
173+
"typeSeparator": "."
174+
},
175+
"@schematics/angular:pipe": {
176+
"typeSeparator": "."
177+
},
178+
"@schematics/angular:resolver": {
179+
"typeSeparator": "."
180+
}
155181
}
156182
}

package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,41 @@
1313
"prepare": "husky"
1414
},
1515
"dependencies": {
16-
"@angular/common": "^19.1.5",
17-
"@angular/compiler": "^19.1.5",
18-
"@angular/core": "^19.1.5",
19-
"@angular/forms": "^19.1.5",
20-
"@angular/platform-browser": "^19.1.5",
21-
"@angular/platform-browser-dynamic": "^19.1.5",
16+
"@angular/common": "^20.3.13",
17+
"@angular/compiler": "^20.3.13",
18+
"@angular/core": "^20.3.13",
19+
"@angular/forms": "^20.3.13",
20+
"@angular/platform-browser": "^20.3.13",
21+
"@angular/platform-browser-dynamic": "^20.3.13",
2222
"rxjs": "~7.8.1",
2323
"tslib": "^2.8.1",
2424
"zone.js": "~0.15.0"
2525
},
2626
"devDependencies": {
27-
"@angular-builders/jest": "19.0.0",
28-
"@angular-devkit/build-angular": "^19.1.6",
29-
"@angular-eslint/builder": "19.0.2",
30-
"@angular-eslint/eslint-plugin": "19.0.2",
31-
"@angular-eslint/eslint-plugin-template": "19.0.2",
32-
"@angular-eslint/schematics": "19.0.2",
33-
"@angular-eslint/template-parser": "19.0.2",
34-
"@angular/cli": "^19.1.6",
35-
"@angular/compiler-cli": "^19.1.5",
36-
"@angular/language-service": "^19.1.5",
27+
"@angular-builders/jest": "20.0.0",
28+
"@angular-devkit/build-angular": "^20.3.11",
29+
"@angular-eslint/builder": "20.6.0",
30+
"@angular-eslint/eslint-plugin": "20.6.0",
31+
"@angular-eslint/eslint-plugin-template": "20.6.0",
32+
"@angular-eslint/schematics": "20.6.0",
33+
"@angular-eslint/template-parser": "20.6.0",
34+
"@angular/cli": "^20.3.11",
35+
"@angular/compiler-cli": "^20.3.13",
36+
"@angular/language-service": "^20.3.13",
3737
"@release-it/bumper": "^6.0.1",
3838
"@release-it/conventional-changelog": "^8.0.2",
3939
"@types/jest": "^29.5.14",
4040
"@types/node": "^22.13.1",
41-
"@typescript-eslint/eslint-plugin": "8.23.0",
42-
"@typescript-eslint/parser": "8.23.0",
41+
"@typescript-eslint/eslint-plugin": "8.47.0",
42+
"@typescript-eslint/parser": "8.47.0",
4343
"eslint": "^8.57.1",
4444
"husky": "^9.1.7",
4545
"jest": "29.7.0",
4646
"lint-staged": "^15.4.3",
47-
"ng-packagr": "^19.1.2",
47+
"ng-packagr": "^20.3.2",
4848
"release-it": "^17.11.0",
4949
"ts-node": "~10.9.2",
50-
"typescript": "~5.7.3"
50+
"typescript": "~5.9.3"
5151
},
5252
"lint-staged": {
5353
"*.{ts,component.html}": [

projects/angular-cc-library/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"tslib": "^2.8.1"
2424
},
2525
"peerDependencies": {
26-
"@angular/common": "^19.1.4",
27-
"@angular/core": "^19.1.4"
26+
"@angular/common": "^19.0.0 || ^20.0.0",
27+
"@angular/core": "^19.0.0 || ^20.0.0"
2828
}
2929
}

projects/angular-cc-library/src/lib/credit-card.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class CreditCard {
176176

177177
try {
178178
cursor = target.selectionStart;
179-
} catch (error) {
179+
} catch {
180180
// do nothing
181181
}
182182

projects/angular-cc-library/src/lib/directives/credit-card-format.directive.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Directive, ElementRef, HostListener, Optional, Self } from '@angular/core';
1+
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
22
import { CreditCard } from '../credit-card';
33
import { NgControl } from '@angular/forms';
44
import { BehaviorSubject } from 'rxjs';
@@ -9,18 +9,13 @@ import { BehaviorSubject } from 'rxjs';
99
standalone: true,
1010
})
1111
export class CreditCardFormatDirective {
12-
private target: HTMLInputElement;
12+
private el = inject(ElementRef);
13+
private target: HTMLInputElement = this.el.nativeElement;
14+
private control = inject(NgControl, { optional: true, self: true });
1315
private cards = CreditCard.cards();
1416

1517
public resolvedScheme$ = new BehaviorSubject<string>('unknown');
1618

17-
constructor(
18-
private el: ElementRef,
19-
@Self() @Optional() private control: NgControl,
20-
) {
21-
this.target = this.el.nativeElement;
22-
}
23-
2419
/**
2520
* Updates the value to target element, or FormControl if exists.
2621
* @param value New input value.

projects/angular-cc-library/src/lib/directives/cvc-format.directive.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Directive, ElementRef, HostListener, Optional, Self } from '@angular/core';
1+
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
22
import { CreditCard } from '../credit-card';
33
import { NgControl } from '@angular/forms';
44

@@ -7,14 +7,9 @@ import { NgControl } from '@angular/forms';
77
standalone: true,
88
})
99
export class CvcFormatDirective {
10-
private target: HTMLInputElement;
11-
12-
constructor(
13-
private el: ElementRef,
14-
@Self() @Optional() private control: NgControl,
15-
) {
16-
this.target = this.el.nativeElement;
17-
}
10+
private el = inject(ElementRef);
11+
private target: HTMLInputElement = this.el.nativeElement;
12+
private control = inject(NgControl, { optional: true, self: true });
1813

1914
/**
2015
* Updates the value to target element, or FormControl if exists.

projects/angular-cc-library/src/lib/directives/expiry-format.directive.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Directive, ElementRef, HostListener, Optional, Self } from '@angular/core';
1+
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
22
import { CreditCard } from '../credit-card';
33
import { NgControl } from '@angular/forms';
44

@@ -7,14 +7,9 @@ import { NgControl } from '@angular/forms';
77
standalone: true,
88
})
99
export class ExpiryFormatDirective {
10-
private target: HTMLInputElement;
11-
12-
constructor(
13-
private el: ElementRef,
14-
@Self() @Optional() private control: NgControl,
15-
) {
16-
this.target = this.el.nativeElement;
17-
}
10+
private el = inject(ElementRef);
11+
private target: HTMLInputElement = this.el.nativeElement;
12+
private control = inject(NgControl, { optional: true, self: true });
1813

1914
/**
2015
* Updates the value to target element, or FormControl if exists.

projects/example/src/app/app.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AsyncPipe } from '@angular/common';
2-
import { Component } from '@angular/core';
2+
import { Component, inject } from '@angular/core';
33
import { Validators, FormGroup, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
44
import { CreditCardValidators, CreditCard, CreditCardDirectivesModule } from 'angular-cc-library';
55
import { defer } from 'rxjs';
@@ -11,6 +11,8 @@ import { map } from 'rxjs/operators';
1111
imports: [FormsModule, ReactiveFormsModule, AsyncPipe, CreditCardDirectivesModule]
1212
})
1313
export class AppComponent {
14+
private fb = inject(FormBuilder);
15+
1416
public demoForm = this.fb.group({
1517
creditCard: ['', [CreditCardValidators.validateCCNumber]],
1618
expDate: ['', [CreditCardValidators.validateExpDate]],
@@ -22,8 +24,6 @@ export class AppComponent {
2224
public type$ = defer(() => this.demoForm.get('creditCard').valueChanges)
2325
.pipe(map((num: string) => CreditCard.cardType(num)));
2426

25-
constructor(private fb: FormBuilder) {}
26-
2727
public goToNextField(controlName: string, nextField: HTMLInputElement) {
2828
if (this.demoForm.get(controlName)?.valid) {
2929
nextField.focus();

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"baseUrl": "./",
55
"outDir": "./dist/out-tsc",
66
"noImplicitAny": true,
7+
"esModuleInterop": true,
78
"noImplicitReturns": false,
89
"noImplicitThis": true,
910
"noUnusedParameters": true,
@@ -12,10 +13,9 @@
1213
"strictNullChecks": false,
1314
"sourceMap": true,
1415
"declaration": false,
15-
"downlevelIteration": true,
1616
"experimentalDecorators": true,
1717
"module": "es2020",
18-
"moduleResolution": "node",
18+
"moduleResolution": "bundler",
1919
"importHelpers": true,
2020
"target": "ES2022",
2121
"lib": [

0 commit comments

Comments
 (0)