facebook / facebook/flow

Non-exported, module-scoped values in a library definition are still importable

Open
#6,982 0 comments 2 reactions 0 assignees View on GitHub
declarations
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Let's say I have the following library definition:
```
declare module 'mod' {
declare class Foo {};
}
```
According to [the Flow docs](https://flow.org/en/docs/libdefs/creation/#toc-declaring-an-es-module), I shouldn't be able to import Foo in a source file:

> Note that you can also declare other things inside the body of the `declare module`, and those things will be scoped to the body of the `declare module` – **but they will not be exported from the module**.

Therefore I'd expect that the following source file would throw a Flow error:
```js
// @flow

import type { Foo } from 'mod';

let x: Foo;
```
If this isn't buggy behavior and I'm simply misinterpreting the docs, then what's the difference between what I've written in the libdef above and, say, `declare export class Foo {};` instead?

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.