facebook / facebook/flow

Flow does not recognize property exported using export * as X from 'a'

Open
#6,234 0 comments 0 reactions 0 assignees View on GitHub
bug Typing: object model
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Test case:
```
// my-module.js
export default {
a: 1,
b: 2,
};

// modules.js
export type Modules = {
MyModule: { a: number, b: number }
};
export * as MyModule from './my-module';

// app.js
import * as modules from './modules';

const modulesCopy: Modules = Object.keys(modules).reduce((prev, moduleKey: $Keys) => {
return {
...prev,
// will give an error, Error:(61, 34) Cannot get `modules[moduleKey]` because property `MyModule` is missing in module `./modules` [1].
[moduleKey]: modules[moduleKey],
};
});
```

if I remove the type from `moduleKey`, it simples gives the following error:
```
Error:(57, 47) Cannot assign `Object.keys(...).reduce(...)` to `modulesCopy` because property `MyModule` is missing in object literal [1] but exists in `Modules ` [2].
```

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.