Skip to content

Type of property circularly references itself in mapped type #9

@Newbie012

Description

@Newbie012

The issue

Given the following code:

import { getByPath } from 'dot-path-value';

type Recursive = {
  a: string;
  r: Recursive;
};

function x(type: Recursive) {
  getByPath(type, '');
  ~~~~~~~~~~~~
}

we get the following error:

Type of property 'r' circularly references itself in mapped type
'{ [K in //keyof Recursive]-?: PathConcat<K & string, Recursive[K]>; }'.(2615)

which makes sense why it would not print until infinity (or at the max TS iterations).

See reproduction

Suggestion

Don't try to infer the fields of the recursive type, or allow inference for only one level deep.

BTW, really cool library, thanks for sharing 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions