facebook / facebook/flow

Cannot use exact object type with [[call]]

Open
#6,705 0 comments 1 reaction 0 assignees View on GitHub
bug Typing: object model
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

```js
type LoggerType = {|
[[call]]: () => void,
+debug: () => void
|};

const createLogger = (): LoggerType => {
const log = () => {};

log.debug = () => {

};

return log;
};

```

https://flow.org/try/#0C4TwDgpgBAMg9gcwRATgFXNAvFA3gHwCgooBtUgYwEMAbGgXXoC4oAKASiiwD4oA3OAEsAJgBpiUANTCIAIwCuCFhy68BIwvgC+AbkKEKcAHYBnYFAooIVYBHhJUXNuxb3k6TKrwTDp8zUQnFR48XX0SAIQAOhkFBCDOENwJEgkwiStgeRQjKEi9XSA

Error:

```
13: return log;
^ Cannot return `log` because inexact function [1] is incompatible with exact `LoggerType` [2].
References:
7: const log = () => {};
^ [1]
6: const createLogger = (): LoggerType => {
^ [2]

```

Expected result:

I should be able to define exact object with [[call]] interface.

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.