facebook / facebook/flow

Checking initialization not working with module pattern literals

Open
#3,864 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Hi everyone,

I have the following simple code. Unfortunately flow doesn't recognize the initialization of the variable (I use nuclide and atom) inside the testMethod. So the last line complains "string - This type is incompatible with uninitialized variable" which is not correct because it is getting initialized in the testMethod before. This is a bug, isn't it?

Best,
Chris

```js
var Module = (function () {
var anotherMember : string;

var testMethod = function () {
anotherMember = "initialize123";

};

return {
testMethod: testMethod,
anotherMember: anotherMember

};

})();

Module.testMethod();
Module.anotherMember = "changeValue";
```

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.