facebook / facebook/flow

Consider dropping empty type parameter list with default params

Open
#4,857 0 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Currently if you have a type with a param that has a default:

```js
type Foo = {};
```

You are required to add `<>` even when you want to add that default:

```js
type Bar1 = Foo; // error
type Bar2 = Foo<>; // works
```

It's not been intuitive in my experience, and syntactically it's not obvious this is necessary.

In the AST, all this adds is an empty `TypeParameterInstantiation` inside of the existing `GenericTypeAnnotation`.

When resolving the generic, I'm wondering if Flow could treat the plain GenericTypeAnnotation as having a TypeParameterInstantiation when the targeted type doesn't require any type params to be provided

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.