Disjoint unions with exact types - poor inference of typeof undefined check
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I honestly dont know if Im right, but this one seems easily inferrable and I just cannot make it work. It might be a bug (cannot know that for sure) or maybe there is some reason why this is happening and Im just not aware of the problem in my code.
Would be greatly appreciated if somebody can clarify things up for me. From my point of view this should behave quite exactly the same as strict shapes example in the docs [here](https://flow.org/en/docs/types/unions/#toc-disjoint-unions-with-exact-types)
EDIT:// I got it to work (see below), but I have no idea whats the difference between those 2:
- `m.iwcs !== undefined` (working)
- `typeof m.iwcs !== 'undefined'` (not working)
Shouldnt they both just work? Also started testing this code branch with such
- `typeof m.iwcs === 'string'`
- `'iwcs' in m`
and they are not working too, which is rly odd
[Original problematic code](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgAeAUgMoDyAcmALxgDeAPmAFYDOcAdgFxjkBGLPAGMMYRgF902fGACSAdQDCpWg2YBLBMLa82GAE4bOAcwA04qZlwEAsnjZsAhiYJ0SFas0UqA3OmEufTAcJwM2PHtHFzcwAAoAWwdnV10wAEEDAycsAB4olLwAPgBKXkzsvI8qItpa+lQASAM8DABXA04wJOjUgDoEpxw4xN4CmJK6hlQwWbBGjSh4hL6tHUmGua25lvbOhlYOHjAyKj7Q8LxE1e02PrYcGA0MOIByAD1XkoBtAEYAXUmUm2c2B2xm22arQ6XQSENmEhKqAkQA)
[Working example](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCSA6gMIDKYAvGAN4A+YAlggMYDOAXGOxgE5MAdgHMw9AL6ZcBAB4ApcgHkActTqMAVuziDuigEYa8rDGMlT8YALJ527AIbCCNEhTFh5S5QG50rHbxgOPZ87Hg2do7OYAAUALa2Dk5cYACCfHz2WAA8EUl4AHwAlNzpmTmeKgXU1bSoAJB8eBgArnyCYAmRyQB0cfY4MfHceVFFNXQN9UxQsXE9LBxgAIRUNC2CACZ4UEJ4m+N1YMcnp43NbR0KKj3BoXjxC2zsPew4MEwYMQDkAHrfRQA2gBGAC6RV8p1Oknq51a7U6qGhRVQ4iAA)
Contributor guide
Assessment
This issue has not been assessed yet.