Support getters
Closed this issue · 3 comments
We should ensure that we're showing getters in object previews
Note that it's not only about getters - probably about stuff with custom descriptors, those coming from a prototype might also have some importance here.
Basically I don't see any of those in the object previews:
Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
__tsDebuggerDisplay: {
value: function () {
var typeHeader = this.flags & 98304 ? "NullableType" :
this.flags & 384 ? "LiteralType " + JSON.stringify(this.value) :
this.flags & 2048 ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" :
this.flags & 8192 ? "UniqueESSymbolType" :
this.flags & 32 ? "EnumType" :
this.flags & 67359327 ? "IntrinsicType " + this.intrinsicName :
this.flags & 1048576 ? "UnionType" :
this.flags & 2097152 ? "IntersectionType" :
this.flags & 4194304 ? "IndexType" :
this.flags & 8388608 ? "IndexedAccessType" :
this.flags & 16777216 ? "ConditionalType" :
this.flags & 33554432 ? "SubstitutionType" :
this.flags & 262144 ? "TypeParameter" :
this.flags & 524288 ?
this.objectFlags & 3 ? "InterfaceType" :
this.objectFlags & 4 ? "TypeReference" :
this.objectFlags & 8 ? "TupleType" :
this.objectFlags & 16 ? "AnonymousType" :
this.objectFlags & 32 ? "MappedType" :
this.objectFlags & 1024 ? "ReverseMappedType" :
this.objectFlags & 256 ? "EvolvingArrayType" :
"ObjectType" :
"Type";
var remainingObjectFlags = this.flags & 524288 ? this.objectFlags & ~1343 : 0;
return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : "");
}
},
__debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
__debugObjectFlags: { get: function () { return this.flags & 524288 ? formatObjectFlags(this.objectFlags) : ""; } },
__debugTypeToString: {
value: function () {
var map = getWeakTypeTextMap();
var text = map === null || map === void 0 ? void 0 : map.get(this);
if (text === undefined) {
text = this.checker.typeToString(this);
map === null || map === void 0 ? void 0 : map.set(this, text);
}
return text;
}
},
});
Notice that some of those only define the { value }
.
We are tracking this internally now.
Quick update though:
Basic support for getterValues
is now tracked in RUN-1016
.
However, this issue requires evaluation of user-defined getters. We have not even done this in gecko, since this could cause side effects, and as stated here, we don't want that:
Results of evaluating getter properties from this or the prototype chain on this object, if they could be evaluated without side effects.
Thus, user-defined getters would require an extension of the original protocol, where user-defined getters are sometimes allowed to be evaluated.