diff --git a/src/models/__tests__/queries.spec.ts b/src/models/__tests__/queries.spec.ts index 75f7f5b..2bc0745 100644 --- a/src/models/__tests__/queries.spec.ts +++ b/src/models/__tests__/queries.spec.ts @@ -91,13 +91,13 @@ describe("QueryTerm", () => { it("stringifies only the left side of an op if the right side is invalid", () => { const term = createOp("AND", createExpr(), new QueryTerm("expr")); expect(term.toString()).toBe("{[alice|bob]}"); - term.right = null; + term.right = undefined; expect(term.toString()).toBe("{[alice|bob]}"); }); it("stringifies only the right side of an op if the left side is invalid", () => { const term = createOp("AND", new QueryTerm("expr")); expect(term.toString()).toBe("{[charlie|eve]}"); - term.left = null; + term.left = undefined; expect(term.toString()).toBe("{[charlie|eve]}"); }); }); @@ -132,7 +132,7 @@ describe("QueryTerm", () => { describe("removeLeft", () => { it("refuses to operate without a right term", () => { const term = createOp(); - term.right = null; + term.right = undefined; expect(() => term.removeLeft()).toThrowError(QueryTermError); }); it("creates an expr when right is an expr", () => { @@ -161,7 +161,7 @@ describe("QueryTerm", () => { describe("removeRight", () => { it("refuses to operate without a left term", () => { const term = createOp(); - term.left = null; + term.left = undefined; expect(() => term.removeRight()).toThrowError(QueryTermError); }); it("creates an expr when left is an expr", () => { diff --git a/src/models/queries.ts b/src/models/queries.ts index 004b544..6c45810 100644 --- a/src/models/queries.ts +++ b/src/models/queries.ts @@ -213,13 +213,13 @@ export class QueryTerm { termType: string; // termType == "op" - operation: string | null = null; - left: QueryTerm | null = null; - right: QueryTerm | null = null; + operation?: string = undefined; + left?: QueryTerm = undefined; + right?: QueryTerm = undefined; // termType == "expr" category: string = ""; - value: string | number | QueryModuleTerm | null = null; + value?: string | number | QueryModuleTerm = undefined; filters: QueryFilter[] = []; count: number = 1; @@ -241,7 +241,7 @@ export class QueryTerm { this.right = new QueryTerm("expr"); this.category = ""; - this.value = null; + this.value = undefined; this.filters.length = 0; this.count = 1; } @@ -264,9 +264,9 @@ export class QueryTerm { this.filters = this.right.filters; this.count = this.right.count; - this.left = null; - this.right = null; - this.operation = null; + this.left = undefined; + this.right = undefined; + this.operation = undefined; return; } this.operation = this.right.operation; @@ -286,9 +286,9 @@ export class QueryTerm { this.filters = this.left.filters; this.count = this.left.count; - this.left = null; - this.right = null; - this.operation = null; + this.left = undefined; + this.right = undefined; + this.operation = undefined; return; } this.operation = this.left.operation; @@ -377,12 +377,12 @@ export class QueryTerm { clear() { this.termType = "expr"; - this.left = null; - this.right = null; - this.operation = null; + this.left = undefined; + this.right = undefined; + this.operation = undefined; this.category = ""; this.filters.length = 0; - this.value = null; + this.value = undefined; this.count = 1; } }