I'm trying to use Flow with AdonisJS.
I want my app to work in adonis serve --dev --debug mode, but with Flow type checking.
I have idea to create folder like flowApp write code there, run something like nodemon that will transpile code to app folder, where adonis serve --dev --debug will get code and reload server. What do you think about this idea? Is there better way to use Flow in Adonis?
I think I've discovered answer. I'll write it here in a days.
So, that's what I've ended up with:
In the root directory (where app folder is), I've created appFlow folder (you can name it as you wish) and copy everything from app. That's what it looks like:
/app
/appFlow
/config
...
{
...
"scripts": {
...
"dev": "adonis serve --dev --debug",
"flow": "flow",
"flow:deps": "flow-typed install",
"babel:build": "babel appFlow -d app",
"babel:watch": "babel appFlow --watch -d app"
},
"dependencies": {
....
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-eslint": "8.2.5",
"babel-plugin-tcomb": "0.3.26",
"babel-preset-env": "1.7.0",
"babel-preset-flow": "6.23.0",
"eslint": "4.19.1",
"eslint-config-airbnb-base": "13.0.0",
"eslint-plugin-flowtype": "2.49.3",
"eslint-plugin-import": "2.13.0",
"flow-bin": "0.75.0",
"flow-typed": "2.4.0",
"tcomb": "3.2.27"
}
...
}
{
"presets": [
["env", {
"targets": {
"node": "10.5"
}
}],
"flow"
],
"plugins": [
"syntax-flow",
"tcomb",
"transform-flow-strip-types"
]
}
module.exports = {
"extends": ["airbnb-base", 'plugin:flowtype/recommended'],
plugins: [
'import',
'flowtype',
],
parser: 'babel-eslint',
env: {
node: true,
},
};
[ignore]
.*/node_modules/.*
[include]
[libs]
flow-typed
[lints]
[options]
all=true
[strict]
To start everything working you need to open 2 terminals:
npm run dev (or adonis serve --dev --debug)npm run babel:watch (or babel appFlow --watch -d app).When you make changes in any appFlow file (like adding new types or something) babel transpile it in to app folder, where adonis serve see changes, grab them and reload itself.
class User extends Model {
id:number
email:string
password:string
deleted:boolean
static boot () {
...
}
...
}
I'll appreciate and advices or questions.
.
@Dionid Thanks for sharing. I will close the issue, since it's not actionable on my end
@thetutlage what are your thoughts on implementing flow in the library?
@Dionid did you define global functions (e.g. use())?
For reference: facebook/flow#7014
Also, if you're coming off google reading this, I'd check out adonisjs/discussion#65
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
So, that's what I've ended up with:
Stack
Folder structer
In the root directory (where
appfolder is), I've createdappFlowfolder (you can name it as you wish) and copy everything fromapp. That's what it looks like:Package.json
.babelrc
.eslintrc.js
.flowconfig
Start
To start everything working you need to open 2 terminals:
npm run dev(oradonis serve --dev --debug)npm run babel:watch(orbabel appFlow --watch -d app).When you make changes in any
appFlowfile (like adding new types or something)babeltranspile it in toappfolder, whereadonis servesee changes, grab them and reload itself.Lifehacks
P.S.
I'll appreciate and advices or questions.
.