facebook / facebook/flow

Improve error message for undeclared class property initialization

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

説明

Flow requires that class properties be declared before they can be initialized in a constructor. This behavior is reasonable, but the error message should guide the user to the solution:

``` javascript
/* @flow */

class Foo {
constructor() {
this.bar = "baz";
}
}
```

```
test.js|5 col 5 error| assignment of property bar
|| Property not found in
test.js|3 col 7 error| Foo
||
```

A better error message would direct the user to declare the type of `bar`, as follows:

``` javascript
/* @flow */

class Foo {
bar: string;
constructor() {
this.bar = "baz";
}
}
```

```
|| No errors!
```

A better message might be "Property must be declared in class."

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

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

評価

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

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

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