From d022015e38fd009602b37a5e007edb92198affc5 Mon Sep 17 00:00:00 2001 From: streamich Date: Fri, 17 Jan 2025 21:09:30 +0100 Subject: [PATCH] =?UTF-8?q?feat(json-crdt):=20=F0=9F=8E=B8=20issue=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/json-crdt/__demos__/issue-801.ts | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/json-crdt/__demos__/issue-801.ts diff --git a/src/json-crdt/__demos__/issue-801.ts b/src/json-crdt/__demos__/issue-801.ts new file mode 100644 index 0000000000..62ff82c2cd --- /dev/null +++ b/src/json-crdt/__demos__/issue-801.ts @@ -0,0 +1,45 @@ +/* tslint:disable no-console */ + +/** + * Run this demo with: + * + * npx nodemon -q -x ts-node src/json-crdt/__demos__/issue-801.ts + * + * @see issue: https://github.com/streamich/json-joy/issues/801 + */ + +// Original source: +// +// interface SimpleObjectI { +// text: string +// } +// const SimpleObjectSchema = s.obj({ +// text: s.con(''), +// }) +// const model = Model.create().setSchema(SimpleObjectSchema) +// const root: SimpleObjectI = { +// text: 'foo' +// } +// model.api.root(root) +// type SimpleObjectNodeType = ObjNode<{ +// text: ConNode +// }> +// function foo(_node: ObjApi) {} +// foo(model.api.node) + + +import {JsonNodeView, Model} from '..'; +import {s} from '../../json-crdt-patch'; +import {SchemaToJsonNode} from '../schema/types'; + +const SimpleObjectSchema = s.obj({ + text: s.con('foo'), +}); + +const model = Model.create(SimpleObjectSchema); + +type SimpleObjectNodeType = SchemaToJsonNode; +type SimpleObjectI = JsonNodeView; +// type SimpleObjectI = ReturnType<(typeof model)['view']>; + +console.log(model + '');