@@ -36,9 +36,12 @@ import {
3636// > https://exploringjs.com/deep-js/ch_proxies.html
3737setAutoFreeze ( false ) ;
3838
39- export class Paper < UserOperations extends OperationMap = OperationMap > {
40- protected history : DocumentStore [ ] = [ ] ;
41- protected current : DocumentStore ;
39+ export class Paper <
40+ SchemaTypes extends Record < string , any > = Record < string , any > ,
41+ UserOperations extends OperationMap = OperationMap
42+ > {
43+ protected history : DocumentStore < SchemaTypes > [ ] = [ ] ;
44+ protected current : DocumentStore < SchemaTypes > ;
4245 protected sourceGraphQLSchema : GraphQLSchema ;
4346 protected mutateQueue : Queue = new Queue ( ) ;
4447
@@ -57,7 +60,7 @@ export class Paper<UserOperations extends OperationMap = OperationMap> {
5760
5861 constructor ( graphqlSchema : Parameters < typeof createSchema > [ 0 ] , options ?: { operations ?: UserOperations } ) {
5962 const schema = createSchema ( graphqlSchema ) ;
60- this . current = createDocumentStore ( schema ) ;
63+ this . current = createDocumentStore ( schema ) as DocumentStore < SchemaTypes > ;
6164 this . sourceGraphQLSchema = schema ;
6265
6366 this . operations = {
@@ -66,8 +69,8 @@ export class Paper<UserOperations extends OperationMap = OperationMap> {
6669 } ;
6770 }
6871
69- get data ( ) : DocumentStore {
70- return proxyWrap ( this . sourceGraphQLSchema , this . current ) ;
72+ get data ( ) : DocumentStore < SchemaTypes > {
73+ return proxyWrap ( this . sourceGraphQLSchema , this . current ) as DocumentStore < SchemaTypes > ;
7174 }
7275
7376 find ( documentOrKey : KeyOrDocument ) : Document | undefined {
@@ -103,7 +106,7 @@ export class Paper<UserOperations extends OperationMap = OperationMap> {
103106
104107 const next = await produce ( current , async ( draft ) => {
105108 const { transactionResult, eventQueue } = await transaction < typeof operations > (
106- draft ,
109+ draft as DocumentStore < SchemaTypes > ,
107110 schema ,
108111 operations ,
109112 hooks ,
0 commit comments