Skip to content

Conversation

@dckc
Copy link

@dckc dckc commented Feb 26, 2016

I find static type-checking with flow invaluable for refactoring JavaScript. I actually worked up the no-ambient branch with type annotations in place and then took them out to submit the pull request.

In order to minimize diffs, I didn't re-indent the code. I'm interested to know what you think of incorporating this into the project first.

dckc added 12 commits February 25, 2016 21:07
mismatch with es6 specs discovered using flow
Move them closer to other functions that need
similar authority.
  - import powerful objects only
    if (require.main == module), i.e. only when this module
    is invoked from the command line
  - pass access to files, network, randomness explicitly
    rather than using ambient authority
    - to makeConfig(), sslOptions(), makeSturdy(), makeApp()
  - .flowconfig, jshint declarations
  - annotations for exports from caplib, saver
    - name interface types in interfaces/types.js
  - borrow es6 Proxy declaration from typescript
  - adapt misc. node.js API types from typescript
  - tweak commandArgs loop in argMap to not mutate
    strings to numbers in-place
  - tweak copyRecurse isDirectory test to avoid nulls
  - tweak asId to make statically evident that
    it can't return null
  - use single assignment for newContext initialization
  - explicitly check target[method] for null since flow
    doesn't appreciate that it's surrounded by try/catch
While we're at it, get tool support for consistent style from eslint:
  - indent 4 spaces. no tabs. no trailing space
    - one true brace style with the single-line exception
      - except for makeSaver, where emacs got confused
  - double quotes for strings
  - for unused args, use _x name style
    - prune rawSend dead code

relax some of eslint's defaults:
  - console logging is OK
@dckc
Copy link
Author

dckc commented Feb 29, 2016

I re-indented the code, but in a separate commit.

dckc added 7 commits March 3, 2016 20:41
  - reduce filesystem access given to makeSaver
    - ReadAccess, WriteAccess, SyncAccess give access to a specific path
    - just one FileSystem type from node.js
  - server.js: factor run() out of main()
  - use ReadAccess for capper.config, ./ssl/*
    - no need for readFileSync in sslOptions
  - refactor reviverToMaker, reviverToUIPath as
    as Reviver.toMaker and Reviver.sendUI
    - sendUI takes an express Response, which carries authority
      to open files by path name
      - never mind note about express being nearly powerless
  - log errors in showActor
@dckc
Copy link
Author

dckc commented Mar 4, 2016

This branch now has a complete draft of library packaging (#3).

@dckc dckc changed the title static type-checking annotations and tweaks refator as library using static type-checking Mar 4, 2016
@dckc dckc changed the title refator as library using static type-checking refactor as library using static type-checking Mar 4, 2016
@dckc
Copy link
Author

dckc commented Mar 5, 2016

I just realized I haven't been maintaining the mocha tests. Better tend to that...

dckc added 13 commits March 5, 2016 19:30
  - let ezSaver() convenience routine require anything
    - use __dirname in makeReviver() to isolate from
      caller's directory
  - move io builders (fsReadAccess ,...) to saver.js
  - pass saver to run() rather than dbfile
  - pass crypto.randomBytes explicitly to makeUnique
  - use ezSaver convenience routine in tests
consolidate routes using /* and req.params[0]
in flow: Jul 18, 2016: 84a1a24@zacharygolba Add Proxy to core declarations
somewhere before node 7.1, the --harmony-proxies option went away;
https://github.com/tvcutsem/harmony-reflect says node groks as of 6.0.
goal is to log Error traces
  - tighten up static types a bit
In particular, the `has(target, prop)` API.
  - SealerPair:
    - generic parameters
    - nullable return from unseal
  - import Promise from `q` to get `.done()` method
  - add method arg to `Reviver.sendUI` decl
  - the property in the Id type is `@id`, not `id`
  - declare return type of vowAnsToVowJSONString

$ flow version
Flow, a static type checker for JavaScript, version 0.57.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant