Skip to content

Recursive type references are still disallowed in type parameter defaults #34534

@falsandtru

Description

@falsandtru

@ahejlsberg

TypeScript Version: master

Search Terms:

Code

type Tree<T, U extends Tree<T>[] = Tree<T>[]> = [T, U];

Expected behavior:
pass
Actual behavior:

$ node built/local/tsc --noEmit index.ts
index.ts:1:36 - error TS2716: Type parameter 'U' has a circular default.

1 type Tree<T, U extends Tree<T>[] = Tree<T>[]> = [T, U];
                                     ~~~~~~~~~


Found 1 error.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    UnactionableThere isn't something we can do with this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions