facebook / facebook/flow

opaque flow string type dropped in for-in loop

Open
#5,777 1 comment 0 reactions 0 assignees View on GitHub
Typing: opaque types
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Can't reproduce with try flow because I need an import :(

##### file1.js

```js
export opaque type T: string = string;
```

##### file2.js

```js
import type { T } from 'file1';

class Foo {
things: { [T]: string };

method() {
for (const key in this.things) {
this.things[key]; // Error: [flow] string (This type is incompatible with T)
}
}
```

I'd expect the key type to carry through since it's compatible with `string`. I could cast it back to type `T` via an exported function in `file1.js`, but that seems unnecessary.

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.