Skip to content

Commit

Permalink
Merge pull request #165 from undsoft/master
Browse files Browse the repository at this point in the history
feat: upgrade to Angular 14
  • Loading branch information
NetanelBasal committed Jun 10, 2022
2 parents a398ab3 + 9677e32 commit e3949d6
Show file tree
Hide file tree
Showing 9 changed files with 33,273 additions and 5,224 deletions.
2 changes: 1 addition & 1 deletion libs/reactive-forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/ngneat/reactive-forms#readme",
"peerDependencies": {
"@angular/forms": ">= 13.0.0"
"@angular/forms": ">= 14.0.0"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions libs/reactive-forms/src/lib/form-array.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
AbstractControl,
FormArray as NgFormArray,
UntypedFormArray,
ValidationErrors,
} from '@angular/forms';
import { isObservable, Observable, Subject, Subscription } from 'rxjs';
Expand All @@ -26,7 +26,7 @@ export class FormArray<
Control extends AbstractControl = T extends Record<any, any>
? FormGroup<ControlsOf<T>>
: FormControl<T>
> extends NgFormArray {
> extends UntypedFormArray {
readonly value!: T[];
readonly valueChanges!: Observable<T[]>;

Expand All @@ -53,8 +53,8 @@ export class FormArray<

constructor(
public controls: Array<Control>,
validatorOrOpts?: ConstructorParameters<typeof NgFormArray>[1],
asyncValidator?: ConstructorParameters<typeof NgFormArray>[2]
validatorOrOpts?: ConstructorParameters<typeof UntypedFormArray>[1],
asyncValidator?: ConstructorParameters<typeof UntypedFormArray>[2]
) {
super(controls, validatorOrOpts, asyncValidator);
}
Expand Down
4 changes: 2 additions & 2 deletions libs/reactive-forms/src/lib/form-builder.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from "@angular/core";
import { AbstractControl, AbstractControlOptions, AsyncValidatorFn, FormBuilder as NgFormBuilder, ValidatorFn } from '@angular/forms';
import { AbstractControl, AbstractControlOptions, AsyncValidatorFn, UntypedFormBuilder, ValidatorFn } from '@angular/forms';
import { FormControl, FormGroup } from "..";
import { FormArray } from "./form-array";
import { BoxedValue, ControlsOf } from "./types";

@Injectable({ providedIn: 'root' })
export class FormBuilder extends NgFormBuilder {
export class FormBuilder extends UntypedFormBuilder {

control<T>(
formState?: BoxedValue<T>,
Expand Down
8 changes: 4 additions & 4 deletions libs/reactive-forms/src/lib/form-control.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
FormControl as NgFormControl,
UntypedFormControl,
AbstractControl,
ValidationErrors,
} from '@angular/forms';
Expand All @@ -19,7 +19,7 @@ import {
} from './core';
import { BoxedValue } from './types';

export class FormControl<T> extends NgFormControl {
export class FormControl<T> extends UntypedFormControl {
readonly value!: T;
readonly valueChanges!: Observable<T>;

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

constructor(
formState?: BoxedValue<T>,
validatorOrOpts?: ConstructorParameters<typeof NgFormControl>[1],
asyncValidator?: ConstructorParameters<typeof NgFormControl>[2]
validatorOrOpts?: ConstructorParameters<typeof UntypedFormControl>[1],
asyncValidator?: ConstructorParameters<typeof UntypedFormControl>[2]
) {
super(formState, validatorOrOpts, asyncValidator);
}
Expand Down
8 changes: 4 additions & 4 deletions libs/reactive-forms/src/lib/form-group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
AbstractControl,
FormGroup as NgFormGroup,
UntypedFormGroup,
ValidationErrors,
} from '@angular/forms';
import { isObservable, Observable, Subject, Subscription } from 'rxjs';
Expand All @@ -21,7 +21,7 @@ import {
} from './core';
import { DeepPartial, ValuesOf } from './types';

export class FormGroup<T extends Record<string, any>> extends NgFormGroup {
export class FormGroup<T extends Record<string, any>> extends UntypedFormGroup {
readonly value!: ValuesOf<T>;
readonly valueChanges!: Observable<ValuesOf<T>>;

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

constructor(
public controls: T,
validatorOrOpts?: ConstructorParameters<typeof NgFormGroup>[1],
asyncValidator?: ConstructorParameters<typeof NgFormGroup>[2]
validatorOrOpts?: ConstructorParameters<typeof UntypedFormGroup>[1],
asyncValidator?: ConstructorParameters<typeof UntypedFormGroup>[2]
) {
super(controls, validatorOrOpts, asyncValidator);
}
Expand Down
8 changes: 4 additions & 4 deletions libs/reactive-forms/src/lib/persist/persist.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { AbstractControl, FormArray } from "@angular/forms";
import { AbstractControl, UntypedFormArray } from "@angular/forms";
import { from, isObservable, Observable, of } from "rxjs";
import { debounceTime, switchMap, take, tap } from "rxjs/operators";

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

if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
if (Array.isArray(value) && control.get(controlName) instanceof UntypedFormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error(`Please provide arrControlFactory for ${controlName}`);
}
const current = control.get(controlName) as FormArray;
const current = control.get(controlName) as UntypedFormArray;
const fc = (arrControlFactory as any)[controlName]
clearFormArray(current);
value.forEach((v, i) => current.insert(i, fc(v)));
}
});
}

export function clearFormArray(control: FormArray) {
export function clearFormArray(control: UntypedFormArray) {
while (control.length !== 0) {
control.removeAt(0);
}
Expand Down
126 changes: 13 additions & 113 deletions migrations.json
Original file line number Diff line number Diff line change
@@ -1,125 +1,25 @@
{
"migrations": [
{
"version": "13.0.0-beta.1",
"description": "Add default base to nx.json if its not currently set",
"factory": "./src/migrations/update-13-0-0/set-default-base-if-not-set",
"cli": "nx",
"package": "@nrwl/workspace",
"name": "set-default-base-if-not-set"
},
{
"version": "13.0.0-beta.4",
"description": "Move global settings into nx.json, and project specific settings into workspace.json",
"cli": "nx",
"implementation": "./src/migrations/update-13-0-0/config-locations/config-locations",
"package": "@nrwl/workspace",
"name": "13-0-0-config-locations"
},
{
"version": "13.2.0",
"description": "Set --parallel=1 for existing repos to preserve the existing behavior",
"cli": "nx",
"implementation": "./src/migrations/update-13-2-0/set-parallel-default",
"package": "@nrwl/workspace",
"name": "set-parallel-default"
},
{
"cli": "nx",
"version": "13.0.0-beta.10",
"description": "Adds postcss packages needed for Tailwind support if ng-packagr is already installed.",
"factory": "./src/migrations/update-13-0-0/add-postcss-packages",
"package": "@nrwl/angular",
"name": "add-postcss-packages"
},
{
"cli": "nx",
"version": "13.2.0-beta.1",
"description": "Remove deprecated options from webpack-server and webpack-browser.",
"factory": "./src/migrations/update-13-2-0/update-angular-config",
"package": "@nrwl/angular",
"name": "update-angular-config"
},
{
"cli": "nx",
"version": "13.2.0-beta.1",
"description": "Remove enableIvy and add compilationMode to library tsconfig and remove deprecated ng-packagr options.",
"factory": "./src/migrations/update-13-2-0/update-libraries",
"package": "@nrwl/angular",
"name": "update-libraries"
},
{
"cli": "nx",
"version": "13.2.0-beta.1",
"description": "Update jest config to support jest-preset-angular",
"factory": "./src/migrations/update-13-2-0/update-angular-jest-config",
"package": "@nrwl/angular",
"name": "update-angular-jest-config"
},
{
"cli": "nx",
"version": "13.2.0-beta.1",
"description": "Move some imports from @nrwl/angular/testing to jasmine-marbles",
"factory": "./src/migrations/update-13-2-0/update-testing-imports",
"package": "@nrwl/angular",
"name": "update-testing-imports"
},
{
"version": "13.0.0",
"factory": "./update-13/schematic-options",
"description": "Remove no longer valid Angular schematic options from `angular.json`.",
"package": "@angular/cli",
"name": "schematic-options-13"
},
{
"version": "13.0.0",
"factory": "./update-13/update-angular-config",
"description": "Remove deprecated options from 'angular.json' that are no longer present in v13.",
"package": "@angular/cli",
"name": "update-angular-config-v13"
},
{
"version": "13.0.0",
"factory": "./update-13/update-libraries",
"description": "Update library projects to be published in partial mode and removed deprecated options from ng-packagr configuration.",
"package": "@angular/cli",
"name": "update-libraries-v13"
},
{
"version": "13.0.0",
"factory": "./update-13/drop-ie-polyfills",
"description": "Remove polyfills required only for Internet Explorer which is no longer supported.",
"package": "@angular/cli",
"name": "drop-ie-polyfills"
},
{
"version": "13.0.0",
"factory": "./update-13/update-gitignore",
"description": "Updating '.gitignore' to include '.angular/cache'.",
"package": "@angular/cli",
"name": "update-gitignore"
},
{
"version": "13.0.0-beta",
"description": "Migrates `[routerLink]=\"\"` in templates to `[routerLink]=\"[]\"` because these links are likely intended to route to the current page with updated fragment/query params.",
"factory": "./migrations/router-link-empty-expression/index",
"version": "14.0.0-beta",
"description": "As of Angular version 13, `entryComponents` are no longer necessary.",
"factory": "./migrations/entry-components/index",
"package": "@angular/core",
"name": "migration-v13-router-link-empty-expression"
"name": "migration-entry-components"
},
{
"version": "13.0.0-beta",
"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.",
"factory": "./migrations/testbed-teardown/index",
"version": "14.0.0-beta",
"description": "As of Angular version 14, Forms model classes accept a type parameter, and existing usages must be opted out to preserve backwards-compatibility.",
"factory": "./migrations/typed-forms/index",
"package": "@angular/core",
"name": "migration-v13-testbed-teardown"
"name": "migration-v14-typed-forms"
},
{
"version": "13.1.2-beta.0",
"cli": "nx",
"description": "Support .test. file names in tsconfigs",
"factory": "./src/migrations/update-13-1-2/update-tsconfigs-for-tests",
"package": "@nrwl/jest",
"name": "update-ts-config-for-test-filenames"
"version": "14.0.0-beta",
"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`.",
"factory": "./migrations/path-match-type/index",
"package": "@angular/core",
"name": "migration-v14-path-match-type"
}
]
}

0 comments on commit e3949d6

Please sign in to comment.