Skip to content

Commit

Permalink
Update Flow to 0.140.0
Browse files Browse the repository at this point in the history
  • Loading branch information
radex committed Dec 17, 2020
1 parent b5a5d90 commit 858e715
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ esproposal.optional_chaining=enable
emoji=true
module.ignore_non_literal_requires=true
module.file_ext=.js
types_first=false
types_first=true
well_formed_exports=true

[version]
>=0.108.0
>=0.140.0
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev:native": "react-native start",
"release": "node ./scripts/publish.js",
"prettier": "prettier-eslint --config ./.prettierrc --write \"./src/**/*.js\"",
"flow": "flow check",
"flow": "flow check --color always",
"eslint": "eslint ./src -c ./.eslintrc.yml --cache --cache-location ./.cache/.eslintcache",
"tslint": "tslint --project .",
"test": "jest --config=./jest.config.js --forceExit --detectOpenHandles --no-cache",
Expand All @@ -34,6 +34,7 @@
"react-native",
"watermelon",
"offline",
"reactive",
"persistence"
],
"repository": {
Expand Down Expand Up @@ -118,7 +119,7 @@
"execa": "^2.0.0",
"fake-indexeddb": "^3.0.0",
"fast-async": "^7.0",
"flow-bin": "^0.139.0",
"flow-bin": "^0.140.0",
"fs-extra": "^8.0.0",
"glob-to-regexp": "^0.4.1",
"inquirer": "^7.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/Collection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class Collection<Record: Model> {
constructor(database: Database, ModelClass: Class<Record>): void {
this.database = database
this.modelClass = ModelClass
this._cache = new RecordCache(ModelClass.table, raw => new ModelClass(this, raw), this)
this._cache = new RecordCache<Record>((ModelClass.table: $FlowFixMe), raw => new ModelClass((this: $FlowFixMe), raw), this)
}

get db(): Database {
Expand Down Expand Up @@ -63,6 +63,7 @@ export default class Collection<Record: Model> {
}
})
} else {
// $FlowFixMe
observer.error(result.error)
}
})
Expand Down Expand Up @@ -98,13 +99,15 @@ export default class Collection<Record: Model> {
// Prepares a new record in this collection
// Use this to batch-create multiple records
prepareCreate(recordBuilder: Record => void = noop): Record {
// $FlowFixMe
return this.modelClass._prepareCreate(this, recordBuilder)
}

// Prepares a new record in this collection based on a raw object
// e.g. `{ foo: 'bar' }`. Don't use this unless you know how RawRecords work in WatermelonDB
// this is useful as a performance optimization or if you're implementing your own sync mechanism
prepareCreateFromDirtyRaw(dirtyRaw: DirtyRaw): Record {
// $FlowFixMe
return this.modelClass._prepareCreateFromDirtyRaw(this, dirtyRaw)
}

Expand All @@ -124,6 +127,7 @@ export default class Collection<Record: Model> {
// *** Implementation details ***

get table(): TableName<Record> {
// $FlowFixMe
return this.modelClass.table
}

Expand Down
1 change: 1 addition & 0 deletions src/Query/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export default class Query<Record: Model> {
}

get table(): TableName<Record> {
// $FlowFixMe
return this.modelClass.table
}

Expand Down
1 change: 1 addition & 0 deletions src/sync/impl/applyRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ function prepareApplyRemoteChangesToCollection<T: Model>(
})

deleted.forEach(record => {
// $FlowFixMe
recordsToBatch.push(record.prepareDestroyPermanently())
})

Expand Down
2 changes: 2 additions & 0 deletions src/sync/impl/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export function prepareUpdateFromRaw<T: Model>(
newRaw = conflictResolver(record.table, record._raw, updatedDirtyRaw, newRaw)
}

// $FlowFixMe
return record.prepareUpdate(() => {
replaceRaw(record, newRaw)

Expand All @@ -98,6 +99,7 @@ export function prepareUpdateFromRaw<T: Model>(

export function prepareMarkAsSynced<T: Model>(record: T): T {
const newRaw = Object.assign({}, record._raw, { _status: 'synced', _changed: '' }) // faster than object spread
// $FlowFixMe
return record.prepareUpdate(() => {
replaceRaw(record, newRaw)
})
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3716,10 +3716,10 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08"
integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==

flow-bin@^0.139.0:
version "0.139.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.139.0.tgz#3ad6c75460be45b64f00521035c5affb3c440df5"
integrity sha512-eilVetLwztYtKjRj//4OsJ7aw47hsUZ8GTINxaZHWhpqiFikErQL0sV/3hQtpm54w9FuS2PO4yvbU0pWrtckqg==
flow-bin@^0.140.0:
version "0.140.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.140.0.tgz#bf1a2984a0e5604daa0d1e0432138d9897af65bb"
integrity sha512-9P/VciKACXocClhLiDg/p1ntYmgCEEc9QrNOoTqTi2SEdEZDTiAmJLONRJfw4uglPVRZ1p/esWF9KlbZiuxqVw==

for-in@^1.0.1, for-in@^1.0.2:
version "1.0.2"
Expand Down

0 comments on commit 858e715

Please sign in to comment.