facebook / facebook/flow

`typeof A` vs `Class<A>`

オープン
#1,652 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
Needs docs
主要言語
Rust
スター
22.3k
フォーク
1.9k
PR マージ指標
30日以内にマージされた PR はありません

説明

Ran into this one a little bit ago while working on a Bluebird lib:

According to the documentation:

> Given a type T representing instances of a class C, the type Class is the type of the class C.

So it would stand to reason that a definition like this should work:

``` js
declare module 'bluebird' {
class BluebirdPromise {
// ....
}
declare var exports: Class;
}
```

Yet this throws all kinds of errors about polymorphic types not equaling class types.

The solution is to export:

``` js
declare var exports: typeof BluebirdPromise;
```

When should one use `Class` vs `typeof`?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。