abstract get name(): string;
+ readonly supportsMultipleCopies: boolean = false;
+
constructor(input?: I) {
this._input = input;
this.getLines().map(this.addLine.bind(this));
return this._input[name];
}
};
-
-export interface SupportsMultipleCopies extends Form {
- aggregate(forms: Form[]): this;
-};
-
-export function supportsMultipleCopies(f: object): f is SupportsMultipleCopies {
- return f instanceof Form && 'aggregate' in f;
-};
import { Line, AccumulatorLine, InputLine, ReferenceLine, ComputedLine } from './Line';
-import Form, { SupportsMultipleCopies } from './Form';
+import Form from './Form';
import TaxReturn from './TaxReturn';
import { NotFoundError } from './Errors';
});
test('accumulator line', () => {
- class TestForm extends Form implements SupportsMultipleCopies {
+ class TestForm extends Form {
get name() { return 'Form B'; }
- aggregate() { return null; }
+ readonly supportsMultipleCopies = true;
protected getLines() {
return [ new ConstantLine<number>('g', 100.25) ]
import TaxReturn from './TaxReturn';
import Person from './Person';
-import Form, { SupportsMultipleCopies } from './Form';
+import Form from './Form';
import { NotFoundError, InconsistencyError } from './Errors';
test('constructor', () => {
});
test('multiple-copy forms', () => {
- class TestForm extends Form implements SupportsMultipleCopies {
+ class TestForm extends Form {
get name(): string { return 'Test Form'; }
- aggregate(forms: Form[]): this { return null; }
+ readonly supportsMultipleCopies = true;
protected getLines() { return []; }
};
-import Form, { SupportsMultipleCopies, supportsMultipleCopies } from './Form';
+import Form from './Form';
import Person, { Relation } from './Person';
import { NotFoundError, InconsistencyError, UnsupportedFeatureError } from './Errors';
}
addForm(form: Form) {
- if (!supportsMultipleCopies(form)) {
+ if (!form.supportsMultipleCopies) {
const other = this.getForms(form.name);
if (other.length > 0) {
throw new InconsistencyError(`Cannot have more than one type of form ${form.name}`);
-import Form, { SupportsMultipleCopies } from '../Form';
+import Form from '../Form';
import { Line, InputLine } from '../Line';
import Person from '../Person';
class Input<T extends keyof W2Input> extends InputLine<W2Input, T> {};
-export default class W2 extends Form<W2Input> implements SupportsMultipleCopies {
+export default class W2 extends Form<W2Input> {
get name(): string { return 'W-2'; }
+ readonly supportsMultipleCopies = true;
+
aggregate(f: Form[]): this { return null; }
protected getLines(): Line<any>[] {