Skip to content

Generics with default and $ExpectType value #919

@malthe

Description

@malthe

Consider the following example:

class Foo<T = number> {
    public bar: T;
}

declare const foo: Foo;

// $ExpectType Foo<number>
foo;

Should this be rendered instead as just Foo – ?

There's a situation that might motivate this further than just "it's simpler" which is that perhaps generics have been added to Foo but backwards compatibility is provided through the default type.

If a type is specified using just default types, should the tool drop those types from the output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions