sris
sris

Reputation: 4978

Why is object property marked as uncovered by flow?

Checking the flow coverage of the following:

// @flow
import type { Map } from 'immutable';
import { fromJS } from 'immutable';

const formOptions: {
  foo: Map<string, *>,
} = {
  foo: fromJS({
    some: 'value',
  }),
};

It reports the fromJSpart as uncovered:

$ ./node_modules/.bin/flow coverage --json --pretty foo.js
{
  "expressions":{
    "covered_count":5,
    "uncovered_count":1,
    "uncovered_locs":[
      {
        "source":"/Users/jacob/Code/nova/manage-web/app/containers/ResendVerification/foo.js",
        "type":"SourceFile",
        "start":{"line":8,"column":8,"offset":141},
        "end":{"line":10,"column":4,"offset":173}
      }
    ]
  }
}

How should that be annotated to make sure it's fully covered?

Upvotes: 0

Views: 548

Answers (1)

sris
sris

Reputation: 4978

It's because fromJS returns any.

If a "properly typed" Map is constructed it's covered:

// @flow
// import type { Map } from 'immutable';
import { Map } from 'immutable';

const formOptions: {
  foo: Map<string, *>,
} = {
  foo: Map({
    some: 'value',
  }),
};

Upvotes: 1

Related Questions