Skip to content

Commit

Permalink
fix(lib): data input decorator has a type error when used with an array
Browse files Browse the repository at this point in the history
This closes #83
  • Loading branch information
maxime1992 committed Aug 13, 2019
1 parent 96fa4e8 commit b424cdf
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 b424cdf

Please sign in to comment.