使用 flowjs 在 `import *` 上分配模拟函数

Abr*_*m P 5 javascript types mocking covariant flowtype

假设我有以下代码:

export const exampleFunc = () => {}
Run Code Online (Sandbox Code Playgroud)

然后在测试中使用它,如下所示:

import * as exampleAll from '../../path/to/example'


describe('Example', () => {

  exampleAll.exampleFunc = jest.fn()
})
Run Code Online (Sandbox Code Playgroud)

这无法通过以下方式进行类型检查:

无法将 jest.fn() 分配给 exampleAll.exampleFunc,因为属性 exampleFunc 不可写。

 44? const mockStore = configureStore([reduxThunk])
 45?
 46? describe('[Redux action] ExampleAction()', () => {
 47?     exampleAll.exampleFunc = jest.fn()
 48?     beforeEach(() => {
 49?       exampleAll.exampleFunc.mockReturnValue(() => () => {})
 50?     })
Run Code Online (Sandbox Code Playgroud)

为什么不可写?我怎样才能在使用 flow 的同时进行这样的模拟?

谢谢!