dudykr / stc

Speedy TypeScript type checker
https://stc.dudy.dev
Apache License 2.0
5.77k stars 166 forks source link

Check preemptive circulation reference to prevent overflow #431

Open sunrabbit123 opened 1 year ago

sunrabbit123 commented 1 year ago
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 commented 1 year ago

checker.ts search isDeeplyNestedType