warscript
Version:
A typescript library for Warcraft III using Warpack.
49 lines (48 loc) • 2.45 kB
TypeScript
/** @noSelfInFile */
import { Event } from "../../event";
export type HandleConstructor<H extends jhandle, T extends Handle<H>, Args extends any[]> = new (handle: H, ...args: Args) => T;
export type HandleDestructor = {
readonly __handleDestructor: unique symbol;
};
declare const noOverrideSymbol: unique symbol;
type NoOverride = {
[noOverrideSymbol]: typeof noOverrideSymbol;
};
declare const enum HandlePropertyKey {
STATE = 0
}
export declare class Handle<H extends jhandle, DestroyParameters extends any[] = []> implements Destroyable {
readonly handle: H;
private [HandlePropertyKey.STATE]?;
private onDestroyEvent?;
/**
* @deprecated Do not use the constructor directly, use the factory methods.
* The constructor is public solely for type inference purposes.
*/
constructor(handle: H);
protected static get onCreateEvent(): Event<[any]>;
protected static get onDestroyEvent(): Event<[any]>;
private static get memoized();
static of<H extends jhandle, T extends Handle<H>, Args extends any[] = []>(this: HandleConstructor<H, T, Args>, handle: null, ...args: Args): null;
static of<H extends jhandle, T extends Handle<H>, Args extends any[] = []>(this: HandleConstructor<H, T, Args>, handle: undefined, ...args: Args): undefined;
static of<H extends jhandle, T extends Handle<H>, Args extends any[] = []>(this: HandleConstructor<H, T, Args>, handle: H, ...args: Args): T;
static of<H extends jhandle, T extends Handle<H>, Args extends any[] = []>(this: HandleConstructor<H, T, Args>, handle: H | null, ...args: Args): T | null;
static of<H extends jhandle, T extends Handle<H>, Args extends any[] = []>(this: HandleConstructor<H, T, Args>, handle: H | undefined, ...args: Args): T | undefined;
private static createInternal;
private static invokeOnCreateEvent;
static get onCreate(): Event<[Handle<jhandle>]>;
static get destroyEvent(): Event<[Handle<jhandle>]>;
get destroyEvent(): Event;
toString(): string;
/**
* An overriding function should always call the super one at the end of it,
* in the following manner: `return super.onDestroy()`.
*/
protected onDestroy(...parameters: DestroyParameters): HandleDestructor;
/**
* Frees this handle, and runs any associated destruction hooks.
*/
destroy(...parameters: DestroyParameters): NoOverride;
private static invokeOnDestroyEvent;
}
export {};