UNPKG

20.4 kBTypeScriptView Raw
1// tslint:disable
2/**
3 * Marks an interface or class as not implementable or extendable.
4 *
5 * Makes it an error to pass values that would otherwise match the shape of the interface.
6 *
7 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Opaque-Tag-Symbol) chapter of the main guide for more information.
8 */
9declare const one0: unique symbol;
10/**
11 * Marks an interface or class as not implementable or extendable.
12 *
13 * Makes it an error to pass values that would otherwise match the shape of the interface.
14 *
15 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Opaque-Tag-Symbol) chapter of the main guide for more information.
16 */
17declare const one1: unique symbol;
18
19interface Boolean {
20 readonly [one0]: unique symbol;
21}
22interface BooleanConstructor {
23 readonly [one0]: unique symbol;
24}
25declare const Boolean: BooleanConstructor;
26
27interface Number {
28 readonly [one0]: unique symbol;
29}
30interface NumberConstructor {
31 readonly [one0]: unique symbol;
32}
33declare const Number: NumberConstructor;
34
35interface String {
36 readonly [one0]: unique symbol;
37}
38interface StringConstructor {
39 readonly [one0]: unique symbol;
40}
41declare const String: StringConstructor;
42
43interface Function {}
44interface FunctionConstructor {
45 readonly [one0]: unique symbol;
46}
47declare const Function: FunctionConstructor;
48
49interface CallableFunction extends Function {
50 /**
51 * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
52 * @param thisArg The object to be used as the this object.
53 * @param args An array of argument values to be passed to the function.
54 */
55 apply<T, R>(this: (this: T) => R, thisArg: T): R;
56 apply<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R;
57
58 /**
59 * Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
60 * @param thisArg The object to be used as the this object.
61 * @param args Argument values to be passed to the function.
62 */
63 call<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R;
64
65 /**
66 * For a given function, creates a bound function that has the same body as the original function.
67 * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
68 * @param thisArg The object to be used as the this object.
69 * @param args Arguments to bind to the parameters of the function.
70 */
71 bind<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R;
72 bind<T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R;
73 bind<T, A0, A1, A extends any[], R>(
74 this: (this: T, arg0: A0, arg1: A1, ...args: A) => R,
75 thisArg: T,
76 arg0: A0,
77 arg1: A1,
78 ): (...args: A) => R;
79 bind<T, A0, A1, A2, A extends any[], R>(
80 this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R,
81 thisArg: T,
82 arg0: A0,
83 arg1: A1,
84 arg2: A2,
85 ): (...args: A) => R;
86 bind<T, A0, A1, A2, A3, A extends any[], R>(
87 this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R,
88 thisArg: T,
89 arg0: A0,
90 arg1: A1,
91 arg2: A2,
92 arg3: A3,
93 ): (...args: A) => R;
94 bind<T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R;
95}
96
97interface NewableFunction extends Function {
98 /**
99 * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
100 * @param thisArg The object to be used as the this object.
101 * @param args An array of argument values to be passed to the function.
102 */
103 apply<T>(this: new () => T, thisArg: T): void;
104 apply<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void;
105
106 /**
107 * Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
108 * @param thisArg The object to be used as the this object.
109 * @param args Argument values to be passed to the function.
110 */
111 call<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A): void;
112
113 /**
114 * For a given function, creates a bound function that has the same body as the original function.
115 * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
116 * @param thisArg The object to be used as the this object.
117 * @param args Arguments to bind to the parameters of the function.
118 */
119 bind<A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R;
120 bind<A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R;
121 bind<A0, A1, A extends any[], R>(
122 this: new (arg0: A0, arg1: A1, ...args: A) => R,
123 thisArg: any,
124 arg0: A0,
125 arg1: A1,
126 ): new (...args: A) => R;
127 bind<A0, A1, A2, A extends any[], R>(
128 this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R,
129 thisArg: any,
130 arg0: A0,
131 arg1: A1,
132 arg2: A2,
133 ): new (...args: A) => R;
134 bind<A0, A1, A2, A3, A extends any[], R>(
135 this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R,
136 thisArg: any,
137 arg0: A0,
138 arg1: A1,
139 arg2: A2,
140 arg3: A3,
141 ): new (...args: A) => R;
142 bind<AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R;
143}
144
145interface IArguments {
146 readonly [one0]: unique symbol;
147}
148
149interface Object {}
150interface ObjectConstructor {
151 /**
152 * Returns the names of the enumerable properties and methods of an object.
153 * @param o Object that contains the properties and methods.
154 */
155 readonly keys: (o: {}) => string[];
156 readonly [one0]: unique symbol;
157}
158declare const Object: ObjectConstructor;
159
160interface RegExp {
161 readonly [one0]: unique symbol;
162}
163interface RegExpConstructor {
164 readonly [one0]: unique symbol;
165}
166declare const RegExp: RegExpConstructor;
167
168interface Error {
169 readonly message: string;
170 readonly [one0]: unique symbol;
171}
172interface ErrorConstructor {
173 new (message?: string): Error;
174 readonly [one0]: unique symbol;
175}
176declare const Error: ErrorConstructor;
177
178interface Symbol {
179 readonly [one0]: unique symbol;
180}
181interface SymbolConstructor {
182 /**
183 * Returns a Symbol object from the global symbol registry matching the given key if found.
184 * Otherwise, returns a new symbol with this key.
185 * @param key key to search for.
186 */
187 readonly for: (key: string) => symbol;
188 /**
189 * A method that returns the default iterator for an object. Called by the semantics of the
190 * for-of statement.
191 */
192 readonly iterator: symbol;
193 /**
194 * A method that converts an object to a corresponding primitive value.
195 * Called by the ToPrimitive abstract operation.
196 */
197 readonly toPrimitive: symbol;
198 readonly [one0]: unique symbol;
199}
200declare var Symbol: SymbolConstructor;
201
202// Buffer class
203type BufferEncoding = 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'hex';
204interface Buffer {
205 /**
206 * Gets the length of the array. This is a number one higher than the highest element defined in an array.
207 */
208 readonly length: number;
209 readonly equals: (otherBuffer: Buffer) => boolean;
210 readonly toString: (encoding: 'utf8') => string;
211 readonly toInteger: () => number;
212 /**
213 * Returns a section of a buffer.
214 * @param start The beginning of the specified portion of the buffer.
215 * @param end The end of the specified portion of the buffer.
216 */
217 readonly slice: (start?: number, end?: number) => Buffer;
218 readonly [n: number]: number;
219 readonly [one0]: unique symbol;
220}
221interface BufferConstructor {
222 /**
223 * Creates a new Buffer containing the given JavaScript string {str}.
224 * If provided, the {encoding} parameter identifies the character encoding.
225 * If not provided, {encoding} defaults to 'utf8'.
226 */
227 readonly from: (str: string, encoding?: BufferEncoding) => Buffer;
228 /**
229 * Returns a buffer which is the result of concatenating all the buffers in the list together.
230 *
231 * If the list has no items, then it returns a zero-length buffer.
232 * If the list has one or more items, then a new Buffer is created.
233 *
234 * @param list An array of Buffer objects to concatenate
235 */
236 readonly concat: (list: Buffer[]) => Buffer;
237 readonly [one0]: unique symbol;
238}
239/**
240 * Raw data is stored in instances of the Buffer class.
241 * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
242 * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'hex'
243 */
244declare var Buffer: BufferConstructor;
245
246interface Console {
247 /**
248 * Prints to `stdout` with newline.
249 */
250 readonly log: (message?: any, ...optionalParams: any[]) => void;
251 readonly [one0]: unique symbol;
252}
253
254declare var console: Console;
255
256interface IteratorResult<T> {
257 readonly done: boolean;
258 readonly value: T;
259 readonly [one0]: unique symbol;
260}
261
262interface Iterator<T> {
263 readonly next: (value?: any) => IteratorResult<T>;
264 readonly [one0]: unique symbol;
265}
266
267interface Iterable<T> {
268 readonly [Symbol.iterator]: () => Iterator<T>;
269 readonly [one0]: Iterator<T>[typeof one0];
270}
271
272interface IterableIterator<T> extends Iterator<T> {
273 readonly [Symbol.iterator]: () => IterableIterator<T>;
274 readonly [one1]: unique symbol;
275}
276
277interface ReadonlyArray<T> extends Iterable<T> {
278 readonly [Symbol.iterator]: () => IterableIterator<T>;
279 /**
280 * Gets the length of the array. This is a number one higher than the highest element defined in an array.
281 */
282 readonly length: number;
283 /**
284 * Returns an iterable of key, value pairs for every entry in the array
285 */
286 readonly entries: () => IterableIterator<[number, T]>;
287 /**
288 * Returns a string representation of an array.
289 */
290 readonly toString: () => string;
291 /**
292 * Combines two or more arrays.
293 * @param items Additional items to add to the end of array1.
294 */
295 readonly concat: {
296 <T>(...items: ConcatArray<T>[]): T[];
297 <T>(...items: T[]): T[];
298 <T>(...items: (T | ConcatArray<T>)[]): T[];
299 };
300 /**
301 * Adds all the elements of an array separated by the specified separator string.
302 * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
303 */
304 readonly join: (separator?: string) => string;
305 /**
306 * Returns a section of an array.
307 * @param start The beginning of the specified portion of the array.
308 * @param end The end of the specified portion of the array.
309 */
310 readonly slice: (start?: number, end?: number) => T[];
311 /**
312 * Determines whether all the members of an array satisfy the specified test.
313 * @param callbackfn A function that accepts up to two arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
314 */
315 readonly every: (callbackfn: (value: T, index: number) => boolean) => boolean;
316 /**
317 * Determines whether the specified callback function returns true for any element of an array.
318 * @param callbackfn A function that accepts up to two arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
319 */
320 readonly some: (callbackfn: (value: T, index: number) => boolean) => boolean;
321 /**
322 * Performs the specified action for each element in an array.
323 * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the array.
324 */
325 readonly forEach: (callbackfn: (value: T, index: number) => void) => void;
326 /**
327 * Calls a defined callback function on each element of an array, and returns an array that contains the results.
328 * @param callbackfn A function that accepts up to two arguments. The map method calls the callbackfn function one time for each element in the array.
329 */
330 readonly map: <U>(callbackfn: (value: T, index: number) => U) => U[];
331 /**
332 * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
333 * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
334 * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
335 */
336 readonly reduce: {
337 (callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T;
338 <U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
339 };
340 /**
341 * Returns the elements of an array that meet the condition specified in a callback function.
342 * @param callbackfn A function that accepts up to two arguments. The filter method calls the callbackfn function one time for each element in the array.
343 */
344 readonly filter: {
345 <S extends T>(callbackfn: (value: T, index: number) => value is S): S[];
346 (callbackfn: (value: T, index: number) => any): T[];
347 };
348
349 readonly [n: number]: T;
350 readonly [one1]: unique symbol;
351}
352
353type ConcatArray<T> = Array<T> | ReadonlyArray<T>;
354
355interface Array<T> extends Iterable<T> {
356 readonly [Symbol.iterator]: () => IterableIterator<T>;
357 /**
358 * Gets the length of the array. This is a number one higher than the highest element defined in an array.
359 */
360 readonly length: number;
361 /**
362 * Returns an iterable of key, value pairs for every entry in the array
363 */
364 readonly entries: () => IterableIterator<[number, T]>;
365 /**
366 * Returns a string representation of an array.
367 */
368 readonly toString: () => string;
369 /**
370 * Combines two or more arrays.
371 * @param items Additional items to add to the end of array1.
372 */
373 readonly concat: {
374 <T>(...items: ConcatArray<T>[]): T[];
375 <T>(...items: T[]): T[];
376 <T>(...items: (T | ConcatArray<T>)[]): T[];
377 };
378 /**
379 * Adds all the elements of an array separated by the specified separator string.
380 * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
381 */
382 readonly join: (separator?: string) => string;
383 /**
384 * Returns a section of an array.
385 * @param start The beginning of the specified portion of the array.
386 * @param end The end of the specified portion of the array.
387 */
388 readonly slice: (start?: number, end?: number) => T[];
389 /**
390 * Determines whether all the members of an array satisfy the specified test.
391 * @param callbackfn A function that accepts up to two arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
392 */
393 readonly every: (callbackfn: (value: T, index: number) => boolean) => boolean;
394 /**
395 * Determines whether the specified callback function returns true for any element of an array.
396 * @param callbackfn A function that accepts up to two arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
397 */
398 readonly some: (callbackfn: (value: T, index: number) => boolean) => boolean;
399 /**
400 * Performs the specified action for each element in an array.
401 * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the array.
402 */
403 readonly forEach: (callbackfn: (value: T, index: number) => void) => void;
404 /**
405 * Calls a defined callback function on each element of an array, and returns an array that contains the results.
406 * @param callbackfn A function that accepts up to two arguments. The map method calls the callbackfn function one time for each element in the array.
407 */
408 readonly map: <U>(callbackfn: (value: T, index: number) => U) => U[];
409 // Writable only because it causes wonkiness with tsc otherwise
410 /**
411 * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
412 * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
413 * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
414 */
415 reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T;
416 reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
417 /**
418 * Returns the elements of an array that meet the condition specified in a callback function.
419 * @param callbackfn A function that accepts up to two arguments. The filter method calls the callbackfn function one time for each element in the array.
420 */
421 readonly filter: {
422 <S extends T>(callbackfn: (value: T, index: number) => value is S): S[];
423 (callbackfn: (value: T, index: number) => any): T[];
424 };
425 /**
426 * Removes the last element from an array and returns it.
427 */
428 readonly pop: () => T | undefined;
429 // Writable only because it causes wonkiness with tsc otherwise
430 /**
431 * Appends new elements to an array, and returns the new length of the array.
432 * @param items New elements of the Array.
433 */
434 push(...items: T[]): number;
435
436 [n: number]: T;
437 readonly [one1]: ReadonlyArray<T>[typeof one1];
438}
439interface ArrayConstructor {
440 readonly [one0]: unique symbol;
441}
442declare const Array: ArrayConstructor;
443
444interface Map<K, V> extends Iterable<[K, V]> {
445 readonly [Symbol.iterator]: () => IterableIterator<[K, V]>;
446 readonly forEach: (callbackfn: (value: V, key: K) => void) => void;
447 readonly get: (key: K) => V | undefined;
448 readonly has: (key: K) => boolean;
449 readonly size: number;
450 readonly delete: (key: K) => boolean;
451 readonly set: (key: K, value: V) => this;
452 readonly [one1]: ReadonlyMap<K, V>[typeof one1];
453}
454interface MapConstructor {
455 new <K = any, V = any>(): Map<K, V>;
456 readonly prototype: Map<any, any>;
457 readonly [one0]: unique symbol;
458}
459declare var Map: MapConstructor;
460
461interface ReadonlyMap<K, V> extends Iterable<[K, V]> {
462 readonly [Symbol.iterator]: () => IterableIterator<[K, V]>;
463 readonly forEach: (callbackfn: (value: V, key: K) => void) => void;
464 readonly get: (key: K) => V | undefined;
465 readonly has: (key: K) => boolean;
466 readonly size: number;
467 readonly [one1]: unique symbol;
468}
469
470interface Set<T> extends Iterable<T> {
471 readonly [Symbol.iterator]: () => IterableIterator<T>;
472 readonly forEach: (callbackfn: (value: T) => void) => void;
473 readonly has: (value: T) => boolean;
474 readonly size: number;
475 readonly delete: (value: T) => boolean;
476 readonly add: (value: T) => this;
477 readonly [one1]: ReadonlySet<T>[typeof one1];
478}
479interface SetConstructor {
480 new <T = any>(values?: ReadonlyArray<T>): Set<T>;
481 readonly prototype: Set<any>;
482}
483declare var Set: SetConstructor;
484
485interface ReadonlySet<T> extends Iterable<T> {
486 readonly [Symbol.iterator]: () => IterableIterator<T>;
487 readonly forEach: (callbackfn: (value: T) => void) => void;
488 readonly has: (value: T) => boolean;
489 readonly size: number;
490 readonly [one1]: unique symbol;
491}
492
493interface PropertyDescriptor {
494 configurable?: boolean;
495 enumerable?: boolean;
496 value?: any;
497 writable?: boolean;
498 get?(): any;
499 set?(v: any): void;
500}
501
502interface TypedPropertyDescriptor<T> {
503 enumerable?: boolean;
504 configurable?: boolean;
505 writable?: boolean;
506 value?: T;
507 get?: () => T;
508 set?: (value: T) => void;
509}
510
511interface TemplateStringsArray extends Array<string> {}
512
513type Constructor<T> = new (...args: any[]) => T;
514type Parameters<T extends Function> = T extends (...args: infer U) => any ? U : never;
515type ReturnType<T extends Function> = T extends (...args: any[]) => infer R ? R : never;