-
-
Notifications
You must be signed in to change notification settings - Fork 601
Paths
: Add maxCircularDepth
option
#1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Paths
: Add maxCircularDepth
option
#1079
Conversation
@LaurynasGr Types like the following shouldn't be affected by type Test = {
foo: string;
bar: {
foo: string;
bar: {};
};
};
type P = Paths<Test, {maxCircularDepth: 0}>;
// ^? type P = 'foo' | 'bar' |
On second thought, I think this option is just going to be more confusing than helpful.
|
…lagged as circular
@som-sm sorted this one - was a simple Will respond to the other comment tomorrow with a real-world example where I need this specific option to stop VS Code from crashing without limiting myself to a very shallow depth with the general recursion depth option. |
@LaurynasGr Great, I'll try to give this a read sometime tomorrow then! |
@LaurynasGr Also, since type Test = {a: Test};
type P = Paths<Test, {maxRecursionDepth: 0}>;
// ^? type P = "a" Should depth // Current behaviour
type Test = {a: Test};
type P = Paths<Test, {maxCircularDepth: 0}>;
// ^? type P = "a" // Suggested behaviour
type Test = {a: Test};
type P = Paths<Test, {maxCircularDepth: 0}>;
// ^? type P = "a" | "a.a" |
@som-sm I think that having Whereas |
If this is related to
I answered it here #1079 (comment) In other words the whole point of this option is to detach it from I have this state type type SomeState = {
a: {
b: {
c: {
d: boolean;
e: string;
f: {
g: number;
h: boolean;
};
};
};
e: number;
};
connection: Connection;
something: string;
oneMoreThing: {
a: string;
b: {
c: string[];
d: {
e: string;
f: {
g: number;
h: boolean;
};
};
};
};
getSomething: (param?: string) => Promise<Something>;
// <....>
}; Note that the Now if I were to try to get type SomeStateKeys = Paths<SomeState>; my VS Code (running on Intel i9-13900k with 128GB RAM) will immediately choke and then after thinking for a good while, it will just give up and say "No, sorry mate, this is too much for me" The only solution I have right now is to limit the whole recursion to some arbitrary small number But the issue here is that I loose all of the state keys that I myself defined and still get large numbers of keys I do not care about rom the Now if I just use |
Makes sense—I was just concerned that it might cause confusion if But can you please add a note in the description, similar to Line 98 in ed8c987
|
@LaurynasGr Thanks for the detailed explanation! Haven't had a chance to properly review this PR yet, but it looks like type Test = [...Test[], string];
type P = Paths<Test, {maxCircularDepth: 0}>; ![]() |
Adds
maxCircularDepth
option toPaths