Flow: Flow's linter complains that JSON files are untyped

Created on 1 Feb 2018  路  6Comments  路  Source: facebook/flow

Flow's linter is telling me to add // @flow to a JSON file 馃槵

Warning: app/server/helpers/environment.js:2
  2: import { version } from '../../../package.json';
              ^^^^^^^ untyped-import: Importing from an untyped module makes it `any` and is not safe! Did you mean to add `// @flow` to the top of `../../../package.json`?

Is this a bug? I would imagine all JSON files are 100% inferable and therefore could be treated as typed.

bug

All 6 comments

+1

Any update on this? Is there a solution?

Is this still an issue on v0.70? I tried to repo unsuccessfully.

+1

Flow is still complaining about it. My version: "flow-bin": "^0.74.0".

_Importing from an untyped module makes it any and is not safe! Did you mean to add // @flow to the top of ../catalog.json? (untyped-import)_

I find it weird that it's complaining-- perhaps some configuration on your .flowconfig? I tried to repro real quick and the following gives me no errors on 0.74.0:

// @flow

import {c} from './test.json'
var d = c';

The type inference part is known and has been discussed before on https://github.com/facebook/flow/issues/4596


Edit: nvm, my linter was misconfigured. Yeah this is a bug, the linter shouldn't complain about this with json files.

Any chance to get this ticket prioritized? It seems something trivial to fix.

Was this page helpful?
0 / 5 - 0 ratings