33import { firestore } from 'firebase-admin' ;
44import { expectError , expectType } from 'tsd' ;
55import { DefaultMigrator , Traverser , createMigrator , createTraverser } from '../../src' ;
6- import { D , collectionRef } from './_helpers' ;
6+ import { TestAppModelType , TestDbModelType , collectionRef } from './_helpers' ;
77
88const defaultMigrator = createMigrator ( collectionRef ) ;
99
10- expectType < Traverser < D > > ( defaultMigrator . traverser ) ;
10+ expectType < Traverser < TestAppModelType , TestDbModelType > > ( defaultMigrator . traverser ) ;
1111
1212( ( ) => {
1313 const modifiedMigrator = defaultMigrator . withPredicate ( ( doc ) => {
14- expectType < firestore . QueryDocumentSnapshot < D > > ( doc ) ;
14+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > > ( doc ) ;
1515 return false ;
1616 } ) ;
17- expectType < DefaultMigrator < D > > ( modifiedMigrator ) ;
17+ expectType < DefaultMigrator < TestAppModelType , TestDbModelType > > ( modifiedMigrator ) ;
1818} ) ( ) ;
1919
2020( ( ) => {
2121 const traverser = createTraverser ( collectionRef ) ;
2222 const modifiedMigrator = defaultMigrator . withTraverser ( traverser ) ;
23- expectType < DefaultMigrator < D > > ( modifiedMigrator ) ;
23+ expectType < DefaultMigrator < TestAppModelType , TestDbModelType > > ( modifiedMigrator ) ;
2424} ) ( ) ;
2525
2626defaultMigrator . onBeforeBatchStart ( ( batchDocs , batchIndex ) => {
27- expectType < firestore . QueryDocumentSnapshot < D > [ ] > ( batchDocs ) ;
27+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > [ ] > ( batchDocs ) ;
2828 expectType < number > ( batchIndex ) ;
2929} ) ;
3030
3131defaultMigrator . onAfterBatchComplete ( ( batchDocs , batchIndex ) => {
32- expectType < firestore . QueryDocumentSnapshot < D > [ ] > ( batchDocs ) ;
32+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > [ ] > ( batchDocs ) ;
3333 expectType < number > ( batchIndex ) ;
3434} ) ;
3535
@@ -52,17 +52,17 @@ defaultMigrator.set({ num: 0 }, { merge: true });
5252
5353expectError (
5454 defaultMigrator . setWithDerivedData ( ( doc ) => {
55- expectType < firestore . QueryDocumentSnapshot < D > > ( doc ) ;
55+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > > ( doc ) ;
5656 return { num : 0 } ;
5757 } )
5858) ;
5959defaultMigrator . setWithDerivedData ( ( doc ) => {
60- expectType < firestore . QueryDocumentSnapshot < D > > ( doc ) ;
60+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > > ( doc ) ;
6161 return { num : 0 , text : '' } ;
6262} ) ;
6363defaultMigrator . setWithDerivedData (
6464 ( doc ) => {
65- expectType < firestore . QueryDocumentSnapshot < D > > ( doc ) ;
65+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > > ( doc ) ;
6666 return { num : 0 } ;
6767 } ,
6868 { merge : true }
@@ -78,14 +78,14 @@ defaultMigrator.update('anyField', 'anyValue');
7878
7979expectError (
8080 defaultMigrator . updateWithDerivedData ( ( doc ) => {
81- expectType < firestore . QueryDocumentSnapshot < D > > ( doc ) ;
81+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > > ( doc ) ;
8282 return { anyField : '' } ;
8383 } )
8484) ;
8585
8686expectError (
8787 defaultMigrator . updateWithDerivedData ( ( doc ) => {
88- expectType < firestore . QueryDocumentSnapshot < D > > ( doc ) ;
88+ expectType < firestore . QueryDocumentSnapshot < TestAppModelType , TestDbModelType > > ( doc ) ;
8989 return [ 'anyField' , 'anyValue' ] ;
9090 } )
9191) ;
0 commit comments