Gathering detailed insights and metrics for @afa-ag/ngx-strongly-typed-forms
Gathering detailed insights and metrics for @afa-ag/ngx-strongly-typed-forms
Gathering detailed insights and metrics for @afa-ag/ngx-strongly-typed-forms
Gathering detailed insights and metrics for @afa-ag/ngx-strongly-typed-forms
Strongly typed definitions for Anglulars `@angular/forms`
npm install @afa-ag/ngx-strongly-typed-forms
Typescript
Module System
Node Version
NPM Version
TypeScript (85.89%)
JavaScript (14.11%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
118 Commits
4 Branches
1 Contributors
Updated on May 02, 2024
Latest Version
13.0.2
Package Id
@afa-ag/ngx-strongly-typed-forms@13.0.2
Unpacked Size
47.42 kB
Size
10.41 kB
File Count
10
NPM Version
8.4.1
Node Version
16.14.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
This is a one off fork of no0x9d/ngx-strongly-typed-forms to add support for Angular 11.
1npm install @mjpenza/ngx-strongly-typed-forms
Attention: Since version 7.2 this project does no longer follow semver version numbers. The major and minor version represents the compatible Angular version and patch versions are bugfixes in this library.
Now you can import generic FormControl, FormGroup and FormArray and use them instead of the classes from @angular/forms
1import {FormArray, FormControl, FormGroup} from 'ngx-strongly-typed-forms';
If you want to use the FormBuilder you have to provide it from your app module
1import { ReactiveFormsModule } from '@angular/forms'; 2import { NgxStronglyTypedFormsModule } from 'ngx-strongly-typed-forms'; 3 4@NgModule({ 5 imports: [ ReactiveFormsModule, NgxStronglyTypedFormsModule ] 6}) 7export class AppModule { 8}
All usages of AbstractControl
and its subclasses now supports generic types.
This change is not backwards compatible with Angular's AbstractControl. All occurrence at minimum must be typed with AbstractControl<any>
, or at best with an interface which describes all form fields.
This project does not modify any angular classes but provides new strongly typed definitions for Angular's own forms. For convenience it re-exports these classes directly from Angular.
1form = fb.group<MyModel>({ 2 foo: null, 3 bar: ["bar", Validators.required], 4 baz: fb.array<Baz>([]) 5})
FormArray<T>
extends AbstractControl<T[]>
. So if you have a FormArray<string>
you can assign it to an AbstractControl<string[]>
. This is necessary, because for instance FormArray.get
returns a single instance of type T
but FormArray.value
returns T[]
.
It's also important when working with FormArrays as part of complex FormGroups. The generic type of the FormArray must always be the same as the generic of the Array in the model.Beside the known limitations, everything that is possible with the native Angular Forms should be possible too.
If you find something not working as expected then there might be a problem in my type definitions. Please open an issue with an minimal example to reproduce the problem and I will try to fix it asap.
DeepPartial<T>
.TypeScript 2.8 supports conditional types to build this structure like
1type DeepPartial<T> = { 2 [P in keyof T]?: T[P] extends Array<infer U> 3 ? Array<DeepPartial<U>> 4 : T[P] extends ReadonlyArray<infer U> 5 ? ReadonlyArray<DeepPartial<U>> 6 : DeepPartial<T[P]> 7};
When Angular uses TypeScript 2.8 the return value should be changed.
AbstractControl#get(path: string|number [])
is impossible to statically type, because every subclass has a different implementation.
FormControl always return null, FormGroup only works with string keys and FormArray only with a numerical index. Because I never needed a deeply nested access with both number and string, only string key up to a depth of 5 levels are currently supported. If this is not sufficient for you, please open an issue and explain your situation.AbstractControl<any>
or an interface with all possible fields set as optional.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is archived
Details
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More