0
爲什麼flowtype會報告以下錯誤,以及如何將這些錯誤記錄爲按預期工作?簡單構造函數中的Flowtype錯誤
index.js:7
4: console.log(MY_OBJECT.getName());
^^^^^^^ property `getName`. Property not found in
4: console.log(MY_OBJECT.getName());
^^^^^^^^^ new object
index.js
// @flow
import {MyObject} from './object';
const MY_OBJECT = new MyObject('name');
console.log(MY_OBJECT.getName());
object.js:
// @flow
export function MyObject(name: string) {
this._name = name;
this.getName = function(): string {return this._name;};
this.setName = function (name: string) {this._name = name;};
}