facebook / facebook/flow

`typeof A` vs `Class<A>`

Đang mở
#1,652 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Needs docs
Ngôn ngữ chính
Rust
Star
22.3k
Fork
1.9k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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`?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.