0
最近、私のReact NativeプロジェクトにFlowを適用しました。これまでのところ、ほとんどのことが充足されています。フロータイプのチェックで行内にnull可能なオブジェクトのメソッドを呼び出す
let player ?Object = new Player();
if (this.player) {
this.player.stop();
this.player.destroy();
this.player = null;
}
しかし、Flowは私が以下のようにしたいと考えています。
let player ?Object = new Player();
if (this.player) {
this.player.stop();
}
if (this.player) {
this.player.destroy();
}
this.player = null;
このような状況に対処する適切な方法はありますか?例外的なケースではないので、私はここでコメントを使用したくない。
https://flowtype.org/try/#0MYGwhgzhAEAK4E8CmAnA3gXwFCkjAgtGltNAA6KoBcA-NAPIBGAVksAC7QC80AdkgHc4lFAAoAlAG4S0ALYSiM0iCScKYZCm7R2ACwCWEAHTrN00qX0AzaKNOpxiixfsojEdgHsyE88-IiRgAmSB4ongi+Si4i2rwAriAgfqTYqVgYQA –
'プレイヤーを聞かせて=新しいプレイヤー()' '聞かせてプレイヤーであるべきオブジェクト:?オブジェクト=新しいプレイヤー()' –