Skip to content

Commit

Permalink
Merge pull request #87 from cloudnc/fix/data-input-decorator-type
Browse files Browse the repository at this point in the history
fix(lib): data input decorator has a type error when used with an array
  • Loading branch information
maxime1992 authored Aug 13, 2019
2 parents 96fa4e8 + b424cdf commit 6ecdb20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions projects/ngx-sub-form/src/lib/ngx-sub-form.decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ export class DataInputUsedOnWrongPropertyError extends Error {
}

export function DataInput() {
return function(target: NgxRootFormComponent<any, any>, propertyKey: string) {
return function<ControlInterface, FormInterface = ControlInterface>(
target: NgxRootFormComponent<ControlInterface, FormInterface>,
propertyKey: string,
) {
if (propertyKey !== 'dataInput') {
throw new DataInputUsedOnWrongPropertyError(propertyKey);
}

Object.defineProperty(target, propertyKey, {
set: function(dataInputValue) {
(this as NgxRootFormComponent<any, any>).dataInputUpdated(dataInputValue);
(this as NgxRootFormComponent<ControlInterface, FormInterface>).dataInputUpdated(dataInputValue);
},
});
};
Expand Down

0 comments on commit 6ecdb20

Please sign in to comment.