facebook / facebook/flow

Any way to make Flow strongly type an imported JSON file?

Open
#6,851 0 comments 17 reactions 0 assignees View on GitHub
feature request
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

When I do `import foo from 'foo.json'` the foo object has `any` type.

From #5150 I realise there is a way to declare the type of a JSON file by writing a libdef for it. But as the JSON file is config local to my project, I’d rather it act as its own definition, and have Flow be aware of its entire structure (treated preferably as a deeply immutable object with literal-typed values). So I can just import JSON into a JS module and have full autocompletion and type checking.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.