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 + '');