1/*! ***************************************************************************** 2Copyright (c) Microsoft Corporation. All rights reserved. 3Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4this file except in compliance with the License. You may obtain a copy of the 5License at http://www.apache.org/licenses/LICENSE-2.0 6 7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10MERCHANTABLITY OR NON-INFRINGEMENT. 11 12See the Apache Version 2.0 License for specific language governing permissions 13and limitations under the License. 14***************************************************************************** */ 15 16 17 18/// <reference no-default-lib="true"/> 19 20 21/// <reference lib="es2015.symbol" /> 22 23interface SymbolConstructor { 24 /** 25 * A method that returns the default iterator for an object. Called by the semantics of the 26 * for-of statement. 27 */ 28 readonly iterator: symbol; 29} 30 31interface IteratorYieldResult<TYield> { 32 done?: false; 33 value: TYield; 34} 35 36interface IteratorReturnResult<TReturn> { 37 done: true; 38 value: TReturn; 39} 40 41type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>; 42 43interface Iterator<T, TReturn = any, TNext = undefined> { 44 // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. 45 next(...args: [] | [TNext]): IteratorResult<T, TReturn>; 46 return?(value?: TReturn): IteratorResult<T, TReturn>; 47 throw?(e?: any): IteratorResult<T, TReturn>; 48} 49 50interface Iterable<T> { 51 [Symbol.iterator](): Iterator<T>; 52} 53 54interface IterableIterator<T> extends Iterator<T> { 55 [Symbol.iterator](): IterableIterator<T>; 56} 57 58interface Array<T> { 59 /** Iterator */ 60 [Symbol.iterator](): IterableIterator<T>; 61 62 /** 63 * Returns an iterable of key, value pairs for every entry in the array 64 */ 65 entries(): IterableIterator<[number, T]>; 66 67 /** 68 * Returns an iterable of keys in the array 69 */ 70 keys(): IterableIterator<number>; 71 72 /** 73 * Returns an iterable of values in the array 74 */ 75 values(): IterableIterator<T>; 76} 77 78interface ArrayConstructor { 79 /** 80 * Creates an array from an iterable object. 81 * @param iterable An iterable object to convert to an array. 82 */ 83 from<T>(iterable: Iterable<T> | ArrayLike<T>): T[]; 84 85 /** 86 * Creates an array from an iterable object. 87 * @param iterable An iterable object to convert to an array. 88 * @param mapfn A mapping function to call on every element of the array. 89 * @param thisArg Value of 'this' used to invoke the mapfn. 90 */ 91 from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; 92} 93 94interface ReadonlyArray<T> { 95 /** Iterator of values in the array. */ 96 [Symbol.iterator](): IterableIterator<T>; 97 98 /** 99 * Returns an iterable of key, value pairs for every entry in the array 100 */ 101 entries(): IterableIterator<[number, T]>; 102 103 /** 104 * Returns an iterable of keys in the array 105 */ 106 keys(): IterableIterator<number>; 107 108 /** 109 * Returns an iterable of values in the array 110 */ 111 values(): IterableIterator<T>; 112} 113 114interface IArguments { 115 /** Iterator */ 116 [Symbol.iterator](): IterableIterator<any>; 117} 118 119interface Map<K, V> { 120 /** Returns an iterable of entries in the map. */ 121 [Symbol.iterator](): IterableIterator<[K, V]>; 122 123 /** 124 * Returns an iterable of key, value pairs for every entry in the map. 125 */ 126 entries(): IterableIterator<[K, V]>; 127 128 /** 129 * Returns an iterable of keys in the map 130 */ 131 keys(): IterableIterator<K>; 132 133 /** 134 * Returns an iterable of values in the map 135 */ 136 values(): IterableIterator<V>; 137} 138 139interface ReadonlyMap<K, V> { 140 /** Returns an iterable of entries in the map. */ 141 [Symbol.iterator](): IterableIterator<[K, V]>; 142 143 /** 144 * Returns an iterable of key, value pairs for every entry in the map. 145 */ 146 entries(): IterableIterator<[K, V]>; 147 148 /** 149 * Returns an iterable of keys in the map 150 */ 151 keys(): IterableIterator<K>; 152 153 /** 154 * Returns an iterable of values in the map 155 */ 156 values(): IterableIterator<V>; 157} 158 159interface MapConstructor { 160 new <K, V>(iterable: Iterable<readonly [K, V]>): Map<K, V>; 161} 162 163interface WeakMap<K extends object, V> { } 164 165interface WeakMapConstructor { 166 new <K extends object, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>; 167} 168 169interface Set<T> { 170 /** Iterates over values in the set. */ 171 [Symbol.iterator](): IterableIterator<T>; 172 /** 173 * Returns an iterable of [v,v] pairs for every value `v` in the set. 174 */ 175 entries(): IterableIterator<[T, T]>; 176 /** 177 * Despite its name, returns an iterable of the values in the set. 178 */ 179 keys(): IterableIterator<T>; 180 181 /** 182 * Returns an iterable of values in the set. 183 */ 184 values(): IterableIterator<T>; 185} 186 187interface ReadonlySet<T> { 188 /** Iterates over values in the set. */ 189 [Symbol.iterator](): IterableIterator<T>; 190 191 /** 192 * Returns an iterable of [v,v] pairs for every value `v` in the set. 193 */ 194 entries(): IterableIterator<[T, T]>; 195 196 /** 197 * Despite its name, returns an iterable of the values in the set. 198 */ 199 keys(): IterableIterator<T>; 200 201 /** 202 * Returns an iterable of values in the set. 203 */ 204 values(): IterableIterator<T>; 205} 206 207interface SetConstructor { 208 new <T>(iterable?: Iterable<T> | null): Set<T>; 209} 210 211interface WeakSet<T extends object> { } 212 213interface WeakSetConstructor { 214 new <T extends object = object>(iterable: Iterable<T>): WeakSet<T>; 215} 216 217interface Promise<T> { } 218 219interface PromiseConstructor { 220 /** 221 * Creates a Promise that is resolved with an array of results when all of the provided Promises 222 * resolve, or rejected when any Promise is rejected. 223 * @param values An iterable of Promises. 224 * @returns A new Promise. 225 */ 226 all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>; 227 228 /** 229 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 230 * or rejected. 231 * @param values An iterable of Promises. 232 * @returns A new Promise. 233 */ 234 race<T>(values: Iterable<T>): Promise<T extends PromiseLike<infer U> ? U : T>; 235 236 /** 237 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 238 * or rejected. 239 * @param values An iterable of Promises. 240 * @returns A new Promise. 241 */ 242 race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>; 243} 244 245interface String { 246 /** Iterator */ 247 [Symbol.iterator](): IterableIterator<string>; 248} 249 250interface Int8Array { 251 [Symbol.iterator](): IterableIterator<number>; 252 /** 253 * Returns an array of key, value pairs for every entry in the array 254 */ 255 entries(): IterableIterator<[number, number]>; 256 /** 257 * Returns an list of keys in the array 258 */ 259 keys(): IterableIterator<number>; 260 /** 261 * Returns an list of values in the array 262 */ 263 values(): IterableIterator<number>; 264} 265 266interface Int8ArrayConstructor { 267 new (elements: Iterable<number>): Int8Array; 268 269 /** 270 * Creates an array from an array-like or iterable object. 271 * @param arrayLike An array-like or iterable object to convert to an array. 272 * @param mapfn A mapping function to call on every element of the array. 273 * @param thisArg Value of 'this' used to invoke the mapfn. 274 */ 275 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; 276} 277 278interface Uint8Array { 279 [Symbol.iterator](): IterableIterator<number>; 280 /** 281 * Returns an array of key, value pairs for every entry in the array 282 */ 283 entries(): IterableIterator<[number, number]>; 284 /** 285 * Returns an list of keys in the array 286 */ 287 keys(): IterableIterator<number>; 288 /** 289 * Returns an list of values in the array 290 */ 291 values(): IterableIterator<number>; 292} 293 294interface Uint8ArrayConstructor { 295 new (elements: Iterable<number>): Uint8Array; 296 297 /** 298 * Creates an array from an array-like or iterable object. 299 * @param arrayLike An array-like or iterable object to convert to an array. 300 * @param mapfn A mapping function to call on every element of the array. 301 * @param thisArg Value of 'this' used to invoke the mapfn. 302 */ 303 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; 304} 305 306interface Uint8ClampedArray { 307 [Symbol.iterator](): IterableIterator<number>; 308 /** 309 * Returns an array of key, value pairs for every entry in the array 310 */ 311 entries(): IterableIterator<[number, number]>; 312 313 /** 314 * Returns an list of keys in the array 315 */ 316 keys(): IterableIterator<number>; 317 318 /** 319 * Returns an list of values in the array 320 */ 321 values(): IterableIterator<number>; 322} 323 324interface Uint8ClampedArrayConstructor { 325 new (elements: Iterable<number>): Uint8ClampedArray; 326 327 328 /** 329 * Creates an array from an array-like or iterable object. 330 * @param arrayLike An array-like or iterable object to convert to an array. 331 * @param mapfn A mapping function to call on every element of the array. 332 * @param thisArg Value of 'this' used to invoke the mapfn. 333 */ 334 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; 335} 336 337interface Int16Array { 338 [Symbol.iterator](): IterableIterator<number>; 339 /** 340 * Returns an array of key, value pairs for every entry in the array 341 */ 342 entries(): IterableIterator<[number, number]>; 343 344 /** 345 * Returns an list of keys in the array 346 */ 347 keys(): IterableIterator<number>; 348 349 /** 350 * Returns an list of values in the array 351 */ 352 values(): IterableIterator<number>; 353} 354 355interface Int16ArrayConstructor { 356 new (elements: Iterable<number>): Int16Array; 357 358 /** 359 * Creates an array from an array-like or iterable object. 360 * @param arrayLike An array-like or iterable object to convert to an array. 361 * @param mapfn A mapping function to call on every element of the array. 362 * @param thisArg Value of 'this' used to invoke the mapfn. 363 */ 364 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; 365} 366 367interface Uint16Array { 368 [Symbol.iterator](): IterableIterator<number>; 369 /** 370 * Returns an array of key, value pairs for every entry in the array 371 */ 372 entries(): IterableIterator<[number, number]>; 373 /** 374 * Returns an list of keys in the array 375 */ 376 keys(): IterableIterator<number>; 377 /** 378 * Returns an list of values in the array 379 */ 380 values(): IterableIterator<number>; 381} 382 383interface Uint16ArrayConstructor { 384 new (elements: Iterable<number>): Uint16Array; 385 386 /** 387 * Creates an array from an array-like or iterable object. 388 * @param arrayLike An array-like or iterable object to convert to an array. 389 * @param mapfn A mapping function to call on every element of the array. 390 * @param thisArg Value of 'this' used to invoke the mapfn. 391 */ 392 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; 393} 394 395interface Int32Array { 396 [Symbol.iterator](): IterableIterator<number>; 397 /** 398 * Returns an array of key, value pairs for every entry in the array 399 */ 400 entries(): IterableIterator<[number, number]>; 401 /** 402 * Returns an list of keys in the array 403 */ 404 keys(): IterableIterator<number>; 405 /** 406 * Returns an list of values in the array 407 */ 408 values(): IterableIterator<number>; 409} 410 411interface Int32ArrayConstructor { 412 new (elements: Iterable<number>): Int32Array; 413 414 /** 415 * Creates an array from an array-like or iterable object. 416 * @param arrayLike An array-like or iterable object to convert to an array. 417 * @param mapfn A mapping function to call on every element of the array. 418 * @param thisArg Value of 'this' used to invoke the mapfn. 419 */ 420 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; 421} 422 423interface Uint32Array { 424 [Symbol.iterator](): IterableIterator<number>; 425 /** 426 * Returns an array of key, value pairs for every entry in the array 427 */ 428 entries(): IterableIterator<[number, number]>; 429 /** 430 * Returns an list of keys in the array 431 */ 432 keys(): IterableIterator<number>; 433 /** 434 * Returns an list of values in the array 435 */ 436 values(): IterableIterator<number>; 437} 438 439interface Uint32ArrayConstructor { 440 new (elements: Iterable<number>): Uint32Array; 441 442 /** 443 * Creates an array from an array-like or iterable object. 444 * @param arrayLike An array-like or iterable object to convert to an array. 445 * @param mapfn A mapping function to call on every element of the array. 446 * @param thisArg Value of 'this' used to invoke the mapfn. 447 */ 448 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; 449} 450 451interface Float32Array { 452 [Symbol.iterator](): IterableIterator<number>; 453 /** 454 * Returns an array of key, value pairs for every entry in the array 455 */ 456 entries(): IterableIterator<[number, number]>; 457 /** 458 * Returns an list of keys in the array 459 */ 460 keys(): IterableIterator<number>; 461 /** 462 * Returns an list of values in the array 463 */ 464 values(): IterableIterator<number>; 465} 466 467interface Float32ArrayConstructor { 468 new (elements: Iterable<number>): Float32Array; 469 470 /** 471 * Creates an array from an array-like or iterable object. 472 * @param arrayLike An array-like or iterable object to convert to an array. 473 * @param mapfn A mapping function to call on every element of the array. 474 * @param thisArg Value of 'this' used to invoke the mapfn. 475 */ 476 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; 477} 478 479interface Float64Array { 480 [Symbol.iterator](): IterableIterator<number>; 481 /** 482 * Returns an array of key, value pairs for every entry in the array 483 */ 484 entries(): IterableIterator<[number, number]>; 485 /** 486 * Returns an list of keys in the array 487 */ 488 keys(): IterableIterator<number>; 489 /** 490 * Returns an list of values in the array 491 */ 492 values(): IterableIterator<number>; 493} 494 495interface Float64ArrayConstructor { 496 new (elements: Iterable<number>): Float64Array; 497 498 /** 499 * Creates an array from an array-like or iterable object. 500 * @param arrayLike An array-like or iterable object to convert to an array. 501 * @param mapfn A mapping function to call on every element of the array. 502 * @param thisArg Value of 'this' used to invoke the mapfn. 503 */ 504 from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; 505} 506