Repository navigation
Compile event-loop metrics, predicate-narrowed catch bindings and other wrapper-reachable gaps - #1433
Merged
ctate merged 4 commits intoOct 20, 2026
Conversation
…er wrapper-reachable gaps Once generic wrappers compile (#1413), the code behind them is reachable. This closes the general gaps found there: - performance.eventLoopUtilization() and monitorEventLoopDelay()'s IntervalHistogram (enable, disable, reset, percentile and the min, max, mean, stddev, count and exceeds readings), under the fallback declarations and @types/node. A new runtime unit, scr_perf_loop.c, links only for programs that read them (the perfLoop feature): an unref'd sampling interval records into HdrHistogram-shaped buckets, and utilization measures active time as the main thread's CPU time since the loop started. - Catch bindings narrowed by a user type predicate or an assertion read their members through the checked-dynamic value. - `??` with a function default of a different signature takes the optional callback's own function type and adapts the default. - Optional calls on interface-typed receivers dispatch like the plain protocol call. - `any` parameters of function declarations and spelled function types are checked-dynamic slots, and a generic instantiated at `any` takes `unknown` there. - `'key' in err` on Error receivers answers from the declaring subclasses. - Object.entries over a generic record resolves `keyof T extends never ? unknown : T[keyof T]` through the binding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Inside a generic body Object.entries(t) over T extends Record<string, unknown> types its values 'keyof T extends never ? unknown : T[keyof T]'. An instance whose T maps to the checked-dynamic value now reads both branches as unknown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 20, 2026
… 'in' keys, event-loop metrics in libraries - monitorEventLoopDelay is lowered from the builtin call dispatch, by module and member, so aliased named imports, namespace members and destructured requires all reach it. Shorthand and possibly undefined resolutions take Node's default. - The runtime validates the resolution as Node does (an integer of at least 1) and throws a catchable RangeError with ERR_OUT_OF_RANGE. - `'stack' in err` and Object.prototype's keys are true for every Error. The declared-member fold applies only to keys some program class declares and that built-in errors don't carry in runtime slots; other keys stay fenced. - Library mode's async_free gate refuses the event-loop metrics, which library links leave out. They join the perf_hooks fence family.
cramforce
added a commit
that referenced
this pull request
Oct 20, 2026
Brings main in through the already-resolved stack merge (f4c6441: main merged into #1413 and #1433). Main split lower-exprs.ts into expressions/*: the review follow-up's Error 'in' keys (own 'stack', Object.prototype keys, BUILTIN_ERROR_SLOT_KEYS gating the declared-member fold) move to expressions/relational.ts, and the perfLoop feature keeps main's rule table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cramforce
added a commit
that referenced
this pull request
Oct 20, 2026
…ance-error-expando Brings main into the stack (thrown-value fixes, the lower-exprs split, the checker helper removal). This branch's lower-exprs.ts hunks move to expressions/relational.ts (`in` on errors), expressions/property-access.ts (stdlib members of a structurally narrowed catch binding) and expressions/narrowing.ts (assertions on an `any` catch binding); the `this` blame, the `any` catch-binding read and the setPrototypeOf feature test stay in lower-exprs.ts. The Error member read keeps both this branch's intersection members and #1433's subclass-owned `code`. Corpus 6407 and 6408 renumber to 6412 and 6413 (main has its own 6407 and 6408), and 6414 adds the thrown-value round trip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cramforce
added a commit
that referenced
this pull request
Oct 20, 2026
…expando Brings in #1433's review follow-up (now merged into #1413). In `key in err`, own `stack` and Object.prototype keys answer true, keys built-in errors keep outside their class fields stay fenced, and every other key keeps this branch's answer: a declaring subclass or a runtime-set own property. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1413 (variadic generic wrappers). Once wrapper bodies compile, the code behind them becomes reachable, and with it a set of independent gaps. This PR closes the general ones.
Summary
performance.eventLoopUtilization()(no-argument, one-argument and two-argument difference forms) andmonitorEventLoopDelay()(anIntervalHistogramwithenable,disable,reset,percentile, and themin,max,mean,stddev,countandexceedsreadings). These work under the shipped fallback declarations and under a project's own@types/node.scr_perf_loop.c. The unit samples on an unref'd interval at the requested resolution and records each interval in nanoseconds, like Node'sELDHistogram. Values land in HdrHistogram-shaped buckets (three significant figures), so the readings are the bucket values Node reports. An empty histogram readsminas 2^63−1 andmean/stddevasNaN, like Node.percentilevalidates Node's range and throwsERR_OUT_OF_RANGE.mainmarks the loop's start only in programs that read the metric.perfLoop.if (isErrorLike(e)) e.message,TypeError & { code: unknown }) read their members through the checked-dynamic value, as JavaScript reads them. Before, these reads were SC1063.??with a function default of a different signature (opts.tags ?? (() => ({}))). The result is the callback's own function type, and the default adapts into it. Before, the checker's merged signature caused SC1090 and would have lost the callback's result shape.tracer.scope().active()?.addTags(tags),s?.m(x)) dispatch like the non-optional protocol call. Before, these were SC1090.anyin TypeScript function types: a parameter typedany(optional or not) of a function declaration or a spelled function type is the checked-dynamic slot, as ananybinding already is. A generic instantiated atany(for example a type argument inferred from an untyped forwarding call such astracer.trace(name, () => fn.apply(this, args))) takesunknownfor that parameter or result.'key' in erronErrorreceivers for keys other thancode,messageandname. The answer istruewhen the static class declares the key, otherwise a runtime class test over the subclasses that declare it.Object.entriesover a generic record parameter:keyof T extends never ? unknown : T[keyof T]resolves through the binding. Fields of different scalar types map to their union.Forms not covered keep their refusals:
Pick<SomeClass, "method">record members still don't accept class instances. Mapping them to the class would refuse object-literal values that compile today.any(or otherwise differs in its native ABI).Evidence
??function defaults), 6392 (optional protocol calls), 6393 (anyparameters), 6394 (inon Error subclasses), 6395 (genericObject.entries), 6396 (generic method atany), 6397 (event-loop metrics).@types/nodefixturesevent-loop-metrics.tsandtimeout-type.ts, run bytests/harness/project-config.test.ts.scripts/zero-cost-gate.mjs, bench + self-hosted compiler + all corpus entries, sharded over three sandboxes):dynAsync. It is now its ownperfLoopfeature, linked only where used.T[keyof T]union widened a literal-key read in2550-generics-keyof-pick.anyparameter rule changed two object literals ofany-taking lambdas and methods (checked-callback-options,5197); it now covers only function declarations and spelled function types.pnpm manifest,pnpm node-compat,pnpm node-compat:check, lint, format,pnpm test:ts7 --baselines-only, diagnostics, frontend unit tests, and the self-hosted IR build all pass. The compatibility diff marksperformance.eventLoopUtilization,monitorEventLoopDelayand four Histogram methods partial, with the new tests as evidence.🤖 Generated with Claude Code