Skip to content

Consider dropping empty type parameter list with default params #4857

@jamiebuilds

Description

@jamiebuilds

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

type Foo<T = boolean> = {};

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions