Skip to content

Breaking change for default parameters #29803

@Akxe

Description

@Akxe

TypeScript Version: 3.3.1

Search Terms:
Type parameter defaults can only reference previously declared type parameters.

Code

interface INamed {
    name: string;
}

class Person<T extends INamed = T> {
    //  ...
}

Intended use
I wanted to use T as shorthand for INamed, because it may get very long and unless you make a separate type variable, there wasn't an easy and clean way to do it.

Previous behavior:
no error

Current behavior:
Error: Type parameter defaults can only reference previously declared type parameters.

Playground Link:
Demo

Related Issues:
Not really found anything...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions