-
Notifications
You must be signed in to change notification settings - Fork 2
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
"Type instantiation is excessively deep" for Element
as a predicant
#6
Comments
I think we can find if a union has many constituents (say more than 15) using something like this... namespace U {
type HasManyConstituents<U, L = 15> =
U extends never ? false :
L extends 0 ? true :
HasManyConstituents<U.Pop<U>, N.Decrement<L>>
} And later we could even take the upper limit from some "options interface" via module augumentation instead of keeping it a hardcoded 15. Also I wonder if it's possible make sense to show only top 15 keys as completion but also have a |
Another much greater possibility is that (afair) we compute index operator deeply (and eagerly) and |
Yep, looks like it's because of recursive definition... import { p, pa } from "@sthir/predicate"
interface MyElement {
parentElement: MyElement
}
pa({} as MyElement, p())
// ~~~
// Type instantiation is excessively deep and possibly infinite.(2589) In that case let's do this...
|
Element
as a predicant
I'm too lazy to rewrite the types right now to make index not compute eagerly, so instead in case of recursive types we stop when we come across a type we've already seen and with that we fixed #8 This comes with a little downside that instead of being able to write But even after fixing #8 the code in the description takes too long (and probably also shows the error didn't wait to see it) that's probably because as we're still computing (deep) index eagerly and Now to fix We can also try another solution of checking when a type is huge and making users break the index operator at every level ( |
e4dfae5 — Pretty weird even with |
Ah maybe |
Not sure why it's happening, possibly because
Element
has many keys... If that's the reason then we need to figure out a test for type with many keys (or union with many constituents) and then don't compute index operator for them (which means now.parentNode
,.children
, etc won't show up in the intellisense completetion) and only validate it.The text was updated successfully, but these errors were encountered: