Repository navigation
refactor(core): share op prototypes and keep the es5 bundles es5 - #352
Merged
Merged
Conversation
nev21
commented
Oct 24, 2026
Contributor
- Build the to, is, has, deep, own, nested, strictly and numeric op tables once and share one prototype per table, instead of redefining 30 to 50 getters on every chain step. IAssertScopeFuncDef moves out of IAssertInst.ts into its own file for the shared tables to use.
- The rebuilt tables also put equal, equals and eq on to and add Chai's at, so expect(5).to.be.at.least(5) works.
- Replace bare Symbol.iterator and Error.captureStackTrace uses with ts-utils helpers or casts so the es5 bundles stay es5, and print accessor properties as [Getter] instead of calling them.
- The default config sets timeout, slow and retries to 2000, 75 and 0 for the suite runner.
nev21
enabled auto-merge (squash)
October 24, 2026 19:40
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #352 +/- ##
==========================================
+ Coverage 95.26% 95.59% +0.32%
==========================================
Files 139 141 +2
Lines 6404 6471 +67
Branches 1640 1696 +56
==========================================
+ Hits 6101 6186 +85
+ Misses 303 285 -18
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Getter-safe formatting remains incomplete, and prototype caching regresses support for frozen and mutable custom definition tables.
3 open issues
1 file not reviewed
common/config/rush/npm-shrinkwrap.json: Generated file
What changed in this PR
This PR reduces assertion-chain setup work by sharing operation tables and prototypes across tripwire instances. It also expands fluent assertion syntax and improves compatibility and formatting behavior.
Changes:
- Cache operation definitions and prototypes, and extract their shared interface.
- Add direct
toequality assertions and Chai-styleatchaining. - Update symbol and stack handling, guard accessor formatting, and add suite-runner defaults.
| File | Description |
|---|---|
| core/test/src/support/validate.symbol.test.ts | Check symbol support and iterator identity. |
| core/test/src/assert/expect.to.test.ts | Test decorative at chaining. |
| core/test/src/assert/deepEqual.test.ts | Remove an unused test variable. |
| core/test/src/assert/context.test.ts | Refresh copyright and final newline. |
| core/test/src/assert/addAssertFuncs.test.ts | Remove an unused test interface. |
| core/src/internal/parseStack.ts | Update constant import and stack-limit typing. |
| core/src/internal/formatManager.ts | Reorganize imports and use shared constants. |
| core/src/internal/captureStack.ts | Cast nonstandard Error properties. |
| core/src/internal/_defaultFormatters.ts | Add descriptor checks for getter formatting. |
| core/src/index.ts | Update imports for extracted definition types. |
| core/src/config/defaultConfig.ts | Add timeout, slow, and retry defaults. |
| core/src/config/config.ts | Reorder imports. |
| core/src/assert/ops/toOp.ts | Share definitions and add equality aliases. |
| core/src/assert/ops/strictlyOp.ts | Share strict operation tables. |
| core/src/assert/ops/propertyResultOp.ts | Import extracted definition types. |
| core/src/assert/ops/ownOp.ts | Share tables and use iterator-symbol helpers. |
| core/src/assert/ops/numericOp.ts | Share numeric operation definitions. |
| core/src/assert/ops/nestedOp.ts | Share nested operation tables. |
| core/src/assert/ops/isOp.ts | Share definitions and add at. |
| core/src/assert/ops/includeOp.ts | Update definition-type imports and naming. |
| core/src/assert/ops/hasOp.ts | Share tables and use iterator-symbol helpers. |
| core/src/assert/ops/deepOp.ts | Share deep operation definitions. |
| core/src/assert/ops/changeResultOp.ts | Import extracted definition types. |
| core/src/assert/ops/allOp.ts | Update definition and constant imports. |
| core/src/assert/internal/_instCreator.ts | Add prototype tagging and scoped instance creation. |
| core/src/assert/internal/_blockLength.ts | Use the shared constants path. |
| core/src/assert/internal/_AssertInstCore.ts | Expose the empty assertion prototype internally. |
| core/src/assert/internal/_addAssertInstFuncs.ts | Import extracted definition types. |
| core/src/assert/interface/ops/IToOp.ts | Expose direct equality operations in types. |
| core/src/assert/interface/ops/IIsOp.ts | Declare and document at. |
| core/src/assert/interface/IScopeContext.ts | Reorder properties and their documentation. |
| core/src/assert/interface/IAssertScopeFuncDef.ts | Add the standalone operation-definition interface. |
| core/src/assert/interface/IAssertScope.ts | Use the extracted definition type. |
| core/src/assert/interface/funcs/IncludeFn.ts | Refresh copyright and final newline. |
| core/src/assert/funcs/valuesFunc.ts | Use the shared constants path. |
| core/src/assert/funcs/throws.ts | Rename the internal enum and clarify nullable messages. |
| core/src/assert/funcs/members.ts | Reorder imports. |
| core/src/assert/funcs/isSealed.ts | Clean up imports and file metadata. |
| core/src/assert/funcs/isFrozen.ts | Clean up imports and file metadata. |
| core/src/assert/funcs/isExtensible.ts | Clean up imports and file metadata. |
| core/src/assert/funcs/hasProperty.ts | Reorder imports. |
| core/src/assert/assertScope.ts | Cache prototypes for default operation creation. |
| core/src/assert/assertInst.ts | Use extracted definition types. |
| core/src/assert/adapters/evalAdapter.ts | Clean up imports and copyright. |
| common/config/rush/npm-shrinkwrap.json | Refresh transitive dependency versions. |
Review effort: Balanced
nevware21-bot
previously approved these changes
Oct 24, 2026
nevware21-bot
left a comment
Contributor
There was a problem hiding this comment.
Approved by nevware21-bot
nev21
force-pushed
the
nev21/SharedOps
branch
from
October 24, 2026 21:36
dd06c4e to
399f270
Compare
- Build the to, is, has, deep, own, nested, strictly and numeric op tables once and share one prototype per table, instead of redefining 30 to 50 getters on every chain step. IAssertScopeFuncDef moves out of IAssertInst.ts into its own file for the shared tables to use. - The rebuilt tables also put equal, equals and eq on to and add Chai's at, so expect(5).to.be.at.least(5) works. - Replace bare Symbol.iterator and Error.captureStackTrace uses with ts-utils helpers or casts so the es5 bundles stay es5, and print accessor properties as [Getter] instead of calling them. - The default config sets timeout, slow and retries to 2000, 75 and 0 for the suite runner. fix(core): wire has.own to the own operation table and harden the shared operation prototypes - Point has.own at hasOwnOp, which has existed since the initial prototype but was never reached: has.own went to ownOp, so the own forms of all, any, nested, lengthOf and sizeOf were unreachable from the has chain. - Complete the hasOwnOp table so it is a superset of IOwnOp, binding the same ownIncludeOp and own property functions ownOp binds, setting the OWN context flag as ownOp does, and dropping the meaningless has.own.own entry. - Add IHasOwnOp (@SInCE 0.2.0), IOwnOp plus the own forms of all, any, nested, lengthOf and sizeOf, type IHasOp.own with it and export it from the package index; every previously valid has.own expression still type-checks. - createOperation skips caching the shared prototype on a frozen, sealed or otherwise non-extensible definition table instead of throwing a TypeError, and its doc states that a table is bound on first use and treated as immutable afterwards. - Collect object keys for formatting with objKeys rather than objForEachKey, which read every value and so invoked getters before the [Getter] guard could decline to; a throwing getter no longer aborts the formatter. - Keep the prototype self-reference guard in _isAccessorProp, with a comment that some older runtimes return the object itself from getPrototypeOf at the top of the chain. - Tests: own and inherited getters are described as [Getter] and never invoked; frozen and sealed tables create working operations without anything written onto them, a mutable table shares one prototype, a custom handler creator takes the per-instance path, and a caller-supplied object is decorated in place; has.own refuses inherited properties for property and include and offers all, any, nested, lengthOf and sizeOf; hasOp, hasOwnOp and numericOp are exercised directly; deep.strictly equal, not, true and false; the change result's value chain and its non-numeric delta refusals.
nev21
force-pushed
the
nev21/SharedOps
branch
from
October 24, 2026 22:04
399f270 to
99ad6b5
Compare
nevware21-bot
approved these changes
Oct 24, 2026
nevware21-bot
left a comment
Contributor
There was a problem hiding this comment.
Approved by nevware21-bot
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.
