Implement isDefined and isConstant builtins

This commit is contained in:
dcodeIO
2018-07-14 16:42:00 +02:00
parent 10a9f407bf
commit 3b0fd9aac2
12 changed files with 611 additions and 479 deletions

View File

@ -10,6 +10,10 @@ export declare function isString<T>(value?: T): bool;
export declare function isArray<T>(value?: T): bool;
export declare function isDefined(expression: void): bool;
export declare function isConstant(expression: void): bool;
export const NaN: f64 = 0 / 0;
export const Infinity: f64 = 1 / 0;

View File

@ -304,6 +304,10 @@ declare function isReference<T>(value?: any): value is object | string;
declare function isString<T>(value?: any): value is string | String;
/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */
declare function isArray<T>(value?: any): value is Array<any>;
/** Tests if the specified expression resolves to a defined element. */
declare function isDefined(expression: any): bool;
/** Tests if the specified expression evaluates to a constant value. */
declare function isConstant(expression: any): bool;
/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */
declare function assert<T>(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?
/** Parses an integer string to a 64-bit float. */