Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

4.6.2 regression: Type instantiation is excessively deep and possibly infinite.Β #48552

Copy link
Copy link
@seansfkelley

Description

@seansfkelley
Issue body actions

Bug Report

πŸ”Ž Search Terms

recursive conditional types

πŸ•— Version & Regression Information

  • This changed between versions 4.5.5 and 4.6.2

⏯ Playground Link

Playground Link

πŸ’» Code

type Query<T> = {
  [P in DeepKeys<T>]?: string;
};

type Primitive =
	| null
	| undefined
	| string
	| number
	| boolean
	| symbol
	| bigint;

type DeepKeys<T> = T extends Primitive
  ? never
  :
      | (keyof T & string)
      | {
          [P in keyof T & string]: T[P] extends (infer Inner)[]
            ? `${P}.${DeepKeys<Inner>}`
            : T[P] extends object
            ? `${P}.${DeepKeys<T[P]>}`
            : P;
        }[keyof T & string];

πŸ™ Actual behavior

Type instantiation is excessively deep and possibly infinite. at the ${P}.${DeepKeys<T[P]>} snippet.

πŸ™‚ Expected behavior

No error. Type properly resolves to dot-notation keys of input object.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScript

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.