Closed
Description
While updating the various .d.ts to have | null
and | undefined
, I came across some typings that use any
but don't allow null
or undefined
.
-
Object.defineProperty:
/** * Adds a property to an object, or modifies attributes of an existing property. * @param o Object on which to add or modify the property. This can be a native JavaScript * object (that is, a user-defined object or a built in object) or a DOM object. * @param p The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor * property. */ defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any;
o
and the returned value cannot benull
orundefined
. -
Object.setPrototypeOf:
/** * Sets the prototype of a specified object o to object proto or null. Returns the object o. * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ setPrototypeOf(o: any, proto: any): any;
o
and the returned value cannot benull
orundefined
.proto
can benull
but notundefined
. -
etc.
I think there is value in being able to express both "This can be any type including null and undefined" and "This can be any type excluding null / undefined", but there is no way to express the latter.
Metadata
Metadata
Assignees
Labels
No labels