From f2b3a38911dca10a05fb572283e3550e8408c201 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 20 Feb 2020 01:08:19 -0500 Subject: [PATCH] InputLine needs to take the Form's generic. The refactor in b51c88b40714d3b7183fd593c9e4496ff5dc7162 had failing tests that was hidden by Jest's cache. --- src/Line.test.ts | 10 +++++++--- src/Line.ts | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Line.test.ts b/src/Line.test.ts index c0f76ef..135bd92 100644 --- a/src/Line.test.ts +++ b/src/Line.test.ts @@ -53,13 +53,17 @@ test('reference line', () => { }); test('input line', () => { + interface Input { + key: string; + key2?: string; + } class TestForm extends Form { get name() { return 'F1'; } protected getLines() { return [ - new InputLine('1', 'key'), - new InputLine('2', 'key2') + new InputLine('1', 'key'), + new InputLine('2', 'key2') ]; } }; @@ -77,7 +81,7 @@ test('line stack', () => { get name() { return 'Z'; } protected getLines() { - return [ new InputLine('3', 'input') ]; + return [ new InputLine('3', 'input') ]; } }; diff --git a/src/Line.ts b/src/Line.ts index 0dd1b32..f4beb7d 100644 --- a/src/Line.ts +++ b/src/Line.ts @@ -53,15 +53,17 @@ export class ReferenceLine extends Line { } }; -export class InputLine extends Line { - private _input: string; +export class InputLine extends Line { + private _input: keyof U; - constructor(id: string, input: string, description?: string) { + form: Form; + + constructor(id: string, input: keyof U, description?: string) { super(id, description); this._input = input; } value(tr: TaxReturn): T { - return this.form.getInput(this._input); + return this.form.getInput(this._input) as any; } }; -- 2.22.5