Skip to content

Commit e3949d6

Browse files
authored
Merge pull request #165 from undsoft/master
feat: upgrade to Angular 14
2 parents a398ab3 + 9677e32 commit e3949d6

File tree

9 files changed

+33273
-5224
lines changed

9 files changed

+33273
-5224
lines changed

libs/reactive-forms/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"homepage": "https://github.com/ngneat/reactive-forms#readme",
2828
"peerDependencies": {
29-
"@angular/forms": ">= 13.0.0"
29+
"@angular/forms": ">= 14.0.0"
3030
},
3131
"repository": {
3232
"type": "git",

libs/reactive-forms/src/lib/form-array.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
AbstractControl,
3-
FormArray as NgFormArray,
3+
UntypedFormArray,
44
ValidationErrors,
55
} from '@angular/forms';
66
import { isObservable, Observable, Subject, Subscription } from 'rxjs';
@@ -26,7 +26,7 @@ export class FormArray<
2626
Control extends AbstractControl = T extends Record<any, any>
2727
? FormGroup<ControlsOf<T>>
2828
: FormControl<T>
29-
> extends NgFormArray {
29+
> extends UntypedFormArray {
3030
readonly value!: T[];
3131
readonly valueChanges!: Observable<T[]>;
3232

@@ -53,8 +53,8 @@ export class FormArray<
5353

5454
constructor(
5555
public controls: Array<Control>,
56-
validatorOrOpts?: ConstructorParameters<typeof NgFormArray>[1],
57-
asyncValidator?: ConstructorParameters<typeof NgFormArray>[2]
56+
validatorOrOpts?: ConstructorParameters<typeof UntypedFormArray>[1],
57+
asyncValidator?: ConstructorParameters<typeof UntypedFormArray>[2]
5858
) {
5959
super(controls, validatorOrOpts, asyncValidator);
6060
}

libs/reactive-forms/src/lib/form-builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Injectable } from "@angular/core";
2-
import { AbstractControl, AbstractControlOptions, AsyncValidatorFn, FormBuilder as NgFormBuilder, ValidatorFn } from '@angular/forms';
2+
import { AbstractControl, AbstractControlOptions, AsyncValidatorFn, UntypedFormBuilder, ValidatorFn } from '@angular/forms';
33
import { FormControl, FormGroup } from "..";
44
import { FormArray } from "./form-array";
55
import { BoxedValue, ControlsOf } from "./types";
66

77
@Injectable({ providedIn: 'root' })
8-
export class FormBuilder extends NgFormBuilder {
8+
export class FormBuilder extends UntypedFormBuilder {
99

1010
control<T>(
1111
formState?: BoxedValue<T>,

libs/reactive-forms/src/lib/form-control.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
FormControl as NgFormControl,
2+
UntypedFormControl,
33
AbstractControl,
44
ValidationErrors,
55
} from '@angular/forms';
@@ -19,7 +19,7 @@ import {
1919
} from './core';
2020
import { BoxedValue } from './types';
2121

22-
export class FormControl<T> extends NgFormControl {
22+
export class FormControl<T> extends UntypedFormControl {
2323
readonly value!: T;
2424
readonly valueChanges!: Observable<T>;
2525

@@ -46,8 +46,8 @@ export class FormControl<T> extends NgFormControl {
4646

4747
constructor(
4848
formState?: BoxedValue<T>,
49-
validatorOrOpts?: ConstructorParameters<typeof NgFormControl>[1],
50-
asyncValidator?: ConstructorParameters<typeof NgFormControl>[2]
49+
validatorOrOpts?: ConstructorParameters<typeof UntypedFormControl>[1],
50+
asyncValidator?: ConstructorParameters<typeof UntypedFormControl>[2]
5151
) {
5252
super(formState, validatorOrOpts, asyncValidator);
5353
}

libs/reactive-forms/src/lib/form-group.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
AbstractControl,
3-
FormGroup as NgFormGroup,
3+
UntypedFormGroup,
44
ValidationErrors,
55
} from '@angular/forms';
66
import { isObservable, Observable, Subject, Subscription } from 'rxjs';
@@ -21,7 +21,7 @@ import {
2121
} from './core';
2222
import { DeepPartial, ValuesOf } from './types';
2323

24-
export class FormGroup<T extends Record<string, any>> extends NgFormGroup {
24+
export class FormGroup<T extends Record<string, any>> extends UntypedFormGroup {
2525
readonly value!: ValuesOf<T>;
2626
readonly valueChanges!: Observable<ValuesOf<T>>;
2727

@@ -48,8 +48,8 @@ export class FormGroup<T extends Record<string, any>> extends NgFormGroup {
4848

4949
constructor(
5050
public controls: T,
51-
validatorOrOpts?: ConstructorParameters<typeof NgFormGroup>[1],
52-
asyncValidator?: ConstructorParameters<typeof NgFormGroup>[2]
51+
validatorOrOpts?: ConstructorParameters<typeof UntypedFormGroup>[1],
52+
asyncValidator?: ConstructorParameters<typeof UntypedFormGroup>[2]
5353
) {
5454
super(controls, validatorOrOpts, asyncValidator);
5555
}

libs/reactive-forms/src/lib/persist/persist.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { AbstractControl, FormArray } from "@angular/forms";
2+
import { AbstractControl, UntypedFormArray } from "@angular/forms";
33
import { from, isObservable, Observable, of } from "rxjs";
44
import { debounceTime, switchMap, take, tap } from "rxjs/operators";
55

@@ -64,19 +64,19 @@ function handleFormArrays<T>(
6464
Object.keys(formValue).forEach(controlName => {
6565
const value = (formValue as any)[controlName];
6666

67-
if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
67+
if (Array.isArray(value) && control.get(controlName) instanceof UntypedFormArray) {
6868
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
6969
throw new Error(`Please provide arrControlFactory for ${controlName}`);
7070
}
71-
const current = control.get(controlName) as FormArray;
71+
const current = control.get(controlName) as UntypedFormArray;
7272
const fc = (arrControlFactory as any)[controlName]
7373
clearFormArray(current);
7474
value.forEach((v, i) => current.insert(i, fc(v)));
7575
}
7676
});
7777
}
7878

79-
export function clearFormArray(control: FormArray) {
79+
export function clearFormArray(control: UntypedFormArray) {
8080
while (control.length !== 0) {
8181
control.removeAt(0);
8282
}

migrations.json

Lines changed: 13 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,25 @@
11
{
22
"migrations": [
33
{
4-
"version": "13.0.0-beta.1",
5-
"description": "Add default base to nx.json if its not currently set",
6-
"factory": "./src/migrations/update-13-0-0/set-default-base-if-not-set",
7-
"cli": "nx",
8-
"package": "@nrwl/workspace",
9-
"name": "set-default-base-if-not-set"
10-
},
11-
{
12-
"version": "13.0.0-beta.4",
13-
"description": "Move global settings into nx.json, and project specific settings into workspace.json",
14-
"cli": "nx",
15-
"implementation": "./src/migrations/update-13-0-0/config-locations/config-locations",
16-
"package": "@nrwl/workspace",
17-
"name": "13-0-0-config-locations"
18-
},
19-
{
20-
"version": "13.2.0",
21-
"description": "Set --parallel=1 for existing repos to preserve the existing behavior",
22-
"cli": "nx",
23-
"implementation": "./src/migrations/update-13-2-0/set-parallel-default",
24-
"package": "@nrwl/workspace",
25-
"name": "set-parallel-default"
26-
},
27-
{
28-
"cli": "nx",
29-
"version": "13.0.0-beta.10",
30-
"description": "Adds postcss packages needed for Tailwind support if ng-packagr is already installed.",
31-
"factory": "./src/migrations/update-13-0-0/add-postcss-packages",
32-
"package": "@nrwl/angular",
33-
"name": "add-postcss-packages"
34-
},
35-
{
36-
"cli": "nx",
37-
"version": "13.2.0-beta.1",
38-
"description": "Remove deprecated options from webpack-server and webpack-browser.",
39-
"factory": "./src/migrations/update-13-2-0/update-angular-config",
40-
"package": "@nrwl/angular",
41-
"name": "update-angular-config"
42-
},
43-
{
44-
"cli": "nx",
45-
"version": "13.2.0-beta.1",
46-
"description": "Remove enableIvy and add compilationMode to library tsconfig and remove deprecated ng-packagr options.",
47-
"factory": "./src/migrations/update-13-2-0/update-libraries",
48-
"package": "@nrwl/angular",
49-
"name": "update-libraries"
50-
},
51-
{
52-
"cli": "nx",
53-
"version": "13.2.0-beta.1",
54-
"description": "Update jest config to support jest-preset-angular",
55-
"factory": "./src/migrations/update-13-2-0/update-angular-jest-config",
56-
"package": "@nrwl/angular",
57-
"name": "update-angular-jest-config"
58-
},
59-
{
60-
"cli": "nx",
61-
"version": "13.2.0-beta.1",
62-
"description": "Move some imports from @nrwl/angular/testing to jasmine-marbles",
63-
"factory": "./src/migrations/update-13-2-0/update-testing-imports",
64-
"package": "@nrwl/angular",
65-
"name": "update-testing-imports"
66-
},
67-
{
68-
"version": "13.0.0",
69-
"factory": "./update-13/schematic-options",
70-
"description": "Remove no longer valid Angular schematic options from `angular.json`.",
71-
"package": "@angular/cli",
72-
"name": "schematic-options-13"
73-
},
74-
{
75-
"version": "13.0.0",
76-
"factory": "./update-13/update-angular-config",
77-
"description": "Remove deprecated options from 'angular.json' that are no longer present in v13.",
78-
"package": "@angular/cli",
79-
"name": "update-angular-config-v13"
80-
},
81-
{
82-
"version": "13.0.0",
83-
"factory": "./update-13/update-libraries",
84-
"description": "Update library projects to be published in partial mode and removed deprecated options from ng-packagr configuration.",
85-
"package": "@angular/cli",
86-
"name": "update-libraries-v13"
87-
},
88-
{
89-
"version": "13.0.0",
90-
"factory": "./update-13/drop-ie-polyfills",
91-
"description": "Remove polyfills required only for Internet Explorer which is no longer supported.",
92-
"package": "@angular/cli",
93-
"name": "drop-ie-polyfills"
94-
},
95-
{
96-
"version": "13.0.0",
97-
"factory": "./update-13/update-gitignore",
98-
"description": "Updating '.gitignore' to include '.angular/cache'.",
99-
"package": "@angular/cli",
100-
"name": "update-gitignore"
101-
},
102-
{
103-
"version": "13.0.0-beta",
104-
"description": "Migrates `[routerLink]=\"\"` in templates to `[routerLink]=\"[]\"` because these links are likely intended to route to the current page with updated fragment/query params.",
105-
"factory": "./migrations/router-link-empty-expression/index",
4+
"version": "14.0.0-beta",
5+
"description": "As of Angular version 13, `entryComponents` are no longer necessary.",
6+
"factory": "./migrations/entry-components/index",
1067
"package": "@angular/core",
107-
"name": "migration-v13-router-link-empty-expression"
8+
"name": "migration-entry-components"
1089
},
10910
{
110-
"version": "13.0.0-beta",
111-
"description": "In Angular version 13, the `teardown` flag in `TestBed` will be enabled by default. This migration automatically opts out existing apps from the new teardown behavior.",
112-
"factory": "./migrations/testbed-teardown/index",
11+
"version": "14.0.0-beta",
12+
"description": "As of Angular version 14, Forms model classes accept a type parameter, and existing usages must be opted out to preserve backwards-compatibility.",
13+
"factory": "./migrations/typed-forms/index",
11314
"package": "@angular/core",
114-
"name": "migration-v13-testbed-teardown"
15+
"name": "migration-v14-typed-forms"
11516
},
11617
{
117-
"version": "13.1.2-beta.0",
118-
"cli": "nx",
119-
"description": "Support .test. file names in tsconfigs",
120-
"factory": "./src/migrations/update-13-1-2/update-tsconfigs-for-tests",
121-
"package": "@nrwl/jest",
122-
"name": "update-ts-config-for-test-filenames"
18+
"version": "14.0.0-beta",
19+
"description": "In Angular version 14, the `pathMatch` property of `Routes` was updated to be a strict union of the two valid options: `'full'|'prefix'`. `Routes` and `Route` variables need an explicit type so TypeScript does not infer the property as the looser `string`.",
20+
"factory": "./migrations/path-match-type/index",
21+
"package": "@angular/core",
22+
"name": "migration-v14-path-match-type"
12323
}
12424
]
12525
}

0 commit comments

Comments
 (0)