Checks against an opaque type's subtype type fail to properly filter that type out
Open
Typing: opaque types
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Can't reproduce on try flow because this requires an opaque type and thus a different file.
```js
/* file1.js */
export opaque type foo: string = string;
/* file2.js */
import type { foo } from 'file1';
function bar(param: foo | number) {
if (typeof param === 'string') {
param = 42;
}
// param should now be a number no matter what
// with an opaque type this creates an error because `param` is still (incorrectly)
// `foo | number`, however there is no programatic way to check against `foo` in
// this case. Since all foo's are strings the above `if` should work.
param.toFixed(2);
}
```
flow 0.64.0
Contributor guide
Assessment
This issue has not been assessed yet.