Repository navigation
perf: remove unneeded arguments copies, break type import cycles and restore TypeScript v3.4 types - #639
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #639 +/- ##
=======================================
Coverage 99.21% 99.22%
=======================================
Files 180 181 +1
Lines 5630 5688 +58
Branches 1297 1287 -10
=======================================
+ Hits 5586 5644 +58
Misses 44 44
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
A critical active finding remains because the common test suite references the ES2018-only AsyncGeneratorFunction type while compiling against ES2015 libraries, causing test compilation to fail before execution.
1 open issue
Review effort: Lite
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
…restore TypeScript v3.4 types
Performance
- arrSlice now uses _unwrapFunction("slice", ArrProto) rather than slicing its own arguments before calling slice (~16% faster in a V8 micro-benchmark and smaller). It still uses the value's own slice when present, but as it is now a const its name and length change
- createFnDeferredProxy, objExtend, deepExtend, the createCustomError base class call and the timer callback wrapper now pass their arguments object directly rather than copying it (objExtend ~29% faster). ES5 is the minimum runtime and every call has its own arguments object
- The arguments are still copied where they are kept or modified after the call returns (_createTimeoutWith and scheduleInterval for refresh()), with comments explaining why
Cyclic dependencies
- Move ICachedValue, ILazyValue, TimeoutOverrideFn, ClearTimeoutOverrideFn and TimeoutOverrideFuncs to helpers/types.ts, which has no imports, and re-export them from their original modules. This removes the type-level import cycle between cache, lazy, define, global, handler and timeout, without using import type (TypeScript v3.8)
Exported types now compile with TypeScript v3.4, as documented
- Add helpers/deep_types.ts: DeepPartial, DeepReadonly and DeepRequired now resolve arrays through new DeepPartialArray, DeepReadonlyArray and DeepRequiredArray interfaces, as a type alias can't reference itself as a type argument before v3.7. The resulting types are unchanged
- ObjDefinePropDescriptorMap is now Record<PropertyKey, ...>
- Add library-owned types for lib types that older compilers or an ES2015 lib don't provide:
- IAsyncGeneratorFunction, used by isAsyncGenerator
- IAsyncIterable and IAsyncIterator, used by isAsyncIterable. On TypeScript v4.3+ these are interchangeable with the native types. Older compilers using the ES2018 lib see any, so a value declared as a union with AsyncIterable is no longer narrowed on those versions
- IIdleDeadline, IIdleRequestOptions and IdleCallbackFn, used by RequestIdleCallback and scheduleIdleCallback
There was a problem hiding this comment.
🔵 Needs a closer look
The changes span public declarations and runtime wrappers across multiple TypeScript versions, library targets, and browser/worker environments, requiring compatibility validation beyond the available snapshot checks.
1 open issue
Review effort: Lite
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
There was a problem hiding this comment.
🔵 Needs a closer look
Defer because the compatibility change requires validating declarations, assignability, and API-extractor output across the supported TypeScript and library-version matrix, which this review snapshot cannot verify.
No open issues 🎉
1 resolved since last review
Review effort: Lite

Performance
Cyclic dependencies
Exported types now compile with TypeScript v3.4, as documented