Skip to content

Non-exported recursive type alias is inlined until it falls back to any in declarationsΒ #58696

Open
@dragomirtitian

Description

@dragomirtitian

πŸ”Ž Search Terms

declarations recursive types

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried (before 4.4 it was either a stack overflow crash or an error on the recursive type)

⏯ Playground Link

Playground Link

πŸ’» Code

// @declaration: true
// @filename: utils.ts 

type Recursive<T>  =  T extends Array<infer V>? Recursive<V>: T;

export const f = <T>(): Recursive<T> => { return null! } 

// @filename: index.ts 
import { f } from './utils';
export const a = f;

πŸ™ Actual behavior

In declarations, the type for a is printed as a: () => T extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? any : V : V : V : V : V : V : V : V : V : V : T;

πŸ™‚ Expected behavior

Recursive can't be represented without falling back to any (as seen above) so it should just be an error instead of silently to any

Additional information about the issue

Related to #55832

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions