facebook / facebook/flow

Abstract methods

Đang mở
#2,961 1 bình luận 10 reaction 0 người được giao Xem trên GitHub
feature request
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ả

I have the following use case for abstract methods:

```js
declare class RelayMutation {
getMutation(): T;
getVariables(): $Exact<$GraphqlVars>;
}

class MyMutation extends RelayMutation {
getMutation(): {
return Relay.QL`mutation {likeUser}`; // expects {userID: string}
}

getVariables() {
return {id: '123'}; // error: field `userID` not found
}
}
```

`$GraphqlVars` extracts variables-object from graphql-query. I want Flow to check that `getVariables()` returns object that query from `getMutation()` expects. If I define method `getVariables`, then Flow checks object shape. But if `MyMutation#getVariables` is not defined, Flow will not complain.

Are there any plans for abstract methods in declarations? I might try to help to implement that.

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.