diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts
index 9917d217f..55bffe872 100644
--- a/angular-formly/angular-formly.d.ts
+++ b/angular-formly/angular-formly.d.ts
@@ -301,6 +301,17 @@ declare module AngularFormly {
};
+ /**
+ * This allows you to place attributes with string values on the ng-model element.
+ * Easy to use alternative to ngModelAttrs option.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#ngmodelelattrs-object
+ */
+ ngModelElAttrs?: {
+ [key: string]: string;
+ };
+
+
/**
* Used to tell angular-formly to not attempt to add the formControl property to your object. This is useful
* for things like validation, but not necessary if your "field" doesn't use ng-model (if it's just a horizontal
@@ -572,4 +583,4 @@ declare module AngularFormly {
messages: { [key: string]: ($viewValue: any, $modelValue: any, scope: ITemplateScope) => string };
}
-}
\ No newline at end of file
+}
diff --git a/angular-modal/angular-modal-tests.ts b/angular-modal/angular-modal-tests.ts
new file mode 100644
index 000000000..cbb090cee
--- /dev/null
+++ b/angular-modal/angular-modal-tests.ts
@@ -0,0 +1,104 @@
+///
+///
+///
+
+var btfModal: angularModal.AngularModalFactory;
+
+// Using template URL
+function withTemplateUrl() {
+ btfModal({
+ controller: 'SomeController',
+ controllerAs: 'vm',
+ templateUrl: 'some-template.html'
+ });
+}
+
+// Using template
+function withTemplate() {
+ btfModal({
+ controller: 'SomeController',
+ controllerAs: 'vm',
+ template: '
'
+ });
+}
+
+// Using controller function
+function withControllerAsFunction() {
+ btfModal({
+ controller: function () {},
+ template: ''
+ })
+}
+
+// Using constructor function
+function withControllerClass() {
+ class TestController {
+ constructor(dependency1:any, dependency2:any) {}
+ }
+ btfModal({
+ controller: TestController,
+ template: ''
+ });
+}
+
+// With container as selector
+function withContainerAsString() {
+ btfModal({
+ template: '',
+ container: '.container'
+ });
+}
+
+// With container as jQuery element
+function withContainerAsJquery() {
+ var container: JQuery = $('body');
+ btfModal({
+ template: '',
+ container: container
+ });
+}
+
+// With container as DOM Element
+function withContainerAsDom() {
+ var container: Element = document.getElementById('container');
+ btfModal({
+ template: '',
+ container: container
+ });
+}
+
+// With container as DOM Element Array
+function withContainerAsDomArray() {
+ var container: Element[] = [document.getElementById('container'), document.getElementById('container2')];
+ btfModal({
+ template: '',
+ container: container
+ });
+}
+
+// With container as function
+function withContainerAsFunction() {
+ btfModal({
+ template: '',
+ container: function() {}
+ });
+}
+
+// With container as array
+function withContainerAsArray() {
+ btfModal({
+ template: '',
+ container: ['1', 2]
+ });
+}
+
+// Calling return values
+function callingValues() {
+ var modal: angularModal.AngularModal = btfModal({
+ template: ''
+ });
+ modal.activate().then(() => {}, () => {});
+ modal.deactivate().then(() => {}, () => {});
+ var isActive: boolean = modal.active();
+}
+
diff --git a/angular-modal/angular-modal.d.ts b/angular-modal/angular-modal.d.ts
new file mode 100644
index 000000000..0effea95c
--- /dev/null
+++ b/angular-modal/angular-modal.d.ts
@@ -0,0 +1,38 @@
+// Type definitions for angular-modal 0.5.0
+// Project: https://github.com/btford/angular-modal
+// Definitions by: Paul Lessing
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+///
+
+declare module angularModal {
+
+ type AngularModalControllerDefinition = (new (...args: any[]) => any) | Function | string; // Possible arguments to IControllerService
+
+ type AngularModalJQuerySelector = string | Element | Element[] | JQuery | Function | any[] | {}; // Possible arguments to IAugmentedJQueryStatic
+
+ interface AngularModalSettings {
+ controller?: AngularModalControllerDefinition;
+ controllerAs?: string;
+ container?: AngularModalJQuerySelector;
+ }
+
+ export interface AngularModalSettingsWithTemplate extends AngularModalSettings {
+ template: any;
+ }
+
+ export interface AngularModalSettingsWithTemplateUrl extends AngularModalSettings {
+ templateUrl: string;
+ }
+
+ export interface AngularModal {
+ activate(): angular.IPromise;
+ deactivate(): angular.IPromise;
+ active(): boolean;
+ }
+
+ export interface AngularModalFactory {
+ (settings: AngularModalSettingsWithTemplate | AngularModalSettingsWithTemplateUrl): AngularModal;
+ }
+}
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 040622b51..1b54bac2a 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -774,7 +774,7 @@ declare module angular {
* @param reverse Reverse the order of the array.
* @return Reverse the order of the array.
*/
- (array: T[], expression: string|string[]|((value: T) => any)|((value: T) => any)[], reverse?: boolean): T[];
+ (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean): T[];
}
/**
@@ -1660,6 +1660,7 @@ declare module angular {
restrict?: string;
scope?: any;
template?: any;
+ templateNamespace?: string;
templateUrl?: any;
terminal?: boolean;
transclude?: any;
diff --git a/archiver/archiver.d.ts b/archiver/archiver.d.ts
index 570e1424a..e595083d6 100644
--- a/archiver/archiver.d.ts
+++ b/archiver/archiver.d.ts
@@ -16,12 +16,13 @@
///
declare module "archiver" {
import * as FS from 'fs';
+ import * as STREAM from 'stream';
interface nameInterface {
name?: string;
}
- interface Archiver {
+ interface Archiver extends STREAM.Transform {
pipe(writeStream: FS.WriteStream): void;
append(readStream: FS.ReadStream, name: nameInterface): void;
finalize(): void;
@@ -38,4 +39,4 @@ declare module "archiver" {
}
export = archiver;
-}
\ No newline at end of file
+}
diff --git a/bignum/bignum-tests.ts b/bignum/bignum-tests.ts
new file mode 100644
index 000000000..363fad886
--- /dev/null
+++ b/bignum/bignum-tests.ts
@@ -0,0 +1,248 @@
+///
+
+var bignum = require('bignum');
+
+// Test constructors.
+var instance = bignum(16);
+bignum('16');
+bignum(instance);
+
+// Test `toNumber` function.
+instance.toNumber();
+
+bignum.toNumber(4);
+bignum.toNumber('4');
+bignum.toNumber(bignum(4));
+
+// Test `toBuffer` function.
+instance.toBuffer();
+
+bignum.toBuffer(4);
+bignum.toBuffer('4');
+bignum.toBuffer(bignum(4));
+
+// Test `add` function.
+instance.add(4);
+instance.add('4');
+instance.add(bignum(4));
+
+bignum.add(instance, 4);
+bignum.add(instance, '4');
+bignum.add(instance, bignum(4));
+
+// Test `sub` function.
+instance.sub(4);
+instance.sub('4');
+instance.sub(bignum(4));
+
+bignum.sub(instance, 4);
+bignum.sub(instance, '4');
+bignum.sub(instance, bignum(4));
+
+// Test `mul` function.
+instance.mul(4);
+instance.mul('4');
+instance.mul(bignum(4));
+
+bignum.mul(instance, 4);
+bignum.mul(instance, '4');
+bignum.mul(instance, bignum(4));
+
+// Test `div` function.
+instance.div(4);
+instance.div('4');
+instance.div(bignum(4));
+
+bignum.div(instance, 4);
+bignum.div(instance, '4');
+bignum.div(instance, bignum(4));
+
+// Test `abs` function.
+instance.abs();
+bignum.abs(instance);
+
+// Test `neg` function.
+instance.neg();
+bignum.neg(instance);
+
+// Test `cmp` function.
+instance.cmp(4);
+instance.cmp('4');
+instance.cmp(bignum(4));
+
+bignum.cmp(instance, 4);
+bignum.cmp(instance, '4');
+bignum.cmp(instance, bignum(4));
+
+// Test `gt` function.
+instance.gt(4);
+instance.gt('4');
+instance.gt(bignum(4));
+
+bignum.gt(instance, 4);
+bignum.gt(instance, '4');
+bignum.gt(instance, bignum(4));
+
+// Test `ge` function.
+instance.ge(4);
+instance.ge('4');
+instance.ge(bignum(4));
+
+bignum.ge(instance, 4);
+bignum.ge(instance, '4');
+bignum.ge(instance, bignum(4));
+
+// Test `eq` function.
+instance.eq(4);
+instance.eq('4');
+instance.eq(bignum(4));
+
+bignum.eq(instance, 4);
+bignum.eq(instance, '4');
+bignum.eq(instance, bignum(4));
+
+// Test `lt` function.
+instance.lt(4);
+instance.lt('4');
+instance.lt(bignum(4));
+
+bignum.lt(instance, 4);
+bignum.lt(instance, '4');
+bignum.lt(instance, bignum(4));
+
+// Test `le` function.
+instance.le(4);
+instance.le('4');
+instance.le(bignum(4));
+
+bignum.le(instance, 4);
+bignum.le(instance, '4');
+bignum.le(instance, bignum(4));
+
+// Test `and` function.
+instance.and(4);
+instance.and('4');
+instance.and(bignum(4));
+
+bignum.and(instance, 4);
+bignum.and(instance, '4');
+bignum.and(instance, bignum(4));
+
+// Test `or` function.
+instance.or(4);
+instance.or('4');
+instance.or(bignum(4));
+
+bignum.or(instance, 4);
+bignum.or(instance, '4');
+bignum.or(instance, bignum(4));
+
+// Test `xor` function.
+instance.xor(4);
+instance.xor('4');
+instance.xor(bignum(4));
+
+bignum.xor(instance, 4);
+bignum.xor(instance, '4');
+bignum.xor(instance, bignum(4));
+
+// Test `mod` function.
+instance.mod(4);
+instance.mod('4');
+instance.mod(bignum(4));
+
+bignum.mod(instance, 4);
+bignum.mod(instance, '4');
+bignum.mod(instance, bignum(4));
+
+// Test `pow` function.
+instance.pow(4);
+instance.pow('4');
+instance.pow(bignum(4));
+
+bignum.pow(instance, 4);
+bignum.pow(instance, '4');
+bignum.pow(instance, bignum(4));
+
+// Test `powm` function.
+instance.powm(4, 4);
+instance.powm('4', 4);
+instance.powm(bignum(4), 4);
+
+bignum.powm(instance, 4, 4);
+bignum.powm(instance, '4', 4);
+bignum.powm(instance, bignum(4), 4);
+
+instance.powm(4, '4');
+instance.powm('4', '4');
+instance.powm(bignum(4), '4');
+
+bignum.powm(instance, 4, '4');
+bignum.powm(instance, '4', '4');
+bignum.powm(instance, bignum(4), '4');
+
+instance.powm(4, bignum(4));
+instance.powm('4', bignum(4));
+instance.powm(bignum(4), bignum(4));
+
+bignum.powm(instance, 4, bignum(4));
+bignum.powm(instance, '4', bignum(4));
+bignum.powm(instance, bignum(4), bignum(4));
+
+// Test `invertm` function.
+instance.invertm(4);
+instance.invertm('4');
+instance.invertm(bignum(4));
+
+bignum.invertm(instance, 4);
+bignum.invertm(instance, '4');
+bignum.invertm(instance, bignum(4));
+
+// Test `rand` function.
+instance.rand();
+instance.rand(20);
+instance.rand('20');
+instance.rand(bignum(20));
+
+bignum.rand(instance);
+bignum.rand(instance, 20);
+bignum.rand(instance, '20');
+bignum.rand(instance, bignum(20));
+
+// Test `probPrime` function.
+instance.probPrime();
+
+bignum.probPrime(instance);
+
+// Test `shiftLeft` function.
+instance.shiftLeft(4);
+instance.shiftLeft('4');
+instance.shiftLeft(bignum(4));
+
+bignum.shiftLeft(instance, 4);
+bignum.shiftLeft(instance, '4');
+bignum.shiftLeft(instance, bignum(4));
+
+// Test `shiftRight` function.
+instance.shiftRight(4);
+instance.shiftRight('4');
+instance.shiftRight(bignum(4));
+
+bignum.shiftRight(instance, 4);
+bignum.shiftRight(instance, '4');
+bignum.shiftRight(instance, bignum(4));
+
+// Test `gcd` function.
+instance.gcd(bignum(4));
+
+bignum.gcd(instance, bignum(4));
+
+// Test `jacobi` function.
+instance.jacobi(bignum(17));
+
+bignum.jacobi(instance, bignum(17));
+
+// Test `bitLength` function.
+instance.bitLength();
+
+bignum.bitLength(instance);
diff --git a/bignum/bignum.d.ts b/bignum/bignum.d.ts
new file mode 100644
index 000000000..b9e653e18
--- /dev/null
+++ b/bignum/bignum.d.ts
@@ -0,0 +1,269 @@
+// Type definitions for BigNum
+// Project: https://github.com/justmoon/node-BigNum
+// Definitions by: Pat Smuk
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+
+declare class BigNum {
+ /** Create a new BigNum from n. */
+ constructor(n: number|BigNum);
+
+ /** Create a new BigNum from n and a base. */
+ constructor(n: string, base?: number);
+
+ /**
+ * Create a new BigNum from a Buffer.
+ *
+ * The default options are: {endian: 'big', size: 1}.
+ */
+ static fromBuffer(buffer: Buffer, options?: BigNum.BufferOptions): BigNum;
+
+ /**
+ * Generate a probable prime of length bits.
+ *
+ * If safe is true, it will be a "safe" prime of the form p=2p'+1 where p' is also prime.
+ */
+ static prime(bits: number, safe?: boolean): BigNum;
+
+ /** Return true if num is identified as a BigNum instance. Otherwise, return false. */
+ static isBigNum(num: any): boolean;
+
+ /** Print out the BigNum instance in the requested base as a string. Default: base 10 */
+ toString(base?: number): string;
+
+ /**
+ * Turn a BigNum into a Number.
+ *
+ * If the BigNum is too big you'll lose precision or you'll get ±Infinity.
+ */
+ toNumber(): number;
+
+ /**
+ * Return a new Buffer with the data from the BigNum.
+ *
+ * The default options are: {endian: 'big', size: 1}.
+ */
+ toBuffer(options?: BigNum.BufferOptions): Buffer;
+
+ /** Return a new BigNum containing the instance value plus n. */
+ add(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum containing the instance value minus n. */
+ sub(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum containing the instance value multiplied by n. */
+ mul(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum containing the instance value integrally divided by n. */
+ div(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the absolute value of the instance. */
+ abs(): BigNum;
+
+ /** Return a new BigNum with the negative of the instance value. */
+ neg(): BigNum;
+
+ /**
+ * Compare the instance value to n.
+ *
+ * Return a positive integer if > n, a negative integer if < n, and 0 if == n.
+ */
+ cmp(n: BigNum.BigNumCompatible): number;
+
+ /** Return a boolean: whether the instance value is greater than n (> n). */
+ gt(n: BigNum.BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is greater than or equal to n (>= n). */
+ ge(n: BigNum.BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is equal to n (== n). */
+ eq(n: BigNum.BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is less than n (< n). */
+ lt(n: BigNum.BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is less than or equal to n (<= n). */
+ le(n: BigNum.BigNumCompatible): boolean;
+
+ /** Return a new BigNum with the instance value bitwise AND (&)-ed with n. */
+ and(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value bitwise inclusive-OR (|)-ed with n. */
+ or(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value bitwise exclusive-OR (^)-ed with n. */
+ xor(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value modulo n. */
+ mod(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value raised to the nth power. */
+ pow(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value raised to the nth power modulo m. */
+ powm(n: BigNum.BigNumCompatible, m: BigNum.BigNumCompatible): BigNum;
+
+ /** Compute the multiplicative inverse modulo m. */
+ invertm(m: BigNum.BigNumCompatible): BigNum;
+
+ /**
+ * If upperBound is supplied, return a random BigNum between the instance value and upperBound - 1, inclusive.
+ * Otherwise, return a random BigNum between 0 and the instance value - 1, inclusive.
+ */
+ rand(upperBound?: BigNum.BigNumCompatible): BigNum;
+
+ /**
+ * Return whether the BigNum is:
+ * - certainly prime (true)
+ * - probably prime ('maybe')
+ * - certainly composite (false)
+ */
+ probPrime(): boolean | string;
+
+ /** Return a new BigNum that is the 2^n multiple. Equivalent of the << operator. */
+ shiftLeft(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return a new BigNum of the value integer divided by 2^n. Equivalent of the >> operator. */
+ shiftRight(n: BigNum.BigNumCompatible): BigNum;
+
+ /** Return the greatest common divisor of the current BigNum with n as a new BigNum. */
+ gcd(n: BigNum): BigNum;
+
+ /**
+ * Return the Jacobi symbol (or Legendre symbol if n is prime) of the current BigNum (= a) over n.
+ * Note that n must be odd and >= 3. 0 <= a < n.
+ *
+ * Returns -1 or 1 as an int (NOT a BigNum). Throws an error on failure.
+ */
+ jacobi(n: BigNum): number;
+
+ /** Return the number of bits used to represent the current BigNum. */
+ bitLength(): number;
+}
+
+declare namespace BigNum {
+ /** Anything that can be converted to BigNum. */
+ type BigNumCompatible = BigNum | number | string;
+
+ export interface BufferOptions {
+ /** Can be either 'big' or 'little'. Also accepts 1 for big and -1 for little. Doesn't matter when size = 1. */
+ endian: string | number;
+
+ /** Number of bytes per word, or 'auto' to flip entire Buffer. */
+ size: number | string;
+ }
+
+ /**
+ * Turn a BigNum into a Number.
+ *
+ * If the BigNum is too big you'll lose precision or you'll get ±Infinity.
+ */
+ export function toNumber(n: BigNumCompatible): number;
+
+ /**
+ * Return a new Buffer with the data from the BigNum.
+ *
+ * The default options are: {endian: 'big', size: 1}.
+ */
+ export function toBuffer(n: BigNumCompatible, options?: BufferOptions): Buffer;
+
+ /** Return a new BigNum containing the instance value plus n. */
+ export function add(left: BigNumCompatible, right: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum containing the instance value minus n. */
+ export function sub(left: BigNumCompatible, right: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum containing the instance value multiplied by n. */
+ export function mul(left: BigNumCompatible, right: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum containing the instance value integrally divided by n. */
+ export function div(dividend: BigNumCompatible, divisor: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the absolute value of the instance. */
+ export function abs(n: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the negative of the instance value. */
+ export function neg(n: BigNumCompatible): BigNum;
+
+ /**
+ * Compare the instance value to n.
+ *
+ * Return a positive integer if > n, a negative integer if < n, and 0 if == n.
+ */
+ export function cmp(left: BigNumCompatible, right: BigNumCompatible): number;
+
+ /** Return a boolean: whether the instance value is greater than n (> n). */
+ export function gt(left: BigNumCompatible, right: BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is greater than or equal to n (>= n). */
+ export function ge(left: BigNumCompatible, right: BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is equal to n (== n). */
+ export function eq(left: BigNumCompatible, right: BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is less than n (< n). */
+ export function lt(left: BigNumCompatible, right: BigNumCompatible): boolean;
+
+ /** Return a boolean: whether the instance value is less than or equal to n (<= n). */
+ export function le(left: BigNumCompatible, right: BigNumCompatible): boolean;
+
+ /** Return a new BigNum with the instance value bitwise AND (&)-ed with n. */
+ export function and(left: BigNumCompatible, right: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value bitwise inclusive-OR (|)-ed with n. */
+ export function or(left: BigNumCompatible, right: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value bitwise exclusive-OR (^)-ed with n. */
+ export function xor(left: BigNumCompatible, right: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value modulo n. */
+ export function mod(left: BigNumCompatible, right: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value raised to the nth power. */
+ export function pow(base: BigNumCompatible, exponent: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum with the instance value raised to the nth power modulo m. */
+ export function powm(base: BigNumCompatible, exponent: BigNumCompatible, m: BigNumCompatible): BigNum;
+
+ /** Compute the multiplicative inverse modulo m. */
+ export function invertm(n: BigNumCompatible, m: BigNumCompatible): BigNum;
+
+ /**
+ * If upperBound is supplied, return a random BigNum between the instance value and upperBound - 1, inclusive.
+ * Otherwise, return a random BigNum between 0 and the instance value - 1, inclusive.
+ */
+ export function rand(n: BigNumCompatible, upperBound?: BigNumCompatible): BigNum;
+
+ /**
+ * Return whether the BigNum is:
+ * - certainly prime (true)
+ * - probably prime ('maybe')
+ * - certainly composite (false)
+ */
+ export function probPrime(n: BigNumCompatible): boolean | string;
+
+ /** Return a new BigNum that is the 2^bits multiple. Equivalent of the << operator. */
+ export function shiftLeft(n: BigNumCompatible, bits: BigNumCompatible): BigNum;
+
+ /** Return a new BigNum of the value integer divided by 2^bits. Equivalent of the >> operator. */
+ export function shiftRight(n: BigNumCompatible, bits: BigNumCompatible): BigNum;
+
+ /** Return the greatest common divisor of the current BigNum with n as a new BigNum. */
+ export function gcd(left: BigNumCompatible, right: BigNum): BigNum;
+
+ /**
+ * Return the Jacobi symbol (or Legendre symbol if n is prime) of the current BigNum (= a) over n.
+ * Note that n must be odd and >= 3. 0 <= a < n.
+ *
+ * Returns -1 or 1 as an int (NOT a BigNum). Throws an error on failure.
+ */
+ export function jacobi(a: BigNumCompatible, n: BigNum): number;
+
+ /** Return the number of bits used to represent the current BigNum. */
+ export function bitLength(n: BigNumCompatible): number;
+}
+
+declare module "bignum" {
+ export = BigNum;
+}
diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts
index ade461074..bd4f46fc4 100644
--- a/bluebird/bluebird-tests.ts
+++ b/bluebird/bluebird-tests.ts
@@ -80,6 +80,7 @@ var voidProm: Promise;
var fooProm: Promise;
var barProm: Promise;
+var fooOrBarProm: Promise;
var bazProm: Promise;
// - - - - - - - - - - - - - - - - -
@@ -150,6 +151,7 @@ var BlueBird: typeof Promise;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var nodeCallbackFunc = (callback: (err: any, result: string) => void) => {}
+var nodeCallbackFuncErrorOnly = (callback: (err: any) => void) => {}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -225,6 +227,21 @@ barProm = fooProm.then((value: Foo) => {
}, (reason: any) => {
return bar;
});
+barProm = fooProm.then((value: Foo) => {
+ return bar;
+}, (reason: any) => {
+ return barProm;
+});
+barProm = fooProm.then((value: Foo) => {
+ return bar;
+}, (reason: any) => {
+ return;
+});
+barProm = fooProm.then((value: Foo) => {
+ return bar;
+}, (reason: any) => {
+ return voidProm;
+});
barProm = fooProm.then((value: Foo) => {
return bar;
});
@@ -236,36 +253,96 @@ barProm = barProm.then((value: Bar) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-barProm = fooProm.catch((reason: any) => {
+fooProm = fooProm.catch((reason: any) => {
+ return;
+});
+
+fooProm = fooProm.caught((reason: any) => {
+ return;
+});
+fooProm = fooProm.catch((error: any) => {
+ return true;
+}, (reason: any) => {
+ return;
+});
+fooProm = fooProm.caught((error: any) => {
+ return true;
+}, (reason: any) => {
+ return;
+});
+
+fooProm = fooProm.catch((reason: any) => {
+ return voidProm;
+});
+
+fooProm = fooProm.caught((reason: any) => {
+ return voidProm;
+});
+fooProm = fooProm.catch((error: any) => {
+ return true;
+}, (reason: any) => {
+ return voidProm;
+});
+fooProm = fooProm.caught((error: any) => {
+ return true;
+}, (reason: any) => {
+ return voidProm;
+});
+
+fooProm = fooProm.catch((reason: any) => {
+ //handle multiple valid return types simultaneously
+ if (true) {
+ return;
+ } else if (false) {
+ return voidProm;
+ } else if (foo) {
+ return foo;
+ }
+});
+
+fooOrBarProm = fooProm.catch((reason: any) => {
return bar;
});
-barProm = fooProm.caught((reason: any) => {
+fooOrBarProm = fooProm.caught((reason: any) => {
return bar;
});
-barProm = fooProm.catch((reason: any) => {
- return bar;
+fooOrBarProm = fooProm.catch((error: any) => {
+ return true;
}, (reason: any) => {
return bar;
});
-barProm = fooProm.caught((reason: any) => {
- return bar;
+fooOrBarProm = fooProm.caught((error: any) => {
+ return true;
}, (reason: any) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-barProm = fooProm.catch(Error, (reason: any) => {
+fooProm = fooProm.catch(Error, (reason: any) => {
+ return;
+});
+fooProm = fooProm.catch(Promise.CancellationError, (reason: any) => {
+ return;
+});
+fooProm = fooProm.caught(Error, (reason: any) => {
+ return;
+});
+fooProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
+ return;
+});
+
+fooOrBarProm = fooProm.catch(Error, (reason: any) => {
return bar;
});
-barProm = fooProm.catch(Promise.CancellationError, (reason: any) => {
+fooOrBarProm = fooProm.catch(Promise.CancellationError, (reason: any) => {
return bar;
});
-barProm = fooProm.caught(Error, (reason: any) => {
+fooOrBarProm = fooProm.caught(Error, (reason: any) => {
return bar;
});
-barProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
+fooOrBarProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
return bar;
});
@@ -678,6 +755,7 @@ func = Promise.promisify(f, obj);
obj = Promise.promisifyAll(obj);
anyProm = Promise.fromNode(callback => nodeCallbackFunc(callback));
+anyProm = Promise.fromNode(callback => nodeCallbackFuncErrorOnly(callback));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts
index 878e1051e..9f36cf5bc 100644
--- a/bluebird/bluebird.d.ts
+++ b/bluebird/bluebird.d.ts
@@ -25,19 +25,19 @@ declare class Promise implements Promise.Thenable, Promise.Inspection {
/**
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
*/
- then(onFulfill: (value: R) => U|Promise.Thenable, onReject: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- then(onFulfill: (value: R) => U|Promise.Thenable, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise;
-
+ then(onFulfill: (value: R) => U|Promise.Thenable, onReject?: (error: any) => U|Promise.Thenable, onProgress?: (note: any) => any): Promise;
+ then(onFulfill: (value: R) => U|Promise.Thenable, onReject?: (error: any) => void|Promise.Thenable, onProgress?: (note: any) => any): Promise;
+
/**
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
- catch(onReject?: (error: any) => Promise.Thenable): Promise;
- caught(onReject?: (error: any) => Promise.Thenable): Promise;
+ catch(onReject?: (error: any) => R|Promise.Thenable|void|Promise.Thenable): Promise;
+ caught(onReject?: (error: any) => R|Promise.Thenable|void|Promise.Thenable): Promise;
- catch(onReject?: (error: any) => U): Promise;
- caught(onReject?: (error: any) => U): Promise;
+ catch(onReject?: (error: any) => U|Promise.Thenable): Promise;
+ caught(onReject?: (error: any) => U|Promise.Thenable): Promise;
/**
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
@@ -46,17 +46,18 @@ declare class Promise implements Promise.Thenable, Promise.Inspection {
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
- catch(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise;
- caught(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise;
+ catch(predicate: (error: any) => boolean, onReject: (error: any) => R|Promise.Thenable|void|Promise.Thenable): Promise;
+ caught(predicate: (error: any) => boolean, onReject: (error: any) => R|Promise.Thenable|void|Promise.Thenable): Promise;
- catch(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise;
- caught(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise;
+ catch(predicate: (error: any) => boolean, onReject: (error: any) => U|Promise.Thenable): Promise;
+ caught(predicate: (error: any) => boolean, onReject: (error: any) => U|Promise.Thenable): Promise;
- catch(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise;
- caught(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise;
+ catch(ErrorClass: Function, onReject: (error: any) => R|Promise.Thenable|void|Promise.Thenable): Promise;
+ caught(ErrorClass: Function, onReject: (error: any) => R|Promise.Thenable|void|Promise.Thenable): Promise;
+
+ catch(ErrorClass: Function, onReject: (error: any) => U|Promise.Thenable): Promise;
+ caught(ErrorClass: Function, onReject: (error: any) => U|Promise.Thenable): Promise;
- catch(ErrorClass: Function, onReject: (error: any) => U): Promise;
- caught(ErrorClass: Function, onReject: (error: any) => U): Promise;
/**
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
@@ -426,7 +427,7 @@ declare class Promise implements Promise.Thenable, Promise.Inspection {
/**
* Returns a promise that is resolved by a node style callback function.
*/
- static fromNode(resolver: (callback: (err: any, result: any) => void) => void): Promise;
+ static fromNode(resolver: (callback: (err: any, result?: any) => void) => void): Promise;
/**
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
@@ -671,8 +672,8 @@ declare module Promise {
export function OperationalError(): OperationalError;
export interface Thenable {
- then(onFulfilled: (value: R) => U|Thenable, onRejected: (error: any) => Thenable): Thenable;
- then(onFulfilled: (value: R) => U|Thenable, onRejected?: (error: any) => U): Thenable;
+ then(onFulfilled: (value: R) => U|Thenable, onRejected?: (error: any) => U|Thenable): Thenable;
+ then(onFulfilled: (value: R) => U|Thenable, onRejected?: (error: any) => void|Thenable): Thenable;
}
export interface Resolver {
diff --git a/bookshelf/bookshelf-tests.ts b/bookshelf/bookshelf-tests.ts
new file mode 100644
index 000000000..67580dae5
--- /dev/null
+++ b/bookshelf/bookshelf-tests.ts
@@ -0,0 +1,100 @@
+///
+///
+
+import * as Knex from 'knex';
+import * as Bookshelf from 'bookshelf';
+
+var knex = Knex({
+ client: 'sqlite3',
+ connection: {
+ filename: ':memory:',
+ },
+});
+
+// Examples
+
+var bookshelf = Bookshelf(knex);
+
+class User extends bookshelf.Model {
+ get tableName() { return 'users'; }
+ messages() : Bookshelf.Collection {
+ return this.hasMany(Posts);
+ }
+}
+
+class Posts extends bookshelf.Model {
+ get tableName() { return 'messages'; }
+ tags() : Bookshelf.Collection {
+ return this.belongsToMany(Tag);
+ }
+}
+
+class Tag extends bookshelf.Model {
+ get tableName() { return 'tags'; }
+}
+
+new User({}).where('id', 1).fetch({withRelated: ['posts.tags']})
+.then(user => {
+ console.log(user.related('posts').toJSON());
+}).catch(err => {
+ console.error(err);
+});
+
+
+// Associations
+
+class Book extends bookshelf.Model {
+ get tableName() { return 'books'; }
+ summary() {
+ return this.hasOne(Summary);
+ }
+ pages() {
+ return this.hasMany(Pages);
+ }
+ authors() {
+ return this.belongsToMany(Author);
+ }
+}
+
+class Summary extends bookshelf.Model {
+ get tableName() { return 'summaries'; }
+ book() : Book {
+ return this.belongsTo(Book);
+ }
+}
+
+class Pages extends bookshelf.Model {
+ get tableName() { return 'pages'; }
+ book() {
+ return this.belongsTo(Book);
+ }
+}
+
+class Author extends bookshelf.Model {
+ get tableName() { return 'author'; }
+ books() {
+ return this.belongsToMany(Book);
+ }
+}
+
+class Site extends bookshelf.Model {
+ get tableName() { return 'sites'; }
+ photo() {
+ return this.morphOne(Photo, 'imageable');
+ }
+}
+
+class Post extends bookshelf.Model {
+ get tableName() { return 'posts'; }
+ photos() {
+ return this.morphMany(Photo, 'imageable');
+ }
+}
+
+class Photo extends bookshelf.Model {
+ get tableName() { return 'photos'; }
+ imageable() {
+ return this.morphTo('imageable', Site, Post);
+ }
+}
+
diff --git a/bookshelf/bookshelf-tests.ts.tscparams b/bookshelf/bookshelf-tests.ts.tscparams
new file mode 100644
index 000000000..5f84b9777
--- /dev/null
+++ b/bookshelf/bookshelf-tests.ts.tscparams
@@ -0,0 +1 @@
+--noImplicitAny --module commonjs --target es5
diff --git a/bookshelf/bookshelf.d.ts b/bookshelf/bookshelf.d.ts
new file mode 100644
index 000000000..0da1ce2d6
--- /dev/null
+++ b/bookshelf/bookshelf.d.ts
@@ -0,0 +1,313 @@
+// Type definitions for bookshelfjs v0.8.2
+// Project: http://bookshelfjs.org/
+// Definitions by: Andrew Schurman
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+///
+
+declare module 'bookshelf' {
+ import knex = require('knex');
+ import Promise = require('bluebird');
+ import Lodash = require('lodash');
+
+ interface Bookshelf extends Bookshelf.Events {
+ VERSION : string;
+ knex : knex;
+ Model : typeof Bookshelf.Model;
+ Collection : typeof Bookshelf.Collection;
+
+ transaction(callback : (transaction : knex.Transaction) => T) : Promise;
+ }
+
+ function Bookshelf(knex : knex) : Bookshelf;
+
+ namespace Bookshelf {
+ abstract class Events {
+ on(event? : string, callback? : EventFunction, context? : any) : void;
+ off(event? : string) : void;
+ trigger(event? : string, ...args : any[]) : void;
+ triggerThen(name : string, ...args : any[]) : Promise;
+ once(event : string, callback : EventFunction, context? : any) : void;
+ }
+
+ interface IModelBase {
+ /** Should be declared as a getter instead of a plain property. */
+ hasTimestamps? : boolean|string[];
+ /** Should be declared as a getter instead of a plain property. Should be required, but cannot have abstract properties yet. */
+ tableName? : string;
+ }
+
+ abstract class ModelBase> extends Events> implements IModelBase {
+ /** If overriding, must use a getter instead of a plain property. */
+ idAttribute : string;
+
+ constructor(attributes? : any, options? : ModelOptions);
+
+ clear() : T;
+ clone() : T;
+ escape(attribute : string) : string;
+ format(attributes : any) : any;
+ get(attribute : string) : any;
+ has(attribute : string) : boolean;
+ hasChanged(attribute? : string) : boolean;
+ isNew() : boolean;
+ parse(response : any) : any;
+ previousAttributes() : any;
+ previous(attribute : string) : any;
+ related>(relation : string) : R | Collection;
+ serialize(options? : SerializeOptions) : any;
+ set(attribute?: {[key : string] : any}, options? : SetOptions) : T;
+ set(attribute : string, value? : any, options? : SetOptions) : T;
+ timestamp(options? : TimestampOptions) : any;
+ toJSON(options? : SerializeOptions) : any;
+ unset(attribute : string) : T;
+
+ // lodash methods
+ invert() : R;
+ keys() : string[];
+ omit(predicate? : Lodash.ObjectIterator, thisArg? : any) : R;
+ omit(...attributes : string[]) : R;
+ pairs() : any[][];
+ pick(predicate? : Lodash.ObjectIterator, thisArg? : any) : R;
+ pick(...attributes : string[]) : R;
+ values() : any[];
+ }
+
+ class Model> extends ModelBase {
+ static collection>(models? : T[], options? : CollectionOptions) : Collection;
+ static count(column? : string, options? : SyncOptions) : Promise;
+ /** @deprecated use Typescript classes */
+ static extend>(prototypeProperties? : any, classProperties? : any) : Function; // should return a type
+ static fetchAll>() : Promise>;
+ /** @deprecated should use `new` objects instead. */
+ static forge(attributes? : any, options? : ModelOptions) : T;
+
+ belongsTo>(target : {new(...args : any[]) : R}, foreignKey? : string) : R;
+ belongsToMany>(target : {new(...args : any[]) : R}, table? : string, foreignKey? : string, otherKey? : string) : Collection;
+ count(column? : string, options? : SyncOptions) : Promise;
+ destroy(options : SyncOptions) : void;
+ fetch(options? : FetchOptions) : Promise;
+ fetchAll(options? : FetchAllOptions) : Promise>;
+ hasMany>(target : {new(...args : any[]) : R}, foreignKey? : string) : Collection;
+ hasOne>(target : {new(...args : any[]) : R}, foreignKey? : string) : R;
+ load(relations : string|string[], options? : LoadOptions) : Promise;
+ morphMany>(target : {new(...args : any[]) : R}, name? : string, columnNames? : string[], morphValue? : string) : Collection;
+ morphOne>(target : {new(...args : any[]) : R}, name? : string, columnNames? : string[], morphValue? : string) : R;
+ morphTo(name : string, columnNames? : string[], ...target : typeof Model[]) : T;
+ morphTo(name : string, ...target : typeof Model[]) : T;
+ query(...query : string[]) : T;
+ query(query : {[key : string] : any}) : T;
+ query(callback : (qb : knex.QueryBuilder) => void) : T;
+ query() : knex.QueryBuilder;
+ refresh(options? : FetchOptions) : Promise;
+ resetQuery() : T;
+ save(key? : string, val? : string, options? : SaveOptions) : Promise;
+ save(attrs? : {[key : string] : any}, options? : SaveOptions) : Promise;
+ through>(interim : typeof Model, throughForeignKey? : string, otherKey? : string) : R | Collection;
+ where(properties : {[key : string] : any}) : T;
+ where(key : string, operatorOrValue : string|number|boolean, valueIfOperator? : string|number|boolean) : T;
+ }
+
+ abstract class CollectionBase> extends Events {
+ add(models : T[]|{[key : string] : any}[], options? : CollectionAddOptions) : Collection;
+ at(index : number) : T;
+ clone() : Collection;
+ fetch(options? : CollectionFetchOptions) : Promise>;
+ findWhere(match : {[key : string] : any}) : T;
+ get(id : any) : T;
+ invokeThen(name : string, ...args : any[]) : Promise;
+ parse(response : any) : any;
+ pluck(attribute : string) : any[];
+ pop() : void;
+ push(model : any) : Collection;
+ reduceThen(iterator : (prev : R, cur : T, idx : number, array : T[]) => R, initialValue : R, context : any) : Promise;
+ remove(model : T, options? : EventOptions) : T;
+ remove(model : T[], options? : EventOptions) : T[];
+ reset(model : any[], options? : CollectionAddOptions) : T[];
+ serialize(options? : SerializeOptions) : any;
+ set(models : T[]|{[key : string] : any}[], options? : CollectionSetOptions) : Collection;
+ shift(options? : EventOptions) : void;
+ slice(begin? : number, end? : number) : void;
+ toJSON(options? : SerializeOptions) : any;
+ unshift(model : any, options? : CollectionAddOptions) : void;
+ where(match : {[key : string] : any}, firstOnly : boolean) : T|Collection;
+
+ // lodash methods
+ all(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : boolean;
+ all(predicate? : R) : boolean;
+ any(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : boolean;
+ any(predicate? : R) : boolean;
+ chain() : Lodash.LoDashExplicitObjectWrapper;
+ collect(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : T[];
+ collect(predicate? : R) : T[];
+ contains(value : any, fromIndex? : number) : boolean;
+ countBy(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : Lodash.Dictionary;
+ countBy(predicate? : R) : Lodash.Dictionary;
+ detect(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : T;
+ detect(predicate? : R) : T;
+ difference(...values : T[]) : T[];
+ drop(n? : number) : T[];
+ each(callback? : Lodash.ListIterator, thisArg? : any) : Lodash.List;
+ each(callback? : Lodash.DictionaryIterator, thisArg? : any) : Lodash.Dictionary;
+ each(callback? : Lodash.ObjectIterator, thisArg? : any) : T;
+ every(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : boolean;
+ every(predicate? : R) : boolean;
+ filter(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : T[];
+ filter(predicate? : R) : T[];
+ find(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : T;
+ find(predicate? : R) : T;
+ first() : T;
+ foldl(callback? : Lodash.MemoIterator, accumulator? : R, thisArg? : any) : R;
+ foldr(callback? : Lodash.MemoIterator, accumulator? : R, thisArg? : any) : R;
+ forEach(callback? : Lodash.ListIterator, thisArg? : any) : Lodash.List;
+ forEach(callback? : Lodash.DictionaryIterator, thisArg? : any) : Lodash.Dictionary;
+ forEach(callback? : Lodash.ObjectIterator, thisArg? : any) : T;
+ groupBy(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : Lodash.Dictionary;
+ groupBy(predicate? : R) : Lodash.Dictionary;
+ head() : T;
+ include(value : any, fromIndex? : number) : boolean;
+ indexOf(value : any, fromIndex? : number) : number;
+ initial() : T[];
+ inject(callback? : Lodash.MemoIterator, accumulator? : R, thisArg? : any) : R;
+ invoke(methodName : string|Function, ...args : any[]) : any;
+ isEmpty() : boolean;
+ keys() : string[];
+ last() : T;
+ lastIndexOf(value : any, fromIndex? : number) : number;
+ map(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : T[];
+ map(predicate? : R) : T[];
+ max(predicate? : Lodash.ListIterator|string, thisArg? : any) : T;
+ max(predicate? : R) : T;
+ min(predicate? : Lodash.ListIterator|string, thisArg? : any) : T;
+ min(predicate? : R) : T;
+ reduce(callback? : Lodash.MemoIterator, accumulator? : R, thisArg? : any) : R;
+ reduceRight(callback? : Lodash.MemoIterator, accumulator? : R, thisArg? : any) : R;
+ reject(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : T[];
+ reject(predicate? : R) : T[];
+ rest() : T[];
+ select(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator