Skip to content

Recursive types limit? #26001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maxime1992 opened this issue Jul 27, 2018 · 0 comments
Closed

Recursive types limit? #26001

maxime1992 opened this issue Jul 27, 2018 · 0 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@maxime1992
Copy link

TypeScript Version: 2.9.2

Search Terms:

  • recursive type
  • recursive limit

Code

export type RouteData<Data = {}> = {
  propA: boolean;
} & Data;

export interface Route<Data = {}> {
  data?: RouteData<Data>;
  children?: Route<RouteData<Data>>[];
}

const routes: Route[] = [
  {
    data: { propA: true }, // !!! put a number here and there'll be an ERROR !!!
    children: [
      {
        data: { propA: true }, // !!! put a number here and there'll be an ERROR !!!
        children: [
          {
            data: { propA: true }, // !!! put a number here and there'll be an ERROR !!!
            children: [
              {
                data: { propA: true }, // !!! put a number here and there'll be an ERROR !!!
                children: [
                  {
                    data: {
                      propA: 3, // this one's just fine
                    },
                  },
                ],
              },
            ],
          },
        ],
      },
    ],
  },
];

Expected behavior:
Recursive should be working after 2 or 3 levels deep?

Actual behavior:
The 3rd or 4th level of recursion is not working correctly and is probably inferring a type any.

That said, within VSC when I hover the property that should error and doesn't, the type displayed is the right one:
image

Playground Link: Playground repro

Related Issues:

Might eventually be related to #25860 or #23897 but I don't think it's the exact same case.

@mhegazy mhegazy added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

3 participants