【发布时间】:2017-12-22 06:20:14
【问题描述】:
我正在为 fetch API 和 react-native 应用程序中 flowjs 的实现而苦苦挣扎。
使用 Nuclide,我可以看到 Flow 没有涵盖我用来从远程 API 获取数据的 fetch 函数...
是的,如果我 99% 的代码受到监控但仍然受到监控,这没什么大不了的。我想了解发生了什么。
我已经安装了流式。我已经为我的 fetch 创建了一个存根,我可以在 flow-typed/npm/fbjs_vx.x.x.x 中看到它,这里是:
declare module 'fbjs/lib/fetch' {
declare module.exports: any;
}
我也尝试下载替代的 ponyfill 或 polyfill,以便在没有任何成功的情况下覆盖该行。
如果没有 libdef 已经存在,我怎么能说“获取一个字符串作为参数并返回一个承诺”来流动?
感谢您的帮助
更新
这是 package.json
{
"name": "BeerOmatic",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"flow": "flow",
"android": "ENVFILE=.env.dev react-native run-android"
},
"dependencies": {
"eslint-config-airbnb-flow": "^1.0.2",
"eslint-plugin-flowtype": "^2.35.0",
"fetch-ponyfill": "^4.1.0",
"flow-typed": "^2.1.2",
"react": "16.0.0-alpha.12",
"react-native": "0.46.3",
"react-native-config": "^0.5.0",
"react-native-fetch-polyfill": "^1.1.2",
"react-native-navigation": "^1.1.136",
"react-redux": "^5.0.5",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-jest": "20.0.3",
"babel-preset-flow": "^6.23.0",
"babel-preset-react-native": "2.1.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-react-native": "^2.3.2",
"flow-bin": "^0.50.0",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
【问题讨论】:
-
可以添加 package.json 文件吗?
标签: javascript react-native flowtype fetch-api flow-typed