Fixed issue with binding when binding to a falsy object (also added types.isNullOrundefined function).

This commit is contained in:
Nedyalko Nikolov
2015-04-20 14:24:17 +03:00
parent 9550ebc144
commit 6bb533dc30
7 changed files with 25 additions and 10 deletions

9
utils/types.d.ts vendored
View File

@@ -28,12 +28,19 @@
export function isUndefined(value: any): boolean;
/**
* A function that checks if something is defined (not null and not undefined).
* A function that checks if something is defined (not undefined).
* @param value The value which will be checked.
* Returns true if value is defined.
*/
export function isDefined(value: any): boolean;
/**
* A function that checks if something is not defined (null or undefined).
* @param value The value which will be checked.
* Returns true if value is null or undefined.
*/
export function isNullOrUndefined(value: any): boolean;
/**
* A function that checks if something is a valid function.
* @param value The value which will be checked.

View File

@@ -21,6 +21,10 @@ export function isDefined(value: any): boolean {
return typeof value !== "undefined";
}
export function isNullOrUndefined(value: any): boolean {
return (typeof value === "undefined") || (value === null);
}
export function verifyCallback(value: any) {
if (value && !isFunction(value)) {
throw new TypeError("Callback must be a valid function.");