suyi91
11/27/2017 - 3:29 PM

Typescript about 'Object.defineProperty'

Typescript about '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;

    // ......
    
    declare type PropertyKey = string | number | symbol;

    // ......

    interface PropertyDescriptor {
        configurable?: boolean;
        enumerable?: boolean;
        value?: any;
        writable?: boolean;
        get?(): any;
        set?(v: any): void;
    }