});
test('input line', () => {
+ interface Input {
+ key: string;
+ key2?: string;
+ }
class TestForm extends Form {
get name() { return 'F1'; }
protected getLines() {
return [
- new InputLine<string>('1', 'key'),
- new InputLine<string>('2', 'key2')
+ new InputLine<string, Input>('1', 'key'),
+ new InputLine<string, Input>('2', 'key2')
];
}
};
get name() { return 'Z'; }
protected getLines() {
- return [ new InputLine('3', 'input') ];
+ return [ new InputLine<any, any>('3', 'input') ];
}
};
}
};
-export class InputLine<T> extends Line<T> {
- private _input: string;
+export class InputLine<T, U = unknown> extends Line<T> {
+ private _input: keyof U;
- constructor(id: string, input: string, description?: string) {
+ form: Form<U>;
+
+ constructor(id: string, input: keyof U, description?: string) {
super(id, description);
this._input = input;
}
value(tr: TaxReturn): T {
- return this.form.getInput<T>(this._input);
+ return this.form.getInput(this._input) as any;
}
};