Skip to content

Version 3.4-dev breaks recursive types #30188

@millsp

Description

@millsp

TypeScript Version: 3.4.0-dev.20190302

Search Terms: recursive types

screenshot from 2019-03-04 16-09-21

I recently published an article about how to create types for curry and ramda. Quite a few people are excited and waiting for me to add these types to DefinitelyTyped. But I can't pass the lint tests yet.

To create these (curry) types, I detail how I make use of recursive types. But TS 3.4.0-dev.20190302 is indeed breaking these types. In the latest stable version (3.3.3333) warnings arise (only) when we recurse more than 45 times. A recursive type then returns any if the limit is exceeded (which is nice).

But in TS 3.4.0-dev.20190302 it appears that "Type instantiation is excessively deep and possibly infinite", which is a breaking behaviour. But in fact it is only possibly infinite, and this is why the previous behaviour should be preferred. any could just be returned anytime that limit has been exceeded, thus stopping the recursion condition.

However, recursive types seem to break only when they are nested. Any idea why @ahejlsberg ?
By breaking this feature, we cannot expect complex types for curry and other tools from ramda.

Code
Article: https://medium.freecodecamp.org/typescript-curry-ramda-types-f747e99744ab
Repo : https://github.com/pirix-gh/medium/blob/master/types-curry-ramda/src/index.ts

Expected behavior:
Updates should not have breaking behaviors

Actual behavior:
Breaking behavior on recursive types

Playground Link:

Related Issues:
#29511

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions