Flow抱怨输入未输入

问题描述

我从一个使用react-native-geolocation-service获取用户的GPS位置的React Native项目开始,但是Flow抱怨该库没有类型。该库具有Typescript类型,但似乎没有Flow类型,并且在导入该库时,VS Code会给我这个错误

从未类型化的模块导入会使其events.js:292 throw er; // Unhandled 'error' event ^ Error: Status code: 416 at ClientRequest.<anonymous> (C:\Users\jayca\Documents\NAPPY-TUBE\NappyTube-Bot\node_modules\miniget\dist\index.js:156:27) at Object.onceWrapper (events.js:422:26) at ClientRequest.emit (events.js:315:20) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27) at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17) at TLSSocket.socketonData (_http_client.js:469:22) at TLSSocket.emit (events.js:315:20) at addChunk (_stream_readable.js:295:12) at readableAddChunk (_stream_readable.js:271:9) at TLSSocket.Readable.push (_stream_readable.js:212:10) Emitted 'error' event on Passthrough instance at: at errorOrDestroy (internal/streams/destroy.js:108:12) at Passthrough.onerror (_stream_readable.js:752:7) at Passthrough.emit (events.js:315:20) at Passthrough.<anonymous> (C:\Users\jayca\Documents\NAPPY-TUBE\NappyTube-Bot\node_modules\ytdl-core\lib\index.js:96:16) at Passthrough.emit (events.js:315:20) at ClientRequest.<anonymous> (C:\Users\jayca\Documents\NAPPY-TUBE\NappyTube-Bot\node_modules\miniget\dist\index.js:161:28) at Object.onceWrapper (events.js:422:26) [... lines matching original stack trace ...] at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17) 并不安全!您是要在any的顶部添加// @flow吗? (react-native-geolocation-service)Flow(LintError-untyped-import)

我可以说服Flow停止抱怨该库,还是应该切换到Typescript?我对Flow并没有特别的偏好,这正是untyped-import为我设置的。

我用它来创建项目:

react-native init

然后我像这样添加库:

npx react-native init WarmerWalker

我将这样的库导入App.js中:

npm install react-native-geolocation-service

我尝试将库添加import Geolocation from 'react-native-geolocation-service'; 中的untyped section,但这无济于事。 .flowconfig部分也没有。

代码似乎有效,只是在抱怨Flow。

解决方法

感谢亚历克斯(Alex)的评论,我了解了@flow strict-local search_query = SearchQuery('keyword1 keyword2 keyword3') posts = Post.objects.annotate( title_rank=SearchRank( 'title_vector',query=search_query ) ).annotate( body_rank=SearchRank( 'body_vector',query=search_query ) ).annotate( rank=(self.search_weights['title'] * F('title_rank') + self.search_weights['body'] * F('body_rank')) ).order_by('-rank') 创建的示例应用使用了Typescript template,因此引起了问题。删除react-native使其停止抱怨。

但是,由于我要使用的库具有Typescript类型定义,因此我将切换到Typescript。我使用{{3}}重新生成了示例应用,如下所示:

strict-local