From 85eabfe63b58f4b03e9afee11f4f778e5c9330cc Mon Sep 17 00:00:00 2001 From: Andrew Gaspar Date: Wed, 3 Jul 2013 01:36:17 -0700 Subject: [PATCH 01/16] Added typings to jQuery promises and deferreds. --- jquery/jquery-tests.ts | 3 +- jquery/jquery.d.ts | 67 +++++++++++++++++++++++++++++------------- q/Q-tests.ts | 2 +- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index fbee85509..01f75a985 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -940,8 +940,7 @@ function test_deferred() { filtered.done(function (data) { }); function asyncEvent() { - var newDeferred = new jQuery.Deferred(); - var dfd: JQueryDeferred; + var dfd: JQueryDeferred = $.Deferred(); setTimeout(function () { dfd.resolve("hurray"); }, Math.floor(400 + Math.random() * 2000)); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index c66b283f8..5254e98b1 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -57,7 +57,7 @@ interface JQueryAjaxSettings { /* Interface for the jqXHR object */ -interface JQueryXHR extends XMLHttpRequest, JQueryPromise { +interface JQueryXHR extends XMLHttpRequest, JQueryPromise { overrideMimeType(mimeType: string); abort(statusText?: string): void; } @@ -78,33 +78,61 @@ interface JQueryCallback { remove(...callbacks: any[]): any; } +/* + Allows jQuery Promises to interop with non-jQuery promises +*/ +interface JQueryGenericPromise { + then(onFulfill: (value: T) => U, onReject?: (reason) => U): JQueryGenericPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason) => U): JQueryGenericPromise; + then(onFulfill: (value: T) => U, onReject?: (reason) => JQueryGenericPromise): JQueryGenericPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason) => JQueryGenericPromise): JQueryGenericPromise; +} + /* Interface for the JQuery promise, part of callbacks */ -interface JQueryPromise { - always(...alwaysCallbacks: any[]): JQueryDeferred; - done(...doneCallbacks: any[]): JQueryDeferred; - fail(...failCallbacks: any[]): JQueryDeferred; +interface JQueryPromise { + always(...alwaysCallbacks: any[]): JQueryPromise; + done(...doneCallbacks: any[]): JQueryPromise; + fail(...failCallbacks: any[]): JQueryPromise; + progress(...progressCallbacks: any[]): JQueryPromise; + + // Deprecated - given no typings pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; - then(doneCallbacks: any, failCallbacks?: any, progressCallbacks?: any): JQueryDeferred; + + then(onFulfill: (value: T) => U, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (value: T) => U, onReject?: (...reasons) => JQueryGenericPromise, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons) => JQueryGenericPromise, onProgress?: (...progression) => any): JQueryPromise; + + /* Because JQuery Promises Suck */ + then(onFulfill: (...args) => U, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (...args) => JQueryGenericPromise, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (...args) => U, onReject?: (...reasons) => JQueryGenericPromise, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (...args) => JQueryGenericPromise, onReject?: (...reasons) => JQueryGenericPromise, onProgress?: (...progression) => any): JQueryPromise; } /* Interface for the JQuery deferred, part of callbacks */ -interface JQueryDeferred extends JQueryPromise { - notify(...args: any[]): JQueryDeferred; - notifyWith(context: any, ...args: any[]): JQueryDeferred; +interface JQueryDeferred extends JQueryPromise { + always(...alwaysCallbacks: any[]): JQueryDeferred; + done(...doneCallbacks: any[]): JQueryDeferred; + fail(...failCallbacks: any[]): JQueryDeferred; + progress(...progressCallbacks: any[]): JQueryDeferred; - pipe(doneFilter?: any, failFilter?: any, progressFilter?: any): JQueryPromise; - progress(...progressCallbacks: any[]): JQueryDeferred; - reject(...args: any[]): JQueryDeferred; - rejectWith(context: any, ...args: any[]): JQueryDeferred; - resolve(...args: any[]): JQueryDeferred; - resolveWith(context: any, ...args: any[]): JQueryDeferred; + notify(...args: any[]): JQueryDeferred; + notifyWith(context: any, ...args: any[]): JQueryDeferred; + + reject(...args: any[]): JQueryDeferred; + rejectWith(context: any, ...args: any[]): JQueryDeferred; + + resolve(val: T): JQueryDeferred; + resolve(...args: any[]): JQueryDeferred; + resolveWith(context: any, ...args: any[]): JQueryDeferred; state(): string; - then(doneCallbacks: any, failCallbacks?: any, progressCallbacks?: any): JQueryDeferred; - promise(target?: any): JQueryPromise; + + promise(target?: any): JQueryPromise; } /* @@ -260,10 +288,7 @@ interface JQueryStatic { removeData(element: Element, name?: string): JQuery; // Deferred - Deferred: { - (beforeStart?: (deferred: JQueryDeferred) => any): JQueryDeferred; - new (beforeStart?: (deferred: JQueryDeferred) => any): JQueryDeferred; - }; + Deferred(beforeStart?: (deferred: JQueryDeferred) => any): JQueryDeferred; // Effects fx: { tick: () => void; interval: number; stop: () => void; speeds: { slow: number; fast: number; }; off: boolean; step: any; }; diff --git a/q/Q-tests.ts b/q/Q-tests.ts index 943f2bb4e..d647fabde 100644 --- a/q/Q-tests.ts +++ b/q/Q-tests.ts @@ -73,7 +73,7 @@ Q(arrayPromise) // type specification required .then(returnsNumPromise) // requires specification .then(num => num.toFixed()); -declare var jPromise: JQueryPromise; +declare var jPromise: JQueryPromise; // if jQuery promises definition supported generics, this could be more interesting example Q(jPromise).then((val) => val.toExponential()); From f83fb6805bc1630792f7503f3ec4b56565e7049d Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Fri, 5 Jul 2013 01:03:30 -0400 Subject: [PATCH 02/16] Support for more RxJS packages + bool => boolean for TS0.9 --- rx.js/rx.js.aggregates.d.ts | 48 +++++++++++++++++++---- rx.js/rx.js.binding.d.ts | 42 ++++++++++++++++++++ rx.js/rx.js.coincidence.d.ts | 40 +++++++++++++++++++ rx.js/rx.js.d.ts | 15 ++----- rx.js/rx.js.html.d.ts | 8 ---- rx.js/rx.js.joinpatterns.d.ts | 20 ++++++++++ rx.js/rx.js.jquery.d.ts | 21 +++++++--- rx.js/rx.js.time.d.ts | 73 +++++++++++++++++++++++++++++++++++ 8 files changed, 234 insertions(+), 33 deletions(-) create mode 100644 rx.js/rx.js.binding.d.ts create mode 100644 rx.js/rx.js.coincidence.d.ts delete mode 100644 rx.js/rx.js.html.d.ts create mode 100644 rx.js/rx.js.joinpatterns.d.ts diff --git a/rx.js/rx.js.aggregates.d.ts b/rx.js/rx.js.aggregates.d.ts index 16426a96e..93a304db4 100644 --- a/rx.js/rx.js.aggregates.d.ts +++ b/rx.js/rx.js.aggregates.d.ts @@ -1,19 +1,53 @@ /// -// Type definitions for RxJS "Aggregates" +// Type definitions for RxJS-Aggregates package // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Dependencies: +// -> rx.js +// -> rx.aggregates.js declare module Rx { interface IObservable { - all(predicate?: (value: T) => bool): IObservable; - min(comparer?: (value1: T, value2: T) => number): IObservable; - max(comparer?: (value1: T, value2: T) => number): IObservable; - count(predicate?: (item: T) => bool): IObservable; + aggregate(accumulator: (acc: TAcc, value: T) => TAcc): IObservable; + aggregate(seed: TAcc, accumulator: (acc: TAcc, value: T) => TAcc): IObservable; + + any(): IObservable; + any(selector: (item: T) => boolean): IObservable; + + isEmpty(predicate?: (value: T) => boolean): IObservable; + all(predicate?: (value: T) => boolean): IObservable; + contains(value: T, comparer?: (value1: T, value2: T) => boolean): IObservable; + count(predicate?: (item: T) => boolean): IObservable; sum(keySelector?: (item: T) => number): IObservable; - isEmpty(predicate?: (value: T) => bool): IObservable; - contains(value: T, comparer?: (value1: T, value2: T) => bool): IObservable; + minBy(keySelector: (item: T) => number, comparer?: (value1: T, value2: T) => number): IObservable; + min(comparer?: (value1: T, value2: T) => number): IObservable; + maxBy(keySelector: (item: T) => number, comparer?: (value1: T, value2: T) => number): IObservable; + max(comparer?: (value1: T, value2: T) => number): IObservable; average(keySelector?: (item: T) => number): IObservable; + + sequenceEqual(second: IObservable, comparer?: (value1: T, value2: T) => number): IObservable; + elementAt(index: number): IObservable; + elementAtOrDefault(index: number, defaultValue: T): IObservable; + + single(): IObservable; + single(predicate: (T) => boolean): IObservable; + singleOrDefault(): IObservable; + singleOrDefault(predicate: (T) => boolean): IObservable; + singleOrDefault(predicate: (T) => boolean, defaultValue: T): IObservable; + + first(): IObservable; + first(predicate: (T) => boolean): IObservable; + firstOrDefault(): IObservable; + firstOrDefault(predicate: (T) => boolean): IObservable; + firstOrDefault(predicate: (T) => boolean, defaultValue: T): IObservable; + + last(): IObservable; + last(predicate: (T) => boolean): IObservable; + lastOrDefault(): IObservable; + lastOrDefault(predicate: (T) => boolean): IObservable; + lastOrDefault(predicate: (T) => boolean, defaultValue: T): IObservable; } } \ No newline at end of file diff --git a/rx.js/rx.js.binding.d.ts b/rx.js/rx.js.binding.d.ts new file mode 100644 index 000000000..e2d4bfd98 --- /dev/null +++ b/rx.js/rx.js.binding.d.ts @@ -0,0 +1,42 @@ +/// + +// Type definitions for RxJS-Binding package +// Project: http://rx.codeplex.com/ +// Definitions by: Carl de Billy +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Dependencies: +// -> rx.js +// -> rx.binding.js + +declare module Rx { + + interface ReplaySubject extends ISubject { + new (bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject; + } + + interface BehaviorSubject extends ISubject { + new (initialValue: T): BehaviorSubject; + } + + interface ConnectableObservable extends IObservable{ + connect(): _IDisposable; + refCount(): IObservable; + } + + interface IObservable { + + publish(): ConnectableObservable; + publish(selector: (item: T) => IObservable): ConnectableObservable; + publishLast(): ConnectableObservable; + publishLast(selector: (item: T) => IObservable): ConnectableObservable; + publishValue(initialValue: T): ConnectableObservable; + publishValue(selector: (item: T) => TResult, initialValue: TResult): ConnectableObservable; + + replay(selector?: (source: IObservable) => ReplaySubject, bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject; + } + + + interface Observable { + } +} diff --git a/rx.js/rx.js.coincidence.d.ts b/rx.js/rx.js.coincidence.d.ts new file mode 100644 index 000000000..138e99236 --- /dev/null +++ b/rx.js/rx.js.coincidence.d.ts @@ -0,0 +1,40 @@ +/// + +// Type definitions for RxJS-Coincidence package +// Project: http://rx.codeplex.com/ +// Definitions by: Carl de Billy +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Dependencies: +// -> rx.js +// -> rx.coincidence.js + +declare module Rx { + + interface IObservable { + join( + right: IObservable, + leftDurationSelector: (leftItem: T) => IObservable, + rightDurationSelector: (rightItem: T2) => IObservable, + resultSelector: (leftItem: T, rightItem: T2) => TResult): IObservable; + + groupJoin( + right: IObservable, + leftDurationSelector: (leftItem: T) => IObservable, + rightDurationSelector: (rightItem: T2) => IObservable, + resultSelector: (leftItem: T, rightItem: IObservable) => TResult): IObservable; + + + // lack of documentation to complete the followings... + + buffer(bufferOpenings: IObservable, + bufferClosingSelector: (opening: TBufferOpening) => IObservable): IObservable; + + window(bufferOpenings: IObservable, + bufferClosingSelector: (opening: TBufferOpening) => IObservable): IObservable; + } + + + interface Observable { + } +} diff --git a/rx.js/rx.js.d.ts b/rx.js/rx.js.d.ts index 1cce070dc..742694431 100644 --- a/rx.js/rx.js.d.ts +++ b/rx.js/rx.js.d.ts @@ -314,6 +314,7 @@ declare module Rx { observeOn(scheduler: IScheduler): IObservable; subscribeOn(scheduler: IScheduler): IObservable; + amb(rightSource: IObservable): IObservable; catchException(handler: (exception: any) =>IObservable): IObservable; catchException(second: IObservable): IObservable; @@ -369,16 +370,6 @@ declare module Rx { take(count: number, scheduler?: IScheduler): IObservable; takeWhile(predicate: (value: T, index?: number) =>bool): IObservable; where(predicate: (value: T, index?: number) => bool): IObservable; - - // time - delay(dueTime: number, scheduler?: IScheduler): IObservable; - throttle(dueTime: number, scheduler?: IScheduler): IObservable; - windowWithTime(dueTime: number, timeShiftOrScheduler?: any, scheduler?: IScheduler): IObservable; - timeInterval(scheduler: IScheduler): IObservable; - sample(interval: number, scheduler?: IScheduler): IObservable; - sample(sampler: IObservable, scheduler?: IScheduler): IObservable; - timeout(dueTime: number, other?: IObservable, scheduler?: IScheduler): IObservable; - delaySubscription(dueTime: number, scheduler?: IScheduler): IObservable; } interface Observable { @@ -387,9 +378,9 @@ declare module Rx { start(func: () =>T, scheduler?: IScheduler, context?: any): IObservable; toAsync(func: Function, scheduler?: IScheduler, context?: any): (...arguments: any[]) => IObservable; create(subscribe: (observer: IObserver) => void ): IObservable; - create(subscribe: (observer: IObserver) => () => void ): IObservable; + //create(subscribe: (observer: IObserver) => () => void ): IObservable; createWithDisposable(subscribe: (observer: IObserver) =>_IDisposable): IObservable; - defer(observableFactory: () =>IObservable): IObservable; + defer(observableFactory: () => IObservable): IObservable; empty(scheduler?: IScheduler): IObservable; fromArray(array: T[], scheduler?: IScheduler): IObservable; fromArray(array: { length: number;[index: number]: T; }, scheduler?: IScheduler): IObservable; diff --git a/rx.js/rx.js.html.d.ts b/rx.js/rx.js.html.d.ts deleted file mode 100644 index e1dcf69dd..000000000 --- a/rx.js/rx.js.html.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -declare module Rx { - interface Observable { - fromEvent(element: HTMLElement, eventName: string): IObservable; - fromEvent(document: HTMLDocument, eventName: string): IObservable; - } -} \ No newline at end of file diff --git a/rx.js/rx.js.joinpatterns.d.ts b/rx.js/rx.js.joinpatterns.d.ts new file mode 100644 index 000000000..a62b1914d --- /dev/null +++ b/rx.js/rx.js.joinpatterns.d.ts @@ -0,0 +1,20 @@ +/// + +// Type definitions for RxJS-Join package +// Project: http://rx.codeplex.com/ +// Definitions by: Carl de Billy +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Dependencies: +// -> rx.js +// -> rx.joinpatterns.js + +declare module Rx { + + //interface IObservable { + //} + + + //interface Observable { + //} +} diff --git a/rx.js/rx.js.jquery.d.ts b/rx.js/rx.js.jquery.d.ts index 361040390..2a0b29b27 100644 --- a/rx.js/rx.js.jquery.d.ts +++ b/rx.js/rx.js.jquery.d.ts @@ -1,6 +1,15 @@ /// /// +// Those are the definitions for bridging Rx with jQuery. +// +// Using the https://github.com/Reactive-Extensions/rxjs-jquery project +// +// Dependencies: +// -> rx.js +// -> rx.jquery.js +// -> jquery.js + declare module JQueryResults { export interface eventBase{ @@ -8,9 +17,9 @@ declare module JQueryResults { cancelable: bool; type: string; preventDefault(): void; - isDefaultPrevented(): bool; + isDefaultPrevented(): boolean; stopPropagation(): void; - isPropagationStopped(): bool; + isPropagationStopped(): boolean; data: any; originalEvent: any; eventPhase: number; @@ -19,11 +28,11 @@ declare module JQueryResults { export interface keyEvent extends eventBase { key: number; keyCode: number; - altKey: bool; - ctrlKey: bool; - shiftKey: bool; + altKey: boolean; + ctrlKey: boolean; + shiftKey: boolean; char: string; - metaKey: bool; + metaKey: boolean; } export interface uiEvent extends eventBase{ diff --git a/rx.js/rx.js.time.d.ts b/rx.js/rx.js.time.d.ts index fc1299255..698cc300c 100644 --- a/rx.js/rx.js.time.d.ts +++ b/rx.js/rx.js.time.d.ts @@ -1,13 +1,86 @@ /// +// Type definitions for RxJS "Aggregates" +// Project: http://rx.codeplex.com/ +// Definitions by: Carl de Billy +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Dependencies: +// -> rx.js +// -> rx.time.js + declare module Rx { + + interface ITimeInterval { + value: any; + interval: number; + } + + interface ITimestamp { + value: any; + interval: number; + } + interface IObservable { ifThen(condition: () => bool, thenSource: IObservable): IObservable; ifThen(condition: () => bool, thenSource: IObservable, elseSource: IObservable): IObservable; ifThen(condition: () => bool, thenSource: IObservable, scheduler: IScheduler): IObservable; + + delay(dueTime: number, scheduler?: IScheduler): IObservable; + throttle(dueTime: number, scheduler?: IScheduler): IObservable; + windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): IObservable; + windowWithTime(timeSpan: number, scheduler?: IScheduler): IObservable; + windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): IObservable; + bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): IObservable; + bufferWithTime(timeSpan: number, scheduler?: IScheduler): IObservable; + bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): IObservable; + timeInterval(scheduler?: IScheduler): IObservable; + timestamp(scheduler?: IScheduler): IObservable; + sample(interval: number, scheduler?: IScheduler): IObservable; + sample(sampler: IObservable, scheduler?: IScheduler): IObservable; + timeout(dueTime: Date, other?: IObservable, scheduler?: IScheduler): IObservable; + timeout(dueTime: number, other?: IObservable, scheduler?: IScheduler): IObservable; + + delaySubscription(dueTime: number, scheduler?: IScheduler): IObservable; + delayWithSelector(delayDurationSelector: (T) => number): IObservable; + delayWithSelector(subscriptionDelay: number, delayDurationSelector: (T) => number): IObservable; + + timeoutWithSelector(firstTimeout: IObservable, timeoutdurationSelector?: (T) => IObservable, other?: IObservable): IObservable; + throttleWithSelector(throttleDurationSelector: (T) => IObservable): IObservable; + + skipLastWithTime(duration: number, scheduler?: IScheduler): IObservable; + takeLastWithTime(duration: number, timerScheduler?: IScheduler, loopScheduler?: IScheduler): IObservable; + + takeLastBufferWithTime(duration: number, scheduler?: IScheduler): IObservable; + takeWithTime(duration: number, scheduler?: IScheduler): IObservable; + skipWithTime(duration: number, scheduler?: IScheduler): IObservable; + + skipUntilWithTime(startTime: Date, scheduler?: IScheduler): IObservable; + takeUntilWithTime(endTime: Date, scheduler?: IScheduler): IObservable; } + interface Observable { interval(period: number, scheduler?: IScheduler): IObservable; interval(dutTime: number, period: number, scheduler?: IScheduler): IObservable; + timer(dueTime: Date, period: number, scheduler: IScheduler): IObservable; + timer(dueTime: Date, scheduler: IScheduler): IObservable; + timer(dueTime: number, period: number, scheduler: IScheduler): IObservable; + timer(dueTime: number, scheduler: IScheduler): IObservable; + + generateWithAbsoluteTime( + initialState: TState, + condition: (TState) => boolean, + iterate: (TState) => TState, + resultSelector: (TState) => TResult, + timeSelector: (TState) => Date, + scheduler?: IScheduler): IObservable; + + generateWithRelativeTime( + initialState: TState, + condition: (TState) => boolean, + iterate: (TState) => TState, + resultSelector: (TState) => TResult, + timeSelector: (TState) => number, + scheduler?: IScheduler): IObservable; } } \ No newline at end of file From 284f4a629ae74f643ce4e72d705a89b8ee5141c7 Mon Sep 17 00:00:00 2001 From: Andrew Gaspar Date: Fri, 5 Jul 2013 01:06:47 -0700 Subject: [PATCH 03/16] Minor fixes for issue #726 --- jquery/jquery.d.ts | 2 +- q/Q-tests.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 5254e98b1..c2f9f47dd 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -98,7 +98,7 @@ interface JQueryPromise { progress(...progressCallbacks: any[]): JQueryPromise; // Deprecated - given no typings - pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; + pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; then(onFulfill: (value: T) => U, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; diff --git a/q/Q-tests.ts b/q/Q-tests.ts index d647fabde..504655c99 100644 --- a/q/Q-tests.ts +++ b/q/Q-tests.ts @@ -76,7 +76,8 @@ Q(arrayPromise) // type specification required declare var jPromise: JQueryPromise; // if jQuery promises definition supported generics, this could be more interesting example -Q(jPromise).then((val) => val.toExponential()); +Q(jPromise).then(str => str.split(',')); +jPromise.then(returnsNumPromise); declare var promiseArray: Q.IPromise[]; var qPromiseArray = promiseArray.map(p => Q(p)); From e4693b884b4edd3756475409742e34c6ec88d977 Mon Sep 17 00:00:00 2001 From: Tomas Carnecky Date: Fri, 5 Jul 2013 13:52:23 +0200 Subject: [PATCH 04/16] Change IDirective.transclude to be of `any` type It can actually be bool or string, but TypeScript doesn't allow union types (see http://typescript.codeplex.com/workitem/120). --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 8e5e2a007..4320bebb8 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -644,7 +644,7 @@ declare module ng { template?: string; templateUrl?: string; replace?: bool; - transclude?: bool; + transclude?: any; restrict?: string; scope?: any; link?: Function; From ec405640601f44b6ccff802c80a900fc3df205ef Mon Sep 17 00:00:00 2001 From: Steve Fenton Date: Fri, 5 Jul 2013 13:59:47 +0100 Subject: [PATCH 05/16] Create basic version of jQuery UI Layout definition. --- jquery.ui.layout/jquery.ui.layout.d.ts | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 jquery.ui.layout/jquery.ui.layout.d.ts diff --git a/jquery.ui.layout/jquery.ui.layout.d.ts b/jquery.ui.layout/jquery.ui.layout.d.ts new file mode 100644 index 000000000..80e71327c --- /dev/null +++ b/jquery.ui.layout/jquery.ui.layout.d.ts @@ -0,0 +1,40 @@ +// Type definitions for jQueryUI 1.9 +// Project: http://layout.jquery-dev.net/ +// Definitions by: Steve Fenton +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +interface JQueryLayoutOptions { + north: any; + east: any; + south: any; + west: any; +} + +interface JQueryLayout { + panes: any; + options: JQueryLayoutOptions; + state: any; + + toggle(pane: any): any; + open(pane: any): any; + close(pane: any): any; + show(pane: any, openPane?: bool): any; + hide(pane: any): any; + sizePane(pane: any, sizeInPixels: number): any; + resizeContent(pane: any): any; + resizeAll(): any; + + addToggleBtn(selector: string, pane: any) + addCloseBtn(selector: string, pane: any) + addOpenBtn(selector: string, pane: any) + addPinBtn(selector: string, pane: any) + allowOverflow(elemOrPane: any) + resetOverflow(elemOrPane: any) +} + +interface JQuery { + layout(options?: JQueryLayoutOptions): JQueryLayout; +} From 4fd627247d88bc4ca0baba56dc747b1394674882 Mon Sep 17 00:00:00 2001 From: oising Date: Fri, 5 Jul 2013 11:46:37 -0400 Subject: [PATCH 06/16] updated sammyjs definitions for typescript 0.9.x --- sammyjs/sammyjs.d.ts | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/sammyjs/sammyjs.d.ts b/sammyjs/sammyjs.d.ts index f8b5ae147..84b0aef8a 100644 --- a/sammyjs/sammyjs.d.ts +++ b/sammyjs/sammyjs.d.ts @@ -1,16 +1,28 @@ // Type definitions for Sammy.js // Project: http://sammyjs.org/ // Definitions by: Boris Yankov +// - Updated for TypeScript 0.9.x by: Oisin Grehan // Definitions: https://github.com/borisyankov/DefinitelyTyped - /// -module Sammy { - export function (): Sammy.Application; - export function (selector: string): Sammy.Application; - export function (handler: Function): Sammy.Application; - export function (selector: string, handler: Function): Sammy.Application; +interface SammyFunc { + (): Sammy.Application; + (selector: string): Sammy.Application; + (handler: Function): Sammy.Application; + (selector: string, handler: Function): Sammy.Application; +} + +declare function Sammy(): Sammy.Application; +declare function Sammy(selector: string): Sammy.Application; +declare function Sammy(handler: Function): Sammy.Application; +declare function Sammy(selector: string, handler: Function): Sammy.Application; + +interface JQueryStatic { + sammy: SammyFunc; +} + +declare module Sammy { export function Cache(app, options); export function DataCacheProxy(initial, $element); @@ -201,8 +213,7 @@ module Sammy { trigger(name, data); wait(): void; } - - + export interface StoreOptions { name?: string; element?: string; @@ -241,7 +252,4 @@ module Sammy { isAvailable(type); Template(app, method_alias); } -} -interface JQueryStatic { - sammy: Sammy; } \ No newline at end of file From 89b039b2b76871a16a02522f96ecdb24c8e227d0 Mon Sep 17 00:00:00 2001 From: Richard Hepburn Date: Fri, 5 Jul 2013 13:01:31 -0400 Subject: [PATCH 07/16] Changed bool -> boolean to align with TypeScript 0.9 Updated bool type declarations to boolean to align with the ES6 standard now supported in TS 0.9. --- bootstrap/bootstrap.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bootstrap/bootstrap.d.ts b/bootstrap/bootstrap.d.ts index c06c08f89..47ef378fd 100644 --- a/bootstrap/bootstrap.d.ts +++ b/bootstrap/bootstrap.d.ts @@ -7,16 +7,16 @@ /// interface ModalOptions { - backdrop?: bool; - keyboard?: bool; - show?: bool; + backdrop?: boolean; + keyboard?: boolean; + show?: boolean; remote?: string; } interface ModalOptionsBackdropString { backdrop?: string; // for "static" - keyboard?: bool; - show?: bool; + keyboard?: boolean; + show?: boolean; remote?: string; } @@ -25,8 +25,8 @@ interface ScrollSpyOptions { } interface TooltipOptions { - animation?: bool; - html?: bool; + animation?: boolean; + html?: boolean; placement?: any; selector?: string; title?: any; @@ -35,8 +35,8 @@ interface TooltipOptions { } interface PopoverOptions { - animation?: bool; - html?: bool; + animation?: boolean; + html?: boolean; placement?: any; selector?: string; trigger?: string; @@ -47,7 +47,7 @@ interface PopoverOptions { interface CollapseOptions { parent?: any; - toggle?: bool; + toggle?: boolean; } interface CarouselOptions { From e98875bf101f337a5e64187d573f701cc9ee122e Mon Sep 17 00:00:00 2001 From: Richard Hepburn Date: Fri, 5 Jul 2013 13:01:50 -0400 Subject: [PATCH 08/16] Changed bool -> boolean to align with TypeScript 0.9 Updated bool type declarations to boolean to align with the ES6 standard now supported in TS 0.9. --- i18next/i18next.d.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index a1b843640..f9ea5fb42 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -20,28 +20,28 @@ interface I18nextOptions { lng?: string; // Default value: undefined load?: string; // Default value: 'all' preload?: string[]; // Default value: [] - lowerCaseLng?: bool; // Default value: false - returnObjectTrees?: bool; // Default value: false + lowerCaseLng?: boolean; // Default value: false + returnObjectTrees?: boolean; // Default value: false fallbackLng?: string; // Default value: 'dev' detectLngQS?: string; // Default value: 'setLng' ns?: any; // Default value: 'translation' (string), can also be an object nsseparator?: string; // Default value: '::' keyseparator?: string; // Default value: '.' selectorAttr?: string; // Default value: 'data-i18n' - debug?: bool; // Default value: false + debug?: boolean; // Default value: false resGetPath?: string; // Default value: 'locales/__lng__/__ns__.json' resPostPath?: string; // Default value: 'locales/add/__lng__/__ns__' - getAsync?: bool; // Default value: true - postAsync?: bool; // Default value: true + getAsync?: boolean; // Default value: true + postAsync?: boolean; // Default value: true resStore?: IResourceStore; // Default value: undefined - useLocalStorage?: bool; // Default value: false + useLocalStorage?: boolean; // Default value: false localStorageExpirationTime?: number; // Default value: 7 * 24 * 60 * 60 * 1000 (in ms default one week) - dynamicLoad?: bool; // Default value: false - sendMissing?: bool; // Default value: false + dynamicLoad?: boolean; // Default value: false + sendMissing?: boolean; // Default value: false sendMissingTo?: string; // Default value: 'fallback'. Other options are: current | all sendType?: string; // Default value: 'POST' @@ -53,11 +53,11 @@ interface I18nextOptions { pluralNotFound?: string; // Default value: ['plural_not_found' Math.random()].join( '' ) contextNotFound?: string; // Default value: ['context_not_found' Math.random()].join( '' ) - setJqueryExt?: bool; // Default value: true - defaultValueFromContent?: bool; // Default value: true - useDataAttrOptions?: bool; // Default value: false + setJqueryExt?: boolean; // Default value: true + defaultValueFromContent?: boolean; // Default value: true + useDataAttrOptions?: boolean; // Default value: false cookieExpirationTime?: number; // Default value: undefined - useCookie?: bool; // Default value: true + useCookie?: boolean; // Default value: true cookieName?: string; // Default value: 'i18next' postProcess?: string; // Default value: undefined @@ -69,7 +69,7 @@ interface I18nextStatic { detectLanguage(): string; functions: { extend(target: any, ...objs: any[]): Object; - extend(deep: bool, target: any, ...objs: any[]): Object; + extend(deep: boolean, target: any, ...objs: any[]): Object; each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any; ajax(settings: JQueryAjaxSettings): JQueryXHR; ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR; From 8dd5bcc633e0706bdd04448c50abb1c5fcaadc41 Mon Sep 17 00:00:00 2001 From: Richard Hepburn Date: Fri, 5 Jul 2013 13:02:27 -0400 Subject: [PATCH 09/16] Changed bool -> boolean to align with TypeScript 0.9 Updated bool type declarations to boolean to align with the ES6 standard now supported in TS 0.9. --- numeraljs/numeraljs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numeraljs/numeraljs.d.ts b/numeraljs/numeraljs.d.ts index 25e540677..e680806d1 100644 --- a/numeraljs/numeraljs.d.ts +++ b/numeraljs/numeraljs.d.ts @@ -23,7 +23,7 @@ interface NumeralJSLanguage { interface Numeral { (value?: any): Numeral; version: string; - isNumeral: bool; + isNumeral: boolean; language(key: string, values?: NumeralJSLanguage): Numeral; zeroFormat(format: string): string; clone(): Numeral; From 47a6bcdfb0fcf5b9c89c774286aa25959189c0e9 Mon Sep 17 00:00:00 2001 From: Richard Hepburn Date: Fri, 5 Jul 2013 13:02:40 -0400 Subject: [PATCH 10/16] Changed bool -> boolean to align with TypeScript 0.9 Updated bool type declarations to boolean to align with the ES6 standard now supported in TS 0.9. --- toastr/toastr.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toastr/toastr.d.ts b/toastr/toastr.d.ts index e22e8cbfc..db36ee477 100644 --- a/toastr/toastr.d.ts +++ b/toastr/toastr.d.ts @@ -10,7 +10,7 @@ interface ToastrOptions { /** * Should clicking on toast dismiss it? */ - tapToDismiss?: bool; + tapToDismiss?: boolean; /** * CSS class the toast element will be given */ @@ -22,7 +22,7 @@ interface ToastrOptions { /** * Should debug details be outputted to the console */ - debug?: bool; + debug?: boolean; /** * Time in milliseconds the toast should take to fade in */ @@ -88,7 +88,7 @@ interface ToastrOptions { /** * Set newest toast to appear on top **/ - newestOnTop?: bool; + newestOnTop?: boolean; /** * Function to execute on toast click From 184bda7faf5b6f4d897f5b7cda7d484b2997e747 Mon Sep 17 00:00:00 2001 From: NN Date: Fri, 5 Jul 2013 22:05:25 +0300 Subject: [PATCH 11/16] Update according to TS 0.9 'export = internal' is illegal. --- node/node.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index c1a552869..96fa847e1 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1019,8 +1019,8 @@ declare module "util" { } declare module "assert" { - function internal (booleanValue: boolean, message?: string): void; - module internal { + export function internal (booleanValue: boolean, message?: string): void; + export module internal { export function fail(actual: any, expected: any, message: string, operator: string): void; export function assert(value: any, message: string): void; export function ok(value: any, message?: string): void; @@ -1034,8 +1034,6 @@ declare module "assert" { export function doesNotThrow(block: any, error?: any, messsage?: string): void; export function ifError(value: any): void; } - - export = internal; } declare module "tty" { From 64092006cfcc0d8a3997d7db0808fc08285e0fc4 Mon Sep 17 00:00:00 2001 From: NN Date: Fri, 5 Jul 2013 22:05:28 +0300 Subject: [PATCH 12/16] Update according to TS 0.9 'export = internal' is illegal. --- node/node-0.8.8.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 968d2143f..53f5a07e0 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -1004,8 +1004,8 @@ declare module "util" { } declare module "assert" { - function internal(booleanValue: boolean, message?: string): void; - module internal { + export function internal(booleanValue: boolean, message?: string): void; + export module internal { export function fail(actual: any, expected: any, message: string, operator: string): void; export function assert(value: any, message: string): void; export function ok(value: any, message?: string): void; @@ -1019,8 +1019,6 @@ declare module "assert" { export function doesNotThrow(block: any, error?: any, messsage?: string): void; export function ifError(value: any): void; } - - export = internal; } declare module "tty" { From 21dd00558d14f6e190f1a8d66d1aead1bca8332c Mon Sep 17 00:00:00 2001 From: NN Date: Fri, 5 Jul 2013 22:08:49 +0300 Subject: [PATCH 13/16] TS requires semicolon Fix according to TS 0.9 specification. --- durandal/durandal.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 5f98beac1..043ab3f66 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -249,7 +249,7 @@ declare module "durandal/viewModel" { export var activator: { (): IDurandalViewModelActiveItem; (initialActiveItem: any, settings?: IViewModelDefaults): IDurandalViewModelActiveItem; - } + }; } declare module "durandal/viewModelBinder" { @@ -483,7 +483,7 @@ declare module "durandal/plugins/router" { /** * Before any route is activated, the guardRoute funtion is called. You can plug into this function to add custom logic to allow, deny or redirect based on the requested route. To allow, return true. To deny, return false. To redirect, return a string with the hash or url. You may also return a promise for any of these values. */ - export var guardRoute: (routeInfo: IRouteInfo, params: any, instance: any) => any + export var guardRoute: (routeInfo: IRouteInfo, params: any, instance: any) => any; } declare module "durandal/widget" { @@ -524,4 +524,4 @@ interface IEventSubscription * This function removing current subscription from event handlers */ off(): void; - } + } From b96032e42fc4b9e96dda1334c3e5c0266c7fa275 Mon Sep 17 00:00:00 2001 From: NN Date: Fri, 5 Jul 2013 22:22:36 +0300 Subject: [PATCH 14/16] Update according to TS 0.9 There is no declare inside module --- teechart/teechart.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/teechart/teechart.d.ts b/teechart/teechart.d.ts index 41f9de677..6e3a4424a 100644 --- a/teechart/teechart.d.ts +++ b/teechart/teechart.d.ts @@ -18,7 +18,7 @@ */ -module Tee { +declare module Tee { interface IPoint { x: number; @@ -565,12 +565,12 @@ module Tee { refresh(series: ISeries, index: number): void; } - declare class Point implements IPoint { + class Point implements IPoint { public x:number; public y:number; } - declare class Chart implements IChart { + class Chart implements IChart { //public aspect: IAspect; public axes: IAxes; @@ -600,79 +600,79 @@ module Tee { // SERIES - declare var Line: { + var Line: { prototype: ILine; new(values?:number[]): ILine; } - declare var PointXY: { + var PointXY: { prototype: ICustomSeries; new(values?:number[]): ICustomSeries; } - declare var Area: { + var Area: { prototype: IArea; new(values?:number[]): IArea; } - declare var HorizArea: { + var HorizArea: { prototype: IArea; new(values?:number[]): IArea; } - declare var Bar: { + var Bar: { prototype: ICustomBar; new(values?:number[]): ICustomBar; } - declare var HorizBar: { + var HorizBar: { prototype: ICustomBar; new(values?:number[]): ICustomBar; } - declare var Pie: { + var Pie: { prototype: IPie; new(values?:number[]): IPie; } - declare var Donut: { + var Donut: { prototype: IPie; new(values?:number[]): IPie; } - declare var Bubble: { + var Bubble: { prototype: IBubble; new(values?:number[]): IBubble; } - declare var Gantt: { + var Gantt: { prototype: IGantt; new(values?:number[]): IGantt; } - declare var Volume: { + var Volume: { prototype: ICustomBar; new(values?:number[]): ICustomBar; } - declare var Candle: { + var Candle: { prototype: ICandle; new(values?:number[]): ICandle; } // TOOLS - declare var CursorTool: { + var CursorTool: { prototype: ICursorTool; new(chart?: Chart): ICursorTool; } - declare var DragTool: { + var DragTool: { prototype: IDragTool; new(chart?: Chart): IDragTool; } - declare var ToolTip: { + var ToolTip: { prototype: IToolTip; new(chart?: Chart): IToolTip; } From be4949c064d5b18a74487e56c79d67389999822b Mon Sep 17 00:00:00 2001 From: NN Date: Fri, 5 Jul 2013 22:55:50 +0300 Subject: [PATCH 15/16] TS doesn't allow optional parameters with literals --- jquery.pickadate/jquery.pickadate.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.pickadate/jquery.pickadate.d.ts b/jquery.pickadate/jquery.pickadate.d.ts index d0825c770..03d2f943a 100644 --- a/jquery.pickadate/jquery.pickadate.d.ts +++ b/jquery.pickadate/jquery.pickadate.d.ts @@ -251,7 +251,7 @@ interface DatePickerObject extends PickerObject { get(thing: string): any; /** Returns the string value of the picker's input element. */ - get(thing?: 'value'): string; + get(thing: 'value'): string; /** Returns the item object that is visually selected. */ get(thing: 'select'): DatePickerItemObject; @@ -317,7 +317,7 @@ interface TimePickerObject extends PickerObject { get(thing: string): any; /** Returns the string value of the picker's input element. */ - get(thing?: 'value'): string; + get(thing: 'value'): string; /** Returns the item object that is visually selected. */ get(thing: 'select'): TimePickerItemObject; @@ -372,4 +372,4 @@ interface HTMLInputElement { pickadate(picker: string): DatePickerObject; pickatime(picker: string): TimePickerObject; -} \ No newline at end of file +} From f53317a2de57688585e67e8d894540505a0b7788 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 7 Jul 2013 15:25:27 -0400 Subject: [PATCH 16/16] Fixed ISubject/Subject constructor was incorrect. --- rx.js/rx.js.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rx.js/rx.js.d.ts b/rx.js/rx.js.d.ts index 742694431..7a674ba5c 100644 --- a/rx.js/rx.js.d.ts +++ b/rx.js/rx.js.d.ts @@ -427,11 +427,13 @@ declare module Rx { } export interface Subject { - (): ISubject; - create(observer?: IObserver, observable?: IObservable): ISubject; } + var Subject: { + new (): ISubject; + } + interface IAsyncSubject extends IObservable, IObserver { isDisposed: bool; value: T;