Skip to content

Commit

Permalink
flow-lib: JS interfaces for Flow APIs
Browse files Browse the repository at this point in the history
Summary:
This is a first-pass on an idea for an npm package, called `flow-lib`, that allows JS tooling consumers to interface easily with Flow APIs. Pending more experimentation, my hope is that this can become a stable way for JS tooling to integrate with Flow via a simple, well-versioned npm dependency.

To start out I've added JS APIs for `flow check-contents`, `flow ast`, and Flow type definitions for the AST. I also intend to add `type-at-pos`-like APIs as well (all of the tooling needs I can imagine right now need this more than anything else) -- but before that I need to find a good way to represent types that isn't coupled too tightly with Flow implementation details. I'm still working on this and will update when I have something more here.

**NOTE: This is only an RFC while I look into more concrete use cases. I am putting this out for discussion, but I don't necessarily expect to merge it until we see it prove useful or promising for some *specific* tooling needs**
Closes #1360

Reviewed By: samwgoldman

Differential Revision: D3676384

Pulled By: jeffmo

fbshipit-source-id: 96925ebcf12d0509fe49eaa1e17d7958edc20ada
  • Loading branch information
jeffmo authored and Facebook Github Bot 3 committed Aug 9, 2016
1 parent 4ba70f4 commit b437358
Show file tree
Hide file tree
Showing 9 changed files with 927 additions and 0 deletions.
8 changes: 8 additions & 0 deletions npm-flow-lib/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
"transform-flow-strip-types",
"transform-regenerator",
"syntax-async-functions",
],
"presets": ["es2015"]
}
Empty file added npm-flow-lib/.flowconfig
Empty file.
3 changes: 3 additions & 0 deletions npm-flow-lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
*.swp
dist
1 change: 1 addition & 0 deletions npm-flow-lib/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/
22 changes: 22 additions & 0 deletions npm-flow-lib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "flow-lib",
"version": "0.0.0-pre",
"main": "dist/index.js",
"dependencies": {
"babel-polyfill": "^6.13.0"
},
"devDependencies": {
"babel-cli": "^6.11.4",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-flow-strip-types": "^6.8.0",
"flow-bin": "^0.30.0"
},
"scripts": {
"build": "mkdir -p dist; babel ./src --out-dir=./dist",
"clean": "rm -rf dist",
"flow": "flow; test $? -eq 0 -o $? -eq 2",
"prepublish": "mkdir -p; npm run test",
"test": "node dist/test_ast_types",
"watch": "mkdir -p dist; babel --watch=./src --out-dir=./dist"
}
}
Loading

0 comments on commit b437358

Please sign in to comment.