util: canonicalize namespaced tags in inspect() - #63257
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63257 +/- ##
==========================================
- Coverage 90.13% 90.11% -0.03%
==========================================
Files 751 751
Lines 253635 253630 -5
Branches 47786 47796 +10
==========================================
- Hits 228615 228555 -60
- Misses 16268 16315 +47
- Partials 8752 8760 +8
🚀 New features to boost your workflow:
|
| constructor[endPos] === constructor[endPos].toLowerCase()) { | ||
| result += `[${tag}] `; | ||
| } | ||
| const dot = StringPrototypeLastIndexOf(tag, '.'); |
There was a problem hiding this comment.
I think it is not straightforward to write a class with . in its name, like class Namespace.Class {} is not valid. So we can branch here with the presence of . and keep the original behavior, right?
There was a problem hiding this comment.
As in the previous suppression behaviour?
I really do think that divergent behaviour isn't helpful here – there's no difference between the inheritance models of class MapDerived extends Map and class InstantDerived extends Temporal.Instant, so I can't see that formatting one as a primary class and one as a derived class is at all useful for users.
|
This pull request has been marked as stale due to 90 days of inactivity. |
|
@BridgeAR Do you have an opinion on this? As mentioned, this is mainly observable in the context of Temporal objects. Formatting these as
is overly verbose, and implies that these are derived subclasses when they're not. |
Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
b7bebca to
ad239e3
Compare
Precursor to adding support for Temporal objects in #63154.
Namespaced toString tags are becoming more common in ES builtins.
inspect()currently has no logic for dealing with these, leading to rather ugly output:This PR adds logic to handle namespaced tags. If the basename of the namespaced tag matches the constructor name, then it will be treated as the canonical name for that object.
Derived classes retain the same behaviour as exists currently.
Note that this replaces, and effectively reverts, some previous logic that existed here from #59687. That PR made partial string tag matches suppress the derived class output, so derived class instances might be formatted as either derived classes or base classes depending on how they're named:
This logic doesn't really fit with namespaced tags and was fairly quirky to start with, and I think the easiest approach is just to replace it entirely. (cc @BridgeAR, @miguelmarcondesf)