Closed
Description
Track Source and Target Stack Depths Separately
- Started around convo on Negative cases of getNarrowedType that match the exact type should be filtered out, even when generic #45205, Track source and target relationship stack depth seperately, only increase on change in value #41821 is the "better" fix.
- Put up some changes to the second pull request.
- Still waiting for DT results to come back.
- Changed the implementation to track whether or not
isRelatedTo
is diving into the left or right side. - Track source and target relationship stack depth seperately, only increase on change in value #41821 (comment)
- Lots of types have constraints and we have to "drill in" to constraints to see if the constraint is related to the target type.
- Those really shouldn't count towards another level of comparisons when it comes to the recursion limiter - otherwise we'll often incorrectly say the types are too deep to continue comparing.
- Similar behavior occurs for union types because unions add another layer of comparisons.
- Perf is also improved - a 1.5% improvement in Material UI.
- Feels like there is some strangeness around conditional types.
Array.prototype.at
Returning undefined
- Can still index outside the range, just also works with negative indexes.
- Could make that work on tuples, but need more special support.
- Or, could just bake a hack in for tuples.
- ...unless you have rests and spreads!
- ...unless those are front-loaded! (e.g.
[...some, ...stuff, 123, true, 'a'].at(-1)
could returnstring
)
- ...unless those are front-loaded! (e.g.
- ...unless you have rests and spreads!
- Unclear if we would want to get into the domain of adding type notation support for it.
- We're fans of making sure this thing has
undefined
in the return type. - Do we need to have the special tuple support before we ship this?
- Possibly.
- Seems strange - in Python, experience was using regular arrays, and
-1
was the argument that was passed in 99% of the time. - 2 things we should do
- Ship the thing that returns
T | undefined
inlib.d.ts
. - Bake in some support for negative indexes when we know better.
- Ship the thing that returns