Fix dependency order and observer registration by rbuckton · Pull Request #41253 · microsoft/TypeScript

@rbuckton

Fixes a dependency ordering issue in #40593 and correctly handles that PerformanceObserver's callback is called each time a mark or measure is recorded, not just once.

These issues were detected when running perf tests on another PR.

@rbuckton

weswigham

performance.mark(end);
}
performance.measure(name, start, end);
if (end = "__performance.measure-fix__") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... Should we have a lint for this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or a --strictBoolean (or --pedanticBoolean?) flag that requires all conditions be boolean (including !). It wouldn't catch if (f = true), but it also would mean you'd have to write a lot of if (obj !== null && obj !== undefined) instead of if (obj) because !!obj would also be a violation...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while (next = read()) seems like a sane pattern, so this feels more like a heuristic than a compiler error. Having said that, I would probably personally use such a mode, assuming it had a (totally reasonable) exception for !!expr.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, mostly just using = in an if without a reference to the assigned variable within the if. (Since I know we do this intentionally in relationship checking, but the difference there is we actually reference the checked variable)

amcasey

"corePublic.ts",
"core.ts",
"debug.ts",
"semver.ts",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a comment so it doesn't get alphabetized back?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should never be alphabetized, they are all order dependent.

@rbuckton rbuckton deleted the nativePerformanceHooks2 branch

October 26, 2020 19:56

@microsoft microsoft locked as resolved and limited conversation to collaborators

Oct 21, 2025