glutinum-org / cli

https://glutinum.net/
59 stars 6 forks source link

Revisit how TypeReference is handled #69

Open MangelMaxime opened 7 months ago

MangelMaxime commented 7 months ago

Right now, we are making some optimistic decision or early decision to work around recursive types.

This is because Glutinum is trying to get a full view of the AST, meaning that code like below with result in a maximum call stack because MyClass tries to get AST of MyUnion which tries to get the AST of MyClass and so on.

export declare class MyClass {
    contains(otherBoundsOrLatLng: MyUnion | string): boolean;
}

export type MyUnion = MyClass | string;

I think we should find a way to compute a unique ID for a type and store that type AST in a dictionary. This way, when handling TypeReference we should hopefully be able to look into that dictionary for the information we need and not try to recursively handle the types.

Places impacted by this refactor (non exhaustive):