Broken Autocomplete — Module Definitions: Polymorphic Type Aliases
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**TL;DR:** If an export is an object and a value has a type which is polymorphic, type inference breaks ☹️
___
Took me a while to figure out why [my flow-typed library](https://github.com/flowtype/flow-typed/blob/master/definitions/npm/styled-components_v2.x.x/flow_v0.42.x-/styled-components_v2.x.x.js) was not providing autocomplete and type-a-head results & I finally narrowed it down to polymorphic type aliases...
It seems to apply to all library type export definitions (possibly more), flow-typed or not.
___
```js
// ./flowtype-definitions/
declare module 'foo-module' {
declare type Bar = { quux: 'quux' }
declare type Baz = { quuux: 'quuux' }
declare module.exports: {
bar: Bar,
baz: Baz,
}
}
```
```js
// ./foo.js
import foo from 'foo-module'
foo.ba // (See attached screenshots)
```
___
_So far so good, we see both results..._

_Huh...no autocomplete or type for bar?_

_But ``baz`` works!_

Contributor guide
Assessment
This issue has not been assessed yet.