sourcecred/flow-typed/npm
William Chargin 7702bb2e1d
flow: simplify better-sqlite3 bound parameters (#869)
Summary:
The actual constraints for bound parameters are too complicated to
express within Flow. This commit changes the type definitions from one
approximation to another, simpler one. Neither approximation is likely
to cause many problems in practice, either in terms of spurious errors
or spurious lacks of error. (The failure mode for the new formulation is
having multiple dictionaries of binding values, which would pass Flow
but quickly raise a `TypeError` at runtime.)

The reason for the change is that it makes the method definitions
considerably simpler, in a way that is likely to avoid other problems
with Flow. In particular, this removes method overloads and the need for
parameter disambiguation.

I fix a typo while in the area.

Test Plan:
Note that the following file typechecks:

```js
// @flow
import Database from "better-sqlite3";
const db = new Database(":memory:");
const stmt = db.prepare("BEGIN"); // SQL text doesn't matter

stmt.run();
stmt.run(null, 2, "three", new Buffer(Array(4)));
stmt.run(+false);
stmt.run(1, {dos: 2}, 3); // the binding dictionary can go anywhere
stmt.run({a: 1}, {b: 2}); // this will fail at runtime (TypeError)

// $ExpectFlowError
stmt.run(false); // booleans cannot be bound
// $ExpectFlowError
stmt.run({x: {y: "z"}}); // named parameters are not recursive
```

All but the last two success cases (lines 9 and 10) would also have
passed before this change.

wchargin-branch: flow-better-sqlite3-bound-parameters-simplify
2018-09-20 11:31:26 -07:00
..
better-sqlite3_vx.x.x.js flow: simplify better-sqlite3 bound parameters (#869) 2018-09-20 11:31:26 -07:00
chalk_v1.x.x.js Add all available flow-typed libdefs (#548) 2018-07-27 17:23:24 -07:00
dotenv_v4.x.x.js Add all available flow-typed libdefs (#548) 2018-07-27 17:23:24 -07:00
enzyme_v3.x.x.js Add all available flow-typed libdefs (#548) 2018-07-27 17:23:24 -07:00
express_v4.16.x.js Upgrade Flow to v0.76.0 (#546) 2018-07-27 15:54:59 -07:00
flow-bin_v0.x.x.js Move package json to root (#37) 2018-02-26 22:32:23 -08:00
isomorphic-fetch_v2.x.x.js Add all available flow-typed libdefs (#548) 2018-07-27 17:23:24 -07:00
jest_v23.x.x.js Upgrade jest to 23.4.1 (#537) 2018-07-27 12:28:04 -07:00
mkdirp_v0.5.x.js Add all available flow-typed libdefs (#548) 2018-07-27 17:23:24 -07:00
object-assign_v4.x.x.js Add all available flow-typed libdefs (#548) 2018-07-27 17:23:24 -07:00
prettier_v1.x.x.js Add all available flow-typed libdefs (#548) 2018-07-27 17:23:24 -07:00
react-scripts_vx.x.x.js Move package json to root (#37) 2018-02-26 22:32:23 -08:00