React-native-firebase: Transaction related flow types throwing errors

Created on 8 Mar 2018  路  4Comments  路  Source: invertase/react-native-firebase

Issue

After updating to react-native 0.54.0 (uses flow 0.65) and updating react-native-firebase I started getting a lot of flow related errors

Error: node_modules/react-native-firebase/dist/modules/firestore/Transaction.js.flow:103
         v-------------------------
103:     this._commandBuffer.push({
104:       type: 'set',
105:       path: documentRef.path,
...:
108:     });
         -^ rest parameter array of call of method `push`. Has some incompatible type argument with
249:     push(...items: Array<T>): number;
                        ^^^^^^^^ array type. See lib: /private/tmp/flow/flowlib_26f7b5b2/core.js:249
  Type argument `T` is incompatible:
                                      v
    103:     this._commandBuffer.push({
    104:       type: 'set',
    105:       path: documentRef.path,
    ...:
    108:     });
             ^ object literal. This type is incompatible with
     37:   _commandBuffer: Array<Command>;
                                 ^^^^^^^ Command
      Property `options` is incompatible:
        107:       options: options || {},
                                       ^^ object literal. This type is incompatible with
         20:   options: ?{ merge: boolean },
                         ^^^^^^^^^^^^^^^^^^ object type
          Property `merge` is incompatible:
             20:   options: ?{ merge: boolean },
                             ^^^^^^^^^^^^^^^^^^ property `merge`. Property not found in
            107:       options: options || {},
                                           ^^ object literal

Error: node_modules/react-native-firebase/dist/modules/firestore/Transaction.js.flow:156
         v-------------------------
156:     this._commandBuffer.push({
157:       type: 'update',
158:       path: documentRef.path,
159:       data: buildNativeMap(data),
160:     });
         -^ rest parameter array of call of method `push`. Has some incompatible type argument with
249:     push(...items: Array<T>): number;
                        ^^^^^^^^ array type. See lib: /private/tmp/flow/flowlib_26f7b5b2/core.js:249
  Type argument `T` is incompatible:
                                      v
    156:     this._commandBuffer.push({
    157:       type: 'update',
    158:       path: documentRef.path,
    159:       data: buildNativeMap(data),
    160:     });
             ^ object literal. This type is incompatible with
     37:   _commandBuffer: Array<Command>;
                                 ^^^^^^^ Command
      Property `options` is incompatible:
         37:   _commandBuffer: Array<Command>;
                                     ^^^^^^^ property `options`. Property not found in
                                          v
        156:     this._commandBuffer.push({
        157:       type: 'update',
        158:       path: documentRef.path,
        159:       data: buildNativeMap(data),
        160:     });
                 ^ object literal

Error: node_modules/react-native-firebase/dist/modules/firestore/Transaction.js.flow:174
         v-------------------------
174:     this._commandBuffer.push({
175:       type: 'delete',
176:       path: documentRef.path,
177:     });
         -^ rest parameter array of call of method `push`. Has some incompatible type argument with
249:     push(...items: Array<T>): number;
                        ^^^^^^^^ array type. See lib: /private/tmp/flow/flowlib_26f7b5b2/core.js:249
  Type argument `T` is incompatible:
                                      v
    174:     this._commandBuffer.push({
    175:       type: 'delete',
    176:       path: documentRef.path,
    177:     });
             ^ object literal. This type is incompatible with
     37:   _commandBuffer: Array<Command>;
                                 ^^^^^^^ Command
      Property `data` is incompatible:
         37:   _commandBuffer: Array<Command>;
                                     ^^^^^^^ property `data`. Property not found in
                                          v
        174:     this._commandBuffer.push({
        175:       type: 'delete',
        176:       path: documentRef.path,
        177:     });
                 ^ object literal

Error: node_modules/react-native-firebase/dist/modules/firestore/Transaction.js.flow:174
         v-------------------------
174:     this._commandBuffer.push({
175:       type: 'delete',
176:       path: documentRef.path,
177:     });
         -^ rest parameter array of call of method `push`. Has some incompatible type argument with
249:     push(...items: Array<T>): number;
                        ^^^^^^^^ array type. See lib: /private/tmp/flow/flowlib_26f7b5b2/core.js:249
  Type argument `T` is incompatible:
                                      v
    174:     this._commandBuffer.push({
    175:       type: 'delete',
    176:       path: documentRef.path,
    177:     });
             ^ object literal. This type is incompatible with
     37:   _commandBuffer: Array<Command>;
                                 ^^^^^^^ Command
      Property `options` is incompatible:
         37:   _commandBuffer: Array<Command>;
                                     ^^^^^^^ property `options`. Property not found in
                                          v
        174:     this._commandBuffer.push({
        175:       type: 'delete',
        176:       path: documentRef.path,
        177:     });
                 ^ object literal

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:76
 76:     meta.transaction = new Transaction(this._firestore, meta);
              ^^^^^^^^^^^ property `transaction`. Property not found in
 76:     meta.transaction = new Transaction(this._firestore, meta);
         ^^^^ object literal

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:76
 76:     meta.transaction = new Transaction(this._firestore, meta);
                                                             ^^^^ object literal. This type is incompatible with the expected param type of
 39:   constructor(firestore: Firestore, meta: TransactionMeta) {
                                               ^^^^^^^^^^^^^^^ TransactionMeta. See: node_modules/react-native-firebase/dist/modules/firestore/Transaction.js.flow:39
  Property `transaction` is incompatible:
     39:   constructor(firestore: Firestore, meta: TransactionMeta) {
                                                   ^^^^^^^^^^^^^^^ property `transaction`. Property not found in. See: node_modules/react-native-firebase/dist/modules/firestore/Transaction.js.flow:39
     76:     meta.transaction = new Transaction(this._firestore, meta);
                                                                 ^^^^ object literal

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:77
 77:     this._pending[id] = meta;
                             ^^^^ object literal. This type is incompatible with
 77:     this._pending[id] = meta;
         ^^^^^^^^^^^^^^^^^ TransactionMeta
  Property `stack` is incompatible:
                      v----------------
     70:       stack: new Error().stack
     71:         .split('\n')
     72:         .slice(4)
     73:         .join('\n'),
                 ----------^ string. This type is incompatible with
     22:   stack: Array<string>,
                  ^^^^^^^^^^^^^ array type

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:77
 77:     this._pending[id] = meta;
                             ^^^^ object literal. This type is incompatible with
 77:     this._pending[id] = meta;
         ^^^^^^^^^^^^^^^^^ TransactionMeta
  Property `transaction` is incompatible:
     40:   _pending: { [number]: TransactionMeta };
                                 ^^^^^^^^^^^^^^^ property `transaction`. Property not found in
     77:     this._pending[id] = meta;
                                 ^^^^ object literal

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:82
                          v-----
 82:       meta.resolve = r => {
 83:         resolve(r);
 84:         this._remove(id);
 85:       };
           ^ function. This type is incompatible with
 82:       meta.resolve = r => {
           ^^^^^^^^^^^^ null

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:86
                         v-----
 86:       meta.reject = e => {
 87:         reject(e);
 88:         this._remove(id);
 89:       };
           ^ function. This type is incompatible with
 86:       meta.reject = e => {
           ^^^^^^^^^^^ null

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:181
181:       return reject(finalError);
                  ^^^^^^^^^^^^^^^^^^ call of `reject`. Function cannot be called on possibly null value
181:       return reject(finalError);
                  ^^^^^^ null

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:207
207:       const { code, message } = error;
                   ^^^^ property `code`. Property cannot be accessed on possibly null value
207:       const { code, message } = error;
                                     ^^^^^ null or undefined

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:207
207:       const { code, message } = error;
                   ^^^^ property `code`. Property cannot be accessed on possibly undefined value
207:       const { code, message } = error;
                                     ^^^^^ null or undefined

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:207
207:       const { code, message } = error;
                         ^^^^^^^ property `message`. Property cannot be accessed on possibly null value
207:       const { code, message } = error;
                                     ^^^^^ null or undefined

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:207
207:       const { code, message } = error;
                         ^^^^^^^ property `message`. Property cannot be accessed on possibly undefined value
207:       const { code, message } = error;
                                     ^^^^^ null or undefined

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:212
212:       errorWithStack.code = code;
                          ^^^^ property `code`. Property not found in
212:       errorWithStack.code = code;
           ^^^^^^^^^^^^^^ Error

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:213
213:       errorWithStack.stack = meta.stack;
                                  ^^^^^^^^^^ array type. This type is incompatible with
213:       errorWithStack.stack = meta.stack;
           ^^^^^^^^^^^^^^^^^^^^ string

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:215
215:       meta.reject(errorWithStack);
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call of method `reject`. Function cannot be called on possibly null value
215:       meta.reject(errorWithStack);
           ^^^^^^^^^^^ null

Error: node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js.flow:231
231:       meta.resolve(pendingResult);
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call of method `resolve`. Function cannot be called on possibly null value
231:       meta.resolve(pendingResult);
           ^^^^^^^^^^^^ null

Environment

  1. Application Target Platform: iOS / Android
  1. Development Operating System: macOS High Sierra
  1. Build Tools: Flow, Xcode, Android Studio, VSCode
  1. React Native version: 0.54.0
  1. RNFirebase Version: 3.3.0
  1. Firebase Module: Transactions

Most helpful comment

@IljaDaderko literally just published v3.3.1 to fix this

All 4 comments

@IljaDaderko fixed in v3.3.1 :)

@IljaDaderko literally just published v3.3.1 to fix this

Got scared by how quickly you guys responded

Zoom zoom :)

gif

Was this page helpful?
0 / 5 - 0 ratings