-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesHelp WantedYou can do thisYou can do this
Milestone
Description
π 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
π» 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesHelp WantedYou can do thisYou can do this