UNPKG

24 kBTypeScriptView Raw
1interface IteratorResult<T> {
2 done: boolean;
3 value?: T | undefined;
4}
5
6interface IterableShim<T> {
7 /**
8 * Shim for an ES6 iterable. Not intended for direct use by user code.
9 */
10 "_es6-shim iterator_"(): Iterator<T>;
11}
12
13interface Iterator<T> {
14 next(value?: any): IteratorResult<T>;
15 return?(value?: any): IteratorResult<T>;
16 throw?(e?: any): IteratorResult<T>;
17}
18
19interface IterableIteratorShim<T> extends IterableShim<T>, Iterator<T> {
20 /**
21 * Shim for an ES6 iterable iterator. Not intended for direct use by user code.
22 */
23 "_es6-shim iterator_"(): IterableIteratorShim<T>;
24}
25
26interface StringConstructor {
27 /**
28 * Return the String value whose elements are, in order, the elements in the List elements.
29 * If length is 0, the empty string is returned.
30 */
31 fromCodePoint(...codePoints: number[]): string;
32
33 /**
34 * String.raw is intended for use as a tag function of a Tagged Template String. When called
35 * as such the first argument will be a well formed template call site object and the rest
36 * parameter will contain the substitution values.
37 * @param template A well-formed template string call site representation.
38 * @param substitutions A set of substitution values.
39 */
40 raw(template: TemplateStringsArray, ...substitutions: any[]): string;
41}
42
43interface String {
44 /**
45 * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
46 * value of the UTF-16 encoded code point starting at the string element at position pos in
47 * the String resulting from converting this object to a String.
48 * If there is no element at that position, the result is undefined.
49 * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
50 */
51 codePointAt(pos: number): number;
52
53 /**
54 * Returns true if searchString appears as a substring of the result of converting this
55 * object to a String, at one or more positions that are
56 * greater than or equal to position; otherwise, returns false.
57 * @param searchString search string
58 * @param position If position is undefined, 0 is assumed, so as to search all of the String.
59 */
60 includes(searchString: string, position?: number): boolean;
61
62 /**
63 * Returns true if the sequence of elements of searchString converted to a String is the
64 * same as the corresponding elements of this object (converted to a String) starting at
65 * endPosition – length(this). Otherwise returns false.
66 */
67 endsWith(searchString: string, endPosition?: number): boolean;
68
69 /**
70 * Returns a String value that is made from count copies appended together. If count is 0,
71 * T is the empty String is returned.
72 * @param count number of copies to append
73 */
74 repeat(count: number): string;
75
76 /**
77 * Returns true if the sequence of elements of searchString converted to a String is the
78 * same as the corresponding elements of this object (converted to a String) starting at
79 * position. Otherwise returns false.
80 */
81 startsWith(searchString: string, position?: number): boolean;
82
83 /**
84 * Returns an <a> HTML anchor element and sets the name attribute to the text value
85 * @param name
86 */
87 anchor(name: string): string;
88
89 /** Returns a <big> HTML element */
90 big(): string;
91
92 /** Returns a <blink> HTML element */
93 blink(): string;
94
95 /** Returns a <b> HTML element */
96 bold(): string;
97
98 /** Returns a <tt> HTML element */
99 fixed(): string;
100
101 /** Returns a <font> HTML element and sets the color attribute value */
102 fontcolor(color: string): string;
103
104 /** Returns a <font> HTML element and sets the size attribute value */
105 fontsize(size: number): string;
106
107 /** Returns a <font> HTML element and sets the size attribute value */
108 fontsize(size: string): string;
109
110 /** Returns an <i> HTML element */
111 italics(): string;
112
113 /** Returns an <a> HTML element and sets the href attribute value */
114 link(url: string): string;
115
116 /** Returns a <small> HTML element */
117 small(): string;
118
119 /** Returns a <strike> HTML element */
120 strike(): string;
121
122 /** Returns a <sub> HTML element */
123 sub(): string;
124
125 /** Returns a <sup> HTML element */
126 sup(): string;
127
128 /**
129 * Shim for an ES6 iterable. Not intended for direct use by user code.
130 */
131 "_es6-shim iterator_"(): IterableIteratorShim<string>;
132}
133
134interface ArrayConstructor {
135 /**
136 * Creates an array from an array-like object.
137 * @param arrayLike An array-like object to convert to an array.
138 * @param mapfn A mapping function to call on every element of the array.
139 * @param thisArg Value of 'this' used to invoke the mapfn.
140 */
141 from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
142
143 /**
144 * Creates an array from an iterable object.
145 * @param iterable An iterable object to convert to an array.
146 * @param mapfn A mapping function to call on every element of the array.
147 * @param thisArg Value of 'this' used to invoke the mapfn.
148 */
149 from<T, U>(iterable: IterableShim<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
150
151 /**
152 * Creates an array from an array-like object.
153 * @param arrayLike An array-like object to convert to an array.
154 */
155 from<T>(arrayLike: ArrayLike<T>): T[];
156
157 /**
158 * Creates an array from an iterable object.
159 * @param iterable An iterable object to convert to an array.
160 */
161 from<T>(iterable: IterableShim<T>): T[];
162
163 /**
164 * Returns a new array from a set of elements.
165 * @param items A set of elements to include in the new array object.
166 */
167 of<T>(...items: T[]): T[];
168}
169
170interface Array<T> {
171 /**
172 * Returns the value of the first element in the array where predicate is true, and undefined
173 * otherwise.
174 * @param predicate find calls predicate once for each element of the array, in ascending
175 * order, until it finds one where predicate returns true. If such an element is found, find
176 * immediately returns that element value. Otherwise, find returns undefined.
177 * @param thisArg If provided, it will be used as the this value for each invocation of
178 * predicate. If it is not provided, undefined is used instead.
179 */
180 find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined;
181
182 /**
183 * Returns the index of the first element in the array where predicate is true, and -1 otherwise.
184 * @param predicate find calls predicate once for each element of the array, in ascending
185 * order, until it finds one where predicate returns true. If such an element is found, find
186 * immediately returns that element value. Otherwise, find returns undefined.
187 * @param thisArg If provided, it will be used as the this value for each invocation of
188 * predicate. If it is not provided, undefined is used instead.
189 */
190 findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
191
192 /**
193 * Returns the this object after filling the section identified by start and end with value
194 * @param value value to fill array section with
195 * @param start index to start filling the array at. If start is negative, it is treated as
196 * length+start where length is the length of the array.
197 * @param end index to stop filling the array at. If end is negative, it is treated as
198 * length+end.
199 */
200 fill(value: T, start?: number, end?: number): T[];
201
202 /**
203 * Returns the this object after copying a section of the array identified by start and end
204 * to the same array starting at position target
205 * @param target If target is negative, it is treated as length+target where length is the
206 * length of the array.
207 * @param start If start is negative, it is treated as length+start. If end is negative, it
208 * is treated as length+end.
209 * @param end If not specified, length of the this object is used as its default value.
210 */
211 copyWithin(target: number, start: number, end?: number): T[];
212
213 /**
214 * Returns an array of key, value pairs for every entry in the array
215 */
216 entries(): IterableIteratorShim<[number, T]>;
217
218 /**
219 * Returns an list of keys in the array
220 */
221 keys(): IterableIteratorShim<number>;
222
223 /**
224 * Returns an list of values in the array
225 */
226 values(): IterableIteratorShim<T>;
227
228 /**
229 * Shim for an ES6 iterable. Not intended for direct use by user code.
230 */
231 "_es6-shim iterator_"(): IterableIteratorShim<T>;
232}
233
234interface NumberConstructor {
235 /**
236 * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
237 * that is representable as a Number value, which is approximately:
238 * 2.2204460492503130808472633361816 x 10‍−‍16.
239 */
240 EPSILON: number;
241
242 /**
243 * Returns true if passed value is finite.
244 * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
245 * number. Only finite values of the type number, result in true.
246 * @param number A numeric value.
247 */
248 isFinite(number: number): boolean;
249
250 /**
251 * Returns true if the value passed is an integer, false otherwise.
252 * @param number A numeric value.
253 */
254 isInteger(number: number): boolean;
255
256 /**
257 * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
258 * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
259 * to a number. Only values of the type number, that are also NaN, result in true.
260 * @param number A numeric value.
261 */
262 isNaN(number: number): boolean;
263
264 /**
265 * Returns true if the value passed is a safe integer.
266 * @param number A numeric value.
267 */
268 isSafeInteger(number: number): boolean;
269
270 /**
271 * The value of the largest integer n such that n and n + 1 are both exactly representable as
272 * a Number value.
273 * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1.
274 */
275 MAX_SAFE_INTEGER: number;
276
277 /**
278 * The value of the smallest integer n such that n and n − 1 are both exactly representable as
279 * a Number value.
280 * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
281 */
282 MIN_SAFE_INTEGER: number;
283
284 /**
285 * Converts a string to a floating-point number.
286 * @param string A string that contains a floating-point number.
287 */
288 parseFloat(string: string): number;
289
290 /**
291 * Converts A string to an integer.
292 * @param s A string to convert into a number.
293 * @param radix A value between 2 and 36 that specifies the base of the number in numString.
294 * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
295 * All other strings are considered decimal.
296 */
297 parseInt(string: string, radix?: number): number;
298}
299
300interface ObjectConstructor {
301 /**
302 * Copy the values of all of the enumerable own properties from one or more source objects to a
303 * target object. Returns the target object.
304 * @param target The target object to copy to.
305 * @param sources One or more source objects to copy properties from.
306 */
307 assign(target: any, ...sources: any[]): any;
308
309 /**
310 * Returns true if the values are the same value, false otherwise.
311 * @param value1 The first value.
312 * @param value2 The second value.
313 */
314 is(value1: any, value2: any): boolean;
315
316 /**
317 * Sets the prototype of a specified object o to object proto or null. Returns the object o.
318 * @param o The object to change its prototype.
319 * @param proto The value of the new prototype or null.
320 * @remarks Requires `__proto__` support.
321 */
322 setPrototypeOf(o: any, proto: any): any;
323}
324
325interface RegExp {
326 /**
327 * Returns a string indicating the flags of the regular expression in question. This field is read-only.
328 * The characters in this string are sequenced and concatenated in the following order:
329 *
330 * - "g" for global
331 * - "i" for ignoreCase
332 * - "m" for multiline
333 * - "u" for unicode
334 * - "y" for sticky
335 *
336 * If no flags are set, the value is the empty string.
337 */
338 flags: string;
339}
340
341interface Math {
342 /**
343 * Returns the number of leading zero bits in the 32-bit binary representation of a number.
344 * @param x A numeric expression.
345 */
346 clz32(x: number): number;
347
348 /**
349 * Returns the result of 32-bit multiplication of two numbers.
350 * @param x First number
351 * @param y Second number
352 */
353 imul(x: number, y: number): number;
354
355 /**
356 * Returns the sign of the x, indicating whether x is positive, negative or zero.
357 * @param x The numeric expression to test
358 */
359 sign(x: number): number;
360
361 /**
362 * Returns the base 10 logarithm of a number.
363 * @param x A numeric expression.
364 */
365 log10(x: number): number;
366
367 /**
368 * Returns the base 2 logarithm of a number.
369 * @param x A numeric expression.
370 */
371 log2(x: number): number;
372
373 /**
374 * Returns the natural logarithm of 1 + x.
375 * @param x A numeric expression.
376 */
377 log1p(x: number): number;
378
379 /**
380 * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
381 * the natural logarithms).
382 * @param x A numeric expression.
383 */
384 expm1(x: number): number;
385
386 /**
387 * Returns the hyperbolic cosine of a number.
388 * @param x A numeric expression that contains an angle measured in radians.
389 */
390 cosh(x: number): number;
391
392 /**
393 * Returns the hyperbolic sine of a number.
394 * @param x A numeric expression that contains an angle measured in radians.
395 */
396 sinh(x: number): number;
397
398 /**
399 * Returns the hyperbolic tangent of a number.
400 * @param x A numeric expression that contains an angle measured in radians.
401 */
402 tanh(x: number): number;
403
404 /**
405 * Returns the inverse hyperbolic cosine of a number.
406 * @param x A numeric expression that contains an angle measured in radians.
407 */
408 acosh(x: number): number;
409
410 /**
411 * Returns the inverse hyperbolic sine of a number.
412 * @param x A numeric expression that contains an angle measured in radians.
413 */
414 asinh(x: number): number;
415
416 /**
417 * Returns the inverse hyperbolic tangent of a number.
418 * @param x A numeric expression that contains an angle measured in radians.
419 */
420 atanh(x: number): number;
421
422 /**
423 * Returns the square root of the sum of squares of its arguments.
424 * @param values Values to compute the square root for.
425 * If no arguments are passed, the result is +0.
426 * If there is only one argument, the result is the absolute value.
427 * If any argument is +Infinity or -Infinity, the result is +Infinity.
428 * If any argument is NaN, the result is NaN.
429 * If all arguments are either +0 or −0, the result is +0.
430 */
431 hypot(...values: number[]): number;
432
433 /**
434 * Returns the integral part of the a numeric expression, x, removing any fractional digits.
435 * If x is already an integer, the result is x.
436 * @param x A numeric expression.
437 */
438 trunc(x: number): number;
439
440 /**
441 * Returns the nearest single precision float representation of a number.
442 * @param x A numeric expression.
443 */
444 fround(x: number): number;
445
446 /**
447 * Returns an implementation-dependent approximation to the cube root of number.
448 * @param x A numeric expression.
449 */
450 cbrt(x: number): number;
451}
452
453interface PromiseLike<T> {
454 /**
455 * Attaches callbacks for the resolution and/or rejection of the Promise.
456 * @param onfulfilled The callback to execute when the Promise is resolved.
457 * @param onrejected The callback to execute when the Promise is rejected.
458 * @returns A Promise for the completion of which ever callback is executed.
459 */
460 then<TResult>(
461 onfulfilled?: (value: T) => TResult | PromiseLike<TResult>,
462 onrejected?: (reason: any) => TResult | PromiseLike<TResult>,
463 ): PromiseLike<TResult>;
464 then<TResult>(
465 onfulfilled?: (value: T) => TResult | PromiseLike<TResult>,
466 onrejected?: (reason: any) => void,
467 ): PromiseLike<TResult>;
468}
469
470/**
471 * Represents the completion of an asynchronous operation
472 */
473interface Promise<T> {
474 /**
475 * Attaches callbacks for the resolution and/or rejection of the Promise.
476 * @param onfulfilled The callback to execute when the Promise is resolved.
477 * @param onrejected The callback to execute when the Promise is rejected.
478 * @returns A Promise for the completion of which ever callback is executed.
479 */
480 then<TResult>(
481 onfulfilled?: (value: T) => TResult | PromiseLike<TResult>,
482 onrejected?: (reason: any) => TResult | PromiseLike<TResult>,
483 ): Promise<TResult>;
484 then<TResult>(
485 onfulfilled?: (value: T) => TResult | PromiseLike<TResult>,
486 onrejected?: (reason: any) => void,
487 ): Promise<TResult>;
488
489 /**
490 * Attaches a callback for only the rejection of the Promise.
491 * @param onrejected The callback to execute when the Promise is rejected.
492 * @returns A Promise for the completion of the callback.
493 */
494 catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
495 catch(onrejected?: (reason: any) => void): Promise<T>;
496}
497
498interface PromiseConstructor {
499 /**
500 * A reference to the prototype.
501 */
502 prototype: Promise<any>;
503
504 /**
505 * Creates a new Promise.
506 * @param executor A callback used to initialize the promise. This callback is passed two arguments:
507 * a resolve callback used to resolve the promise with a value or the result of another promise,
508 * and a reject callback used to reject the promise with a provided reason or error.
509 */
510 new<T>(
511 executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,
512 ): Promise<T>;
513
514 /**
515 * Creates a Promise that is resolved with an array of results when all of the provided Promises
516 * resolve, or rejected when any Promise is rejected.
517 * @param values An array of Promises.
518 * @returns A new Promise.
519 */
520 all<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T[]>;
521
522 /**
523 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
524 * or rejected.
525 * @param values An array of Promises.
526 * @returns A new Promise.
527 */
528 race<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T>;
529
530 /**
531 * Creates a new rejected promise for the provided reason.
532 * @param reason The reason the promise was rejected.
533 * @returns A new rejected Promise.
534 */
535 reject(reason: any): Promise<void>;
536
537 /**
538 * Creates a new rejected promise for the provided reason.
539 * @param reason The reason the promise was rejected.
540 * @returns A new rejected Promise.
541 */
542 reject<T>(reason: any): Promise<T>;
543
544 /**
545 * Creates a new resolved promise for the provided value.
546 * @param value A promise.
547 * @returns A promise whose internal state matches the provided promise.
548 */
549 resolve<T>(value: T | PromiseLike<T>): Promise<T>;
550
551 /**
552 * Creates a new resolved promise .
553 * @returns A resolved promise.
554 */
555 resolve(): Promise<void>;
556}
557
558declare var Promise: PromiseConstructor;
559
560interface Map<K, V> {
561 clear(): void;
562 delete(key: K): boolean;
563 forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
564 get(key: K): V | undefined;
565 has(key: K): boolean;
566 set(key: K, value: V): Map<K, V>;
567 size: number;
568 entries(): IterableIteratorShim<[K, V]>;
569 keys(): IterableIteratorShim<K>;
570 values(): IterableIteratorShim<V>;
571}
572
573interface MapConstructor {
574 new<K, V>(): Map<K, V>;
575 new<K, V>(iterable: IterableShim<[K, V]>): Map<K, V>;
576 prototype: Map<any, any>;
577}
578
579declare var Map: MapConstructor;
580
581interface Set<T> {
582 add(value: T): Set<T>;
583 clear(): void;
584 delete(value: T): boolean;
585 forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
586 has(value: T): boolean;
587 size: number;
588 entries(): IterableIteratorShim<[T, T]>;
589 keys(): IterableIteratorShim<T>;
590 values(): IterableIteratorShim<T>;
591 "_es6-shim iterator_"(): IterableIteratorShim<T>;
592}
593
594interface SetConstructor {
595 new<T>(): Set<T>;
596 new<T>(iterable: IterableShim<T>): Set<T>;
597 prototype: Set<any>;
598}
599
600declare var Set: SetConstructor;
601
602interface WeakMap<K extends object, V> {
603 delete(key: K): boolean;
604 get(key: K): V | undefined;
605 has(key: K): boolean;
606 set(key: K, value: V): WeakMap<K, V>;
607}
608
609interface WeakMapConstructor {
610 new<K extends object, V>(): WeakMap<K, V>;
611 new<K extends object, V>(iterable: IterableShim<[K, V]>): WeakMap<K, V>;
612 prototype: WeakMap<any, any>;
613}
614
615declare var WeakMap: WeakMapConstructor;
616
617interface WeakSet<T> {
618 add(value: T): WeakSet<T>;
619 delete(value: T): boolean;
620 has(value: T): boolean;
621}
622
623interface WeakSetConstructor {
624 new<T>(): WeakSet<T>;
625 new<T>(iterable: IterableShim<T>): WeakSet<T>;
626 prototype: WeakSet<any>;
627}
628
629declare var WeakSet: WeakSetConstructor;
630
631declare namespace Reflect {
632 function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
633 function construct(target: Function, argumentsList: ArrayLike<any>): any;
634 function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
635 function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
636 function enumerate(target: any): IterableIteratorShim<any>;
637 function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
638 function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
639 function getPrototypeOf(target: any): any;
640 function has(target: any, propertyKey: PropertyKey): boolean;
641 function isExtensible(target: any): boolean;
642 function ownKeys(target: any): PropertyKey[];
643 function preventExtensions(target: any): boolean;
644 function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
645 function setPrototypeOf(target: any, proto: any): boolean;
646}
647
648declare module "es6-shim" {
649 var String: StringConstructor;
650 var Array: ArrayConstructor;
651 var Number: NumberConstructor;
652 var Math: Math;
653 var Object: ObjectConstructor;
654 var Map: MapConstructor;
655 var Set: SetConstructor;
656 var WeakMap: WeakMapConstructor;
657 var WeakSet: WeakSetConstructor;
658 var Promise: PromiseConstructor;
659 namespace Reflect {
660 function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
661 function construct(target: Function, argumentsList: ArrayLike<any>): any;
662 function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
663 function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
664 function enumerate(target: any): Iterator<any>;
665 function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
666 function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
667 function getPrototypeOf(target: any): any;
668 function has(target: any, propertyKey: PropertyKey): boolean;
669 function isExtensible(target: any): boolean;
670 function ownKeys(target: any): PropertyKey[];
671 function preventExtensions(target: any): boolean;
672 function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
673 function setPrototypeOf(target: any, proto: any): boolean;
674 }
675}
676
\No newline at end of file