import {DataClass, JSON2, ReifiedType, setUpDataClass} from "@lightningkite/khrysalis-runtime"; import {Condition, KeyPath, startChain, xKeyPathEq} from "../src"; class Point implements DataClass { public static properties = ["x", "y"] public static propertyTypes = (): Record => ({x: [Number], y: [Number]}) public constructor(public x: number, public y: number) { } copy: (values: Partial) => this; equals: (other: any) => boolean; hashCode: () => number; toJSON: () => Record; public static fromJSON: (record: Record, innerType: Array)=>Point; } setUpDataClass(Point) class PointFields { static INSTANCE = new PointFields() readonly x = "x" readonly y = "y" } function PointChain(): KeyPath { return startChain() } (Point as any)._fields = new Map(Object.entries({ 'x': PointFields.INSTANCE.x, 'y': PointFields.INSTANCE.y, })) describe("TestDataClass", ()=> { test("hashCode", ()=> { console.log(Number) const cond = xKeyPathEq(PointChain().get(PointFields.INSTANCE.x), 32) const asStr = JSON.stringify(cond) console.log(asStr) const copy = JSON2.parse(asStr, [Condition, [Point]]) console.log(copy) }) })