facebook / facebook/flow

[libdef] declare module auto-export is too much magic

未關閉
#3,119 3 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視
declarations
主要語言
Rust
星號
22.3k
分支
1.9k
PR 合併指標
30 天內沒有已合併 PR

描述

I see this all the time... people (including me initially) are really confused about the export handling of `declare module`.

If I do this:

```
declare module 'mylib' {
declare type Foo = { bar: 'test' };
}
```

The type `Foo` will automatically be exported.
As soon as I use `declare module.exports: ...`, `declare var exports: ...` or `export type Other = ....`, flow will only export entities via the export mechanics.

IMO it should by default assume private scope and only export entities, which are explicitly exported (like ES6 or Node CJS do).

It causes a lot of confusion whenever someone submits `flow-typed` libdefs... people tend to use namespaces inside `declare module`, although they are using `declare module.exports` and just make libdefs hard to read (because of this `$npm$whatever$MyType` naming).

I wonder if the default behavior will be changed in the future?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。