lib.es2015.symbol.wellknown.d.ts (11010B)
1 /*! ***************************************************************************** 2 Copyright (c) Microsoft Corporation. All rights reserved. 3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 this file except in compliance with the License. You may obtain a copy of the 5 License at http://www.apache.org/licenses/LICENSE-2.0 6 7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10 MERCHANTABLITY OR NON-INFRINGEMENT. 11 12 See the Apache Version 2.0 License for specific language governing permissions 13 and limitations under the License. 14 ***************************************************************************** */ 15 16 17 /// <reference no-default-lib="true"/> 18 19 /// <reference lib="es2015.symbol" /> 20 21 interface SymbolConstructor { 22 /** 23 * A method that determines if a constructor object recognizes an object as one of the 24 * constructor’s instances. Called by the semantics of the instanceof operator. 25 */ 26 readonly hasInstance: unique symbol; 27 28 /** 29 * A Boolean value that if true indicates that an object should flatten to its array elements 30 * by Array.prototype.concat. 31 */ 32 readonly isConcatSpreadable: unique symbol; 33 34 /** 35 * A regular expression method that matches the regular expression against a string. Called 36 * by the String.prototype.match method. 37 */ 38 readonly match: unique symbol; 39 40 /** 41 * A regular expression method that replaces matched substrings of a string. Called by the 42 * String.prototype.replace method. 43 */ 44 readonly replace: unique symbol; 45 46 /** 47 * A regular expression method that returns the index within a string that matches the 48 * regular expression. Called by the String.prototype.search method. 49 */ 50 readonly search: unique symbol; 51 52 /** 53 * A function valued property that is the constructor function that is used to create 54 * derived objects. 55 */ 56 readonly species: unique symbol; 57 58 /** 59 * A regular expression method that splits a string at the indices that match the regular 60 * expression. Called by the String.prototype.split method. 61 */ 62 readonly split: unique symbol; 63 64 /** 65 * A method that converts an object to a corresponding primitive value. 66 * Called by the ToPrimitive abstract operation. 67 */ 68 readonly toPrimitive: unique symbol; 69 70 /** 71 * A String value that is used in the creation of the default string description of an object. 72 * Called by the built-in method Object.prototype.toString. 73 */ 74 readonly toStringTag: unique symbol; 75 76 /** 77 * An Object whose truthy properties are properties that are excluded from the 'with' 78 * environment bindings of the associated objects. 79 */ 80 readonly unscopables: unique symbol; 81 } 82 83 interface Symbol { 84 /** 85 * Converts a Symbol object to a symbol. 86 */ 87 [Symbol.toPrimitive](hint: string): symbol; 88 89 readonly [Symbol.toStringTag]: string; 90 } 91 92 interface Array<T> { 93 /** 94 * Is an object whose properties have the value 'true' 95 * when they will be absent when used in a 'with' statement. 96 */ 97 readonly [Symbol.unscopables]: { 98 [K in keyof any[]]?: boolean; 99 }; 100 } 101 102 interface ReadonlyArray<T> { 103 /** 104 * Is an object whose properties have the value 'true' 105 * when they will be absent when used in a 'with' statement. 106 */ 107 readonly [Symbol.unscopables]: { 108 [K in keyof readonly any[]]?: boolean; 109 }; 110 } 111 112 interface Date { 113 /** 114 * Converts a Date object to a string. 115 */ 116 [Symbol.toPrimitive](hint: "default"): string; 117 /** 118 * Converts a Date object to a string. 119 */ 120 [Symbol.toPrimitive](hint: "string"): string; 121 /** 122 * Converts a Date object to a number. 123 */ 124 [Symbol.toPrimitive](hint: "number"): number; 125 /** 126 * Converts a Date object to a string or number. 127 * 128 * @param hint The strings "number", "string", or "default" to specify what primitive to return. 129 * 130 * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". 131 * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". 132 */ 133 [Symbol.toPrimitive](hint: string): string | number; 134 } 135 136 interface Map<K, V> { 137 readonly [Symbol.toStringTag]: string; 138 } 139 140 interface WeakMap<K extends WeakKey, V> { 141 readonly [Symbol.toStringTag]: string; 142 } 143 144 interface Set<T> { 145 readonly [Symbol.toStringTag]: string; 146 } 147 148 interface WeakSet<T extends WeakKey> { 149 readonly [Symbol.toStringTag]: string; 150 } 151 152 interface JSON { 153 readonly [Symbol.toStringTag]: string; 154 } 155 156 interface Function { 157 /** 158 * Determines whether the given value inherits from this function if this function was used 159 * as a constructor function. 160 * 161 * A constructor function can control which objects are recognized as its instances by 162 * 'instanceof' by overriding this method. 163 */ 164 [Symbol.hasInstance](value: any): boolean; 165 } 166 167 interface GeneratorFunction { 168 readonly [Symbol.toStringTag]: string; 169 } 170 171 interface Math { 172 readonly [Symbol.toStringTag]: string; 173 } 174 175 interface Promise<T> { 176 readonly [Symbol.toStringTag]: string; 177 } 178 179 interface PromiseConstructor { 180 readonly [Symbol.species]: PromiseConstructor; 181 } 182 183 interface RegExp { 184 /** 185 * Matches a string with this regular expression, and returns an array containing the results of 186 * that search. 187 * @param string A string to search within. 188 */ 189 [Symbol.match](string: string): RegExpMatchArray | null; 190 191 /** 192 * Replaces text in a string, using this regular expression. 193 * @param string A String object or string literal whose contents matching against 194 * this regular expression will be replaced 195 * @param replaceValue A String object or string literal containing the text to replace for every 196 * successful match of this regular expression. 197 */ 198 [Symbol.replace](string: string, replaceValue: string): string; 199 200 /** 201 * Replaces text in a string, using this regular expression. 202 * @param string A String object or string literal whose contents matching against 203 * this regular expression will be replaced 204 * @param replacer A function that returns the replacement text. 205 */ 206 [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; 207 208 /** 209 * Finds the position beginning first substring match in a regular expression search 210 * using this regular expression. 211 * 212 * @param string The string to search within. 213 */ 214 [Symbol.search](string: string): number; 215 216 /** 217 * Returns an array of substrings that were delimited by strings in the original input that 218 * match against this regular expression. 219 * 220 * If the regular expression contains capturing parentheses, then each time this 221 * regular expression matches, the results (including any undefined results) of the 222 * capturing parentheses are spliced. 223 * 224 * @param string string value to split 225 * @param limit if not undefined, the output array is truncated so that it contains no more 226 * than 'limit' elements. 227 */ 228 [Symbol.split](string: string, limit?: number): string[]; 229 } 230 231 interface RegExpConstructor { 232 readonly [Symbol.species]: RegExpConstructor; 233 } 234 235 interface String { 236 /** 237 * Matches a string or an object that supports being matched against, and returns an array 238 * containing the results of that search, or null if no matches are found. 239 * @param matcher An object that supports being matched against. 240 */ 241 match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; 242 243 /** 244 * Passes a string and {@linkcode replaceValue} to the `[Symbol.replace]` method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm. 245 * @param searchValue An object that supports searching for and replacing matches within a string. 246 * @param replaceValue The replacement text. 247 */ 248 replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; 249 250 /** 251 * Replaces text in a string, using an object that supports replacement within a string. 252 * @param searchValue A object can search for and replace matches within a string. 253 * @param replacer A function that returns the replacement text. 254 */ 255 replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; 256 257 /** 258 * Finds the first substring match in a regular expression search. 259 * @param searcher An object which supports searching within a string. 260 */ 261 search(searcher: { [Symbol.search](string: string): number; }): number; 262 263 /** 264 * Split a string into substrings using the specified separator and return them as an array. 265 * @param splitter An object that can split a string. 266 * @param limit A value used to limit the number of elements returned in the array. 267 */ 268 split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; 269 } 270 271 interface ArrayBuffer { 272 readonly [Symbol.toStringTag]: "ArrayBuffer"; 273 } 274 275 interface DataView<TArrayBuffer extends ArrayBufferLike> { 276 readonly [Symbol.toStringTag]: string; 277 } 278 279 interface Int8Array<TArrayBuffer extends ArrayBufferLike> { 280 readonly [Symbol.toStringTag]: "Int8Array"; 281 } 282 283 interface Uint8Array<TArrayBuffer extends ArrayBufferLike> { 284 readonly [Symbol.toStringTag]: "Uint8Array"; 285 } 286 287 interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> { 288 readonly [Symbol.toStringTag]: "Uint8ClampedArray"; 289 } 290 291 interface Int16Array<TArrayBuffer extends ArrayBufferLike> { 292 readonly [Symbol.toStringTag]: "Int16Array"; 293 } 294 295 interface Uint16Array<TArrayBuffer extends ArrayBufferLike> { 296 readonly [Symbol.toStringTag]: "Uint16Array"; 297 } 298 299 interface Int32Array<TArrayBuffer extends ArrayBufferLike> { 300 readonly [Symbol.toStringTag]: "Int32Array"; 301 } 302 303 interface Uint32Array<TArrayBuffer extends ArrayBufferLike> { 304 readonly [Symbol.toStringTag]: "Uint32Array"; 305 } 306 307 interface Float32Array<TArrayBuffer extends ArrayBufferLike> { 308 readonly [Symbol.toStringTag]: "Float32Array"; 309 } 310 311 interface Float64Array<TArrayBuffer extends ArrayBufferLike> { 312 readonly [Symbol.toStringTag]: "Float64Array"; 313 } 314 315 interface ArrayConstructor { 316 readonly [Symbol.species]: ArrayConstructor; 317 } 318 interface MapConstructor { 319 readonly [Symbol.species]: MapConstructor; 320 } 321 interface SetConstructor { 322 readonly [Symbol.species]: SetConstructor; 323 } 324 interface ArrayBufferConstructor { 325 readonly [Symbol.species]: ArrayBufferConstructor; 326 }