stc icon indicating copy to clipboard operation
stc copied to clipboard

Check preemptive circulation reference to prevent overflow

Open sunrabbit123 opened this issue 2 years ago • 1 comments

type NonOptionalKeys<T> = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T];
type Child<T> = { [P in NonOptionalKeys<T>]: T[P] }

export interface ListWidget {
    "type": "list",
    "minimum_count": number,
    "maximum_count": number,
    "collapsable"?: boolean, //default to false, means all expanded
    "each": Child<ListWidget>;
}

type ListChild = Child<ListWidget>
declare let x: ListChild;
x.type;

x should be any, Because Child<ListWidget> Overflow caused by circular reference

sunrabbit123 avatar Dec 21 '22 08:12 sunrabbit123

checker.ts search isDeeplyNestedType

sunrabbit123 avatar Dec 29 '22 16:12 sunrabbit123