testcheck-js icon indicating copy to clipboard operation
testcheck-js copied to clipboard

Flow compatibility with globally available functions

Open wpcarro opened this issue 7 years ago • 0 comments

I'm using jasmine-check's install function, which I believe globally exposes variables like gen and check, which at runtime is working totally fine. I'm having trouble convincing Flow that these variable are indeed available, however. Here's the install code:

import { install } from 'jasmine-check'

install()

Here are two examples of the Flow errors I'm receiving:

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/routes/Linking/store.test.js:265:5

Cannot resolve name check.

     262│     })
     263│   })
     264│   describe('FETCH_ENTITIES_SUCCESS', () => {
     265│     check.it(
     266│       'propertly updates state with the mapped entities',
     267│       testcheckOptions,
     268│       gen.array(genEntityAPI()),


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/routes/Linking/store.test.js:268:7

Cannot resolve name gen.

     265│     check.it(
     266│       'propertly updates state with the mapped entities',
     267│       testcheckOptions,
     268│       gen.array(genEntityAPI()),
     269│       entitiesAPI => {
     270│         const action = {
     271│           type: Actions.FETCH_ENTITIES_SUCCESS,

For the time being, my workaround is...

declare var gen: any
declare var check: any

...but of course this is hackish and only a temporary solution.

It may also be a separate issue, but when I try and install the type definitions for testcheck using flow-typed, it's 404ing.

Here's the command I'm running...

$ npx flow-typed install [email protected]

...and the response that I'm receiving...

!! No [email protected] libdefs found in flow-typed for the explicitly requested libdefs. !!

Consider using `flow-typed create-stub [email protected]` to generate an empty libdef that you can fill in.

This is slightly confusing to me, since I've seen the Flow libdefs in this module. Is there an alternative way of installing these that I'm unaware of? Apologies if this is a separate issue, but I thought I'd include that herein just in case it's related.

wpcarro avatar May 31 '18 16:05 wpcarro