Skip to content

Commit 6dd0b2d

Browse files
author
Scarrier
committed
Fix definition for IFieldGroup, add IFieldArray as convenience type for formly-form fields property, update tests
1 parent bdaf2f0 commit 6dd0b2d

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

angular-formly/angular-formly-tests.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FormConfig {
2424
}
2525

2626
class AppController {
27-
fields: AngularFormly.IFieldConfigurationObject[];
27+
fields: AngularFormly.IFieldArray;
2828
constructor() {
2929
var vm = this;
3030
vm.fields = [
@@ -99,6 +99,21 @@ class AppController {
9999
templateOptions: {
100100
label: 'no wrapper here...'
101101
}
102+
},
103+
{
104+
//From http://angular-formly.com/#/example/other/nested-formly-forms
105+
key: 'address',
106+
wrapper: 'panel',
107+
templateOptions: { label: 'Address' },
108+
fieldGroup: [{
109+
key: 'town',
110+
type: 'input',
111+
templateOptions: {
112+
required: true,
113+
type: 'text',
114+
label: 'Town'
115+
}
116+
}]
102117
}
103118
]
104119
}

angular-formly/angular-formly.d.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Type definitions for angular-formly 6.18.0
1+
// Type definitions for angular-formly 7.2.3
22
// Project: https://github.com/formly-js/angular-formly
33
// Definitions by: Scott Hatcher <https://github.com/scatcher>
4-
// Definitions: https://github.com/borisyankov/DefinitelyTyped
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
55

66
/// <reference path="../angularjs/angular.d.ts" />
77

@@ -16,18 +16,23 @@ declare module 'angular-formly' {
1616

1717
declare module AngularFormly {
1818

19+
interface IFieldArray extends Array<IFieldConfigurationObject|IFieldGroup> {
20+
21+
}
1922

2023
interface IFieldGroup {
2124
data?: Object;
2225
className?: string;
23-
elementAttributes?: { [key: string]: string };
24-
fieldGroup: IFieldConfigurationObject[];
26+
elementAttributes?: string;
27+
fieldGroup: IFieldArray;
2528
form?: Object;
2629
hide?: boolean;
27-
hideExpression?: string | IExpresssionFunction;
30+
hideExpression?: string | IExpressionFunction;
2831
key?: string | number;
2932
model?: string | Object;
30-
options?: IFormOptionsAPI
33+
options?: IFormOptionsAPI;
34+
templateOptions?: ITemplateOptions;
35+
wrapper?: string | string[];
3136
}
3237

3338

@@ -46,7 +51,7 @@ declare module AngularFormly {
4651
/**
4752
* see http://docs.angular-formly.com/docs/formly-expressions#expressionproperties-validators--messages
4853
*/
49-
interface IExpresssionFunction {
54+
interface IExpressionFunction {
5055
($viewValue: any, $modelValue: any, scope: ITemplateScope): any;
5156
}
5257

@@ -122,8 +127,8 @@ declare module AngularFormly {
122127
* see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
123128
*/
124129
interface IValidator {
125-
expression: string | IExpresssionFunction;
126-
message?: string | IExpresssionFunction;
130+
expression: string | IExpressionFunction;
131+
message?: string | IExpressionFunction;
127132
}
128133

129134

@@ -154,7 +159,7 @@ declare module AngularFormly {
154159
* see http://angular-formly.com/#/example/other/unique-value-async-validation
155160
*/
156161
asyncValidators?: {
157-
[key: string]: string | IExpresssionFunction | IValidator;
162+
[key: string]: string | IExpressionFunction | IValidator;
158163
}
159164

160165
/**
@@ -204,7 +209,7 @@ declare module AngularFormly {
204209
* see http://docs.angular-formly.com/docs/field-configuration-object#expressionproperties-object
205210
*/
206211
expressionProperties?: {
207-
[key: string]: string | IExpresssionFunction | IValidator;
212+
[key: string]: string | IExpressionFunction | IValidator;
208213
}
209214

210215

@@ -224,7 +229,7 @@ declare module AngularFormly {
224229
*
225230
* see http://docs.angular-formly.com/docs/field-configuration-object#hideexpression-string--function
226231
*/
227-
hideExpression?: string | IExpresssionFunction;
232+
hideExpression?: string | IExpressionFunction;
228233

229234

230235
/**
@@ -416,7 +421,7 @@ declare module AngularFormly {
416421
* like in this example.
417422
*/
418423
messages?: {
419-
[key: string]: IExpresssionFunction | string;
424+
[key: string]: IExpressionFunction | string;
420425
}
421426

422427

@@ -440,7 +445,7 @@ declare module AngularFormly {
440445
* see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
441446
*/
442447
validators?: {
443-
[key: string]: string | IExpresssionFunction | IValidator;
448+
[key: string]: string | IExpressionFunction | IValidator;
444449
}
445450

446451

@@ -573,7 +578,7 @@ declare module AngularFormly {
573578
//Shortcut to options.formControl
574579
fc: ng.IFormController | ng.IFormController[];
575580
//all the fields for the form
576-
fields: IFieldConfigurationObject[];
581+
fields: IFieldArray;
577582
//the form controller the field is in
578583
form: any;
579584
//The object passed as options.formState to the formly-form directive. Use this to share state between fields.

0 commit comments

Comments
 (0)