|
| 1 | +/* |
| 2 | + * Copyright 2018 The Closure Compiler Authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/** |
| 18 | + * @fileoverview Definitions for ECMAScript 6 Proxy objects. |
| 19 | + * @see https://tc39.github.io/ecma262/#sec-proxy-objects |
| 20 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy |
| 21 | + * @externs |
| 22 | + */ |
| 23 | + |
| 24 | + |
| 25 | +/** |
| 26 | + * @record |
| 27 | + * @template TARGET |
| 28 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots |
| 29 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler |
| 30 | + */ |
| 31 | +function ProxyHandler() {} |
| 32 | + |
| 33 | +/** |
| 34 | + * @type {(function(TARGET):?Object)|undefined} |
| 35 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof |
| 36 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf |
| 37 | + */ |
| 38 | +ProxyHandler.prototype.getPrototypeOf /* = function(target) {} */; |
| 39 | + |
| 40 | +/** |
| 41 | + * @type {(function(TARGET, ?Object):boolean)|undefined} |
| 42 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v |
| 43 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf |
| 44 | + */ |
| 45 | +ProxyHandler.prototype.setPrototypeOf /* = function(target, proto) {} */; |
| 46 | + |
| 47 | +/** |
| 48 | + * @type {(function(TARGET):boolean)|undefined} |
| 49 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible |
| 50 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible |
| 51 | + */ |
| 52 | +ProxyHandler.prototype.isExtensible /* = function(target) {} */; |
| 53 | + |
| 54 | +/** |
| 55 | + * @type {(function(TARGET):boolean)|undefined} |
| 56 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-preventextensions |
| 57 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions |
| 58 | + */ |
| 59 | +ProxyHandler.prototype.preventExtensions /* = function(target) {} */; |
| 60 | + |
| 61 | +/** |
| 62 | + * @type {(function(TARGET, (string|symbol)):(!ObjectPropertyDescriptor|undefined))|undefined} |
| 63 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p |
| 64 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor |
| 65 | + */ |
| 66 | +ProxyHandler.prototype.getOwnPropertyDescriptor /* = function(target, prop) {} */; |
| 67 | + |
| 68 | +/** |
| 69 | + * @type {(function(TARGET, (string|symbol), !ObjectPropertyDescriptor):boolean)|undefined} |
| 70 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc |
| 71 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty |
| 72 | + */ |
| 73 | +ProxyHandler.prototype.defineProperty /* = function(target, prop, desc) {} */; |
| 74 | + |
| 75 | +/** |
| 76 | + * @type {(function(TARGET, (string|symbol)):boolean)|undefined} |
| 77 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p |
| 78 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has |
| 79 | + */ |
| 80 | +ProxyHandler.prototype.has /* = function(target, prop) {} */; |
| 81 | + |
| 82 | +/** |
| 83 | + * @type {(function(TARGET, (string|symbol), !Object):*)|undefined} |
| 84 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver |
| 85 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get |
| 86 | + */ |
| 87 | +ProxyHandler.prototype.get /* = function(target, prop, receiver) {} */; |
| 88 | + |
| 89 | +/** |
| 90 | + * @type {(function(TARGET, (string|symbol), *, !Object):boolean)|undefined} |
| 91 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver |
| 92 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set |
| 93 | + */ |
| 94 | +ProxyHandler.prototype.set /* = function(target, prop, value, receiver) {} */; |
| 95 | + |
| 96 | +/** |
| 97 | + * @type {(function(TARGET, (string|symbol)):boolean)|undefined} |
| 98 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-delete-p |
| 99 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty |
| 100 | + */ |
| 101 | +ProxyHandler.prototype.deleteProperty /* = function (target, prop) {} */; |
| 102 | + |
| 103 | +/** |
| 104 | + * @type {(function(TARGET):!Array<(string|symbol)>)|undefined} |
| 105 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys |
| 106 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys |
| 107 | + */ |
| 108 | +ProxyHandler.prototype.ownKeys /* = function(target) {} */; |
| 109 | + |
| 110 | +/** |
| 111 | + * @type {(function(TARGET, *, !Array):*)|undefined} |
| 112 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist |
| 113 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply |
| 114 | + */ |
| 115 | +ProxyHandler.prototype.apply /* = function(target, thisArg, argList) {} */; |
| 116 | + |
| 117 | +/** |
| 118 | + * @type {(function(TARGET, !Array, function(new: ?, ...?)):!Object)|undefined} |
| 119 | + * @see https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget |
| 120 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct |
| 121 | + */ |
| 122 | +ProxyHandler.prototype.construct /* = function(target, argList, newTarget) {} */; |
| 123 | + |
| 124 | + |
| 125 | +/** |
| 126 | + * @constructor |
| 127 | + * @param {TARGET} target |
| 128 | + * @param {!ProxyHandler<TARGET>} handler |
| 129 | + * @template TARGET |
| 130 | + * @see https://tc39.github.io/ecma262/#sec-proxy-constructor |
| 131 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Syntax |
| 132 | + */ |
| 133 | +function Proxy(target, handler) {} |
| 134 | + |
| 135 | +/** |
| 136 | + * @param {TARGET} target |
| 137 | + * @param {!ProxyHandler<TARGET>} handler |
| 138 | + * @return {{proxy: !Proxy<TARGET>, revoke: function():void}} |
| 139 | + * @template TARGET |
| 140 | + * @see https://tc39.github.io/ecma262/#sec-proxy.revocable |
| 141 | + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable |
| 142 | + */ |
| 143 | +Proxy.revocable = function(target, handler) {}; |
0 commit comments