/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-var */
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable no-shadow-restricted-names */
/* eslint-disable @typescript-eslint/no-empty-interface */
///
// necessary code for ts to work
// so that for/of works
interface SymbolConstructor {
readonly iterator: unique symbol;
readonly __brand: unique symbol;
}
declare var Symbol: SymbolConstructor;
interface IteratorYieldResult {
done?: false;
value: TYield;
}
interface IteratorReturnResult {
done: true;
value: TReturn;
}
type IteratorResult = IteratorYieldResult | IteratorReturnResult;
interface Iterator {
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
next(...args: [] | [TNext]): IteratorResult;
return?(value?: TReturn): IteratorResult;
throw?(e?: any): IteratorResult;
}
interface IterableIterator extends Iterator {
[Symbol.iterator](): IterableIterator;
}
// end of for/of
declare interface Array {
[Symbol.__brand]: 'array';
[Symbol.iterator](): IterableIterator;
[n: number]: T;
}
declare interface Boolean {
[Symbol.__brand]: 'bool';
}
declare interface Function {
[Symbol.__brand]: 'function';
}
declare interface IArguments {
[Symbol.__brand]: 'array';
[Symbol.iterator](): IterableIterator;
[index: number]: any;
}
declare interface Number {
[Symbol.__brand]: 'int' | 'double';
}
declare interface Object {
[Symbol.__brand]: 'object';
readonly constructor: {
readonly name: string;
};
readonly name: string;
}
// to make decorator works
interface ObjectConstructor {
readonly prototype: Object;
getOwnPropertyDescriptor(o: any, p: PropertyKey): PropertyDescriptor | null;
defineProperty(o: T, p: PropertyKey, attributes: PropertyDescriptor): T;
}
declare var Object: ObjectConstructor;
declare interface RegExp {
[Symbol.__brand]: 'regexp';
}
declare interface String {
[Symbol.__brand]: 'string';
}
declare interface CallableFunction extends Function {}
declare interface NewableFunction extends Function {}
declare type PropertyKey = string;
interface PropertyDescriptor {
configurable?: boolean;
enumerable?: boolean;
get?(): any;
set?(v: any): void;
value?: any;
writable?: boolean;
}
declare interface TypedPropertyDescriptor {
configurable?: boolean;
enumerable?: boolean;
get?: () => T;
set?: (value: T) => void;
value?: T;
writable?: boolean;
}
declare type ClassDecorator = (target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string) => void;
declare type MethodDecorator = (
target: Object,
propertyKey: string,
descriptor: TypedPropertyDescriptor,
) => TypedPropertyDescriptor | void;
declare type ParameterDecorator = (
target: Object,
propertyKey: string,
parameterIndex: number,
) => void;
declare var NaN: number;
declare var Infinity: number;
// taken from typescript lib.es5.d.ts, couldn't find a way to use them directly from there without import...
/**
* Make all properties in T optional
*/
declare type Partial = {
[P in keyof T]?: T[P];
};
/**
* Make all properties in T required
*/
declare type Required = {
[P in keyof T]-?: T[P];
};
/**
* Make all properties in T readonly
*/
declare type Readonly = {
readonly [P in keyof T]: T[P];
};
/**
* From T, pick a set of properties whose keys are in the union K
*/
declare type Pick = {
[P in K]: T[P];
};
/**
* Construct a type with a set of properties K of type T
*/
declare type Record = {
[P in K]: T;
};
/**
* Exclude from T those types that are assignable to U
*/
declare type Exclude = T extends U ? never : T;
/**
* Extract from T those types that are assignable to U
*/
declare type Extract = T extends U ? T : never;
/**
* Construct a type with the properties of T except for those in type K.
*/
declare type Omit = Pick>;
/**
* Exclude null and undefined from T
*/
declare type NonNullable = T & {};
/**
* Obtain the parameters of a function type in a tuple
*/
declare type Parameters any> = T extends (...args: infer P) => any
? P
: never;
/**
* Obtain the parameters of a constructor function type in a tuple
*/
declare type ConstructorParameters any> =
T extends abstract new (...args: infer P) => any ? P : never;
/**
* Obtain the return type of a function type
*/
declare type ReturnType any> = T extends (...args: any) => infer R
? R
: any;
/**
* Obtain the return type of a constructor function type
*/
declare type InstanceType any> = T extends abstract new (
...args: any
) => infer R
? R
: any;
/**
* Convert string literal type to uppercase
*/
declare type Uppercase = intrinsic;
/**
* Convert string literal type to lowercase
*/
declare type Lowercase = intrinsic;
/**
* Convert first character of string literal type to uppercase
*/
declare type Capitalize = intrinsic;
/**
* Convert first character of string literal type to lowercase
*/
declare type Uncapitalize = intrinsic;
/**
* Marker for contextual 'this' type
*/
interface ThisType {}