将流与ImmutableJs记录一起使用-缺少“值”的类型注释

时间:2019-05-25 21:19:57

标签: javascript flowtype immutable.js

我收到此流程错误:

[Flow]

alertModal: RecordFactory<AlertModalState>
Missing type annotation for `Values`. `Values` is a type parameter declared in function type [1] and was implicitly instantiated at call of `Record` [2]. (References: [1] [2])

关于此代码:

export const makeFormControls = Record({
  alertModal: new alertModal()
})

这里是所有涉及的代码:

//@flow
import type { RecordOf } from 'immutable'
import { Record } from 'immutable'


export type AlertModalState = {
  isOpen: boolean,
  title: string,
  message: string,
  height: number,
  hasYesNo: boolean,
  yesFunction: string
}

export const alertModal: RecordFactory<AlertModalState> = Record({
  isOpen: false,
  title: '',
  message: '',
  height: 0,
  hasYesNo: false,
  yesFunction: ''
})

export type AlertModalRecord = RecordOf<AlertModalState>



type FormControlsProps = {
  alertModal: AlertModalRecord
}

export const makeFormControls = Record({
  alertModal: new alertModal()
})

export type FormControls = RecordOf<FormControlsProps>

为什么流程会抱怨某些Values参数被声明并隐式实例化?

1 个答案:

答案 0 :(得分:0)

将不可变js从4.0.0-rc.9升级到4.0.0-rc.12可以解决此问题。