facebook / facebook/flow

Error message when trying to call a class as a function is confusing

Open
#8,062 0 comments 11 reactions 1 assignee Claimed by @SamChou19815 View on GitHub
discussion error messages
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

The following code:
```javascript
class Foo {};
const foo = Foo();
```
produces the following error message:
```
2: const foo = Foo();
^ Cannot call `Foo` because a call signature declaring the expected parameter / return type is missing in statics of `Foo` [1].
References:
1: class Foo {};
^ [1]
```
It would be clearer if error message stated that `Foo` is a constructor and must be called using `new` (or something to that effect).

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.