facebook / facebook/flow

Errors in the wrong places... ie, errors at type declarations, and top of stack...

オープン
#4,261 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
error messages
主要言語
Rust
スター
22.3k
フォーク
1.9k
PR マージ指標
30日以内にマージされた PR はありません

説明

Pretty difficult to replicate easily...

Here's an example of an error showing up at the Type declaration:
I've declared these type...
```
type RequestHandler = (request: Request) => Promise
type UserRequestHandler = (request: UserRequest) => Promise
```
Now, I know the mistake I made was I used a RequestHandler in place of a UserRequestHandler or vice versa in one of my lines of code, but instead I get an error saying:
```
src/framework/Controller.js:60
60: type RequestHandler = (request: Request) => Promise
^^^^^^^ Request. This type is incompatible with the expected param type of
61: type UserRequestHandler = (request: UserRequest) => Promise
^^^^^^^^^^^ UserRequest
```

This is obviously a significant issue completely unhelpful. In order to find the error, I have to dig through the code base for all usages of RequestHandler and UserRequestHandler and see where one was used in the place of the other.

An example of top of stack:
```
static many(ids: Array): Promise> {
return orm.many(this, ids) // do a bunch of stuff in there
}
```
This error is extremely odd, since at no point do we use Lodash.keys on this array, but this is the error we get:
```
src/models/Model.js:56
56: static many(ids: Array): Promise> {
^^^^^^ some string with unknown value. Property not found in
419: keys(object: T): Array<$Keys>;
^^^^^^^^ object literal. See lib: flow-typed/lodash.js:419
```
The most obvious conclusion is that our ids string array or some subsequent transformation of it ends up being used in lodash.keys(), but it isn't... at all...

This is happening pretty consistently throughout the codebase.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。