ESLint误解Flow类属性类型定义

时间:2018-10-30 09:33:31

标签: javascript eslint flowtype

我正在将ESLint与Flow一起使用,并且在类语法上遇到了一些麻烦。这是代码:

interface ITransactionState {
  activeKey: string;
  panes: Object;
  selectedRow: Array<any>;
  loading: boolean;
  data: Array<any>;
}

interface ITransactionProps {}

export default class Transaction extends Component<ITransactionProps, ITransactionState> {
  // Type Defs
  newTabIndex: number;              // ESLint said: newTabIndex should be placed after onEdit
  state: ITransactionState;         // ESLint said: state shouod be placed after constructor

  constructor(props:ITransactionProps) {
      ...
  }
  ...

在构造函数中,有两个变量:newTabIndex和state。但是ESLint不断向我显示错误,这些变量必须位于blabla下。

ESLint是否有办法了解Flow / TypeScript中的类型定义,还是只是忽略该行而无需手动忽略每一行?

1 个答案:

答案 0 :(得分:0)

我通过添加以下规则解决了这个问题:

const promiseOfWindowLoad = new Promise(function(resolve, reject) {
  window.onload = resolve;
});

希望这会有所帮助!

相关问题