Skip to content

Added better typings for combineAll and combineLatest #715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0261a6f
style(typings): Added better typings for combineAll and combineLatest
david-driscoll Nov 12, 2015
6c5db82
style(typings): Added better typings for combineAll and combineLatest
david-driscoll Nov 12, 2015
f1e053d
style(typings): Added better typings for combineAll and combineLatest
david-driscoll Nov 12, 2015
eddfa18
style(typings): Added better typings for combineAll and combineLatest
david-driscoll Nov 12, 2015
472b9a2
style(typings): Added tool to generate operator typings from source
david-driscoll Nov 13, 2015
404a3b8
refactor(typings): Updated typings with generation tool
david-driscoll Nov 13, 2015
b165ec3
chore(typings): Added build_operators build step to make sure operato…
david-driscoll Nov 13, 2015
957dc06
style(typings): Updated typings to have a better flow through type in…
david-driscoll Nov 13, 2015
f83e37b
style(typings): Only strongly type 4 levels instead of 9
david-driscoll Nov 14, 2015
b7ee18c
style(typings): Added typings for extended operators
david-driscoll Nov 14, 2015
029206c
style(typings): Updated typings to have a better flow through type in…
david-driscoll Nov 14, 2015
469e6f6
style(typings): Updated for several types
david-driscoll Nov 15, 2015
4888b04
style(typings): Fixed tshint errors on new typings
david-driscoll Nov 16, 2015
36707ef
style(typings): Updated typings for multicast and publish to return a…
david-driscoll Nov 16, 2015
5ebc3af
style(typings): Updated typings for map and mapTo
david-driscoll Nov 16, 2015
819c0a9
Merge branch 'master' of github.com:ReactiveX/RxJS into improved-typings
david-driscoll Nov 16, 2015
aaa52e3
Merge branch 'improved-typings' of github.com:david-driscoll/RxJS-1 i…
david-driscoll Nov 16, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
},
"scripts": {
"build_all": "npm run build_es6 && npm run build_amd && npm run build_cjs && npm run build_global",
"build_amd": "rm -rf dist/amd && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts -m amd --outDir dist/amd --sourcemap --target ES5 --diagnostics",
"build_cjs": "rm -rf dist/cjs && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts src/Rx.KitchenSink.ts -m commonjs --outDir dist/cjs --sourcemap --target ES5 -d --diagnostics",
"build_es6": "rm -rf dist/es6 && tsc src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --sourceMap --target ES6 -d --diagnostics",
"build_amd": "npm run build_operators && rm -rf dist/amd && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts -m amd --outDir dist/amd --sourcemap --target ES5 --diagnostics",
"build_cjs": "npm run build_operators && rm -rf dist/cjs && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts src/Rx.KitchenSink.ts -m commonjs --outDir dist/cjs --sourcemap --target ES5 -d --diagnostics",
"build_es6": "npm run build_operators && rm -rf dist/es6 && tsc typings/es6-build-shim.d.ts src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --sourceMap --target ES6 -d --diagnostics",
"build_closure": "java -jar ./node_modules/google-closure-compiler/compiler.jar ./dist/global/Rx.js --create_source_map ./dist/global/Rx.min.js.map --js_output_file ./dist/global/Rx.min.js",
"build_global": "rm -rf dist/global && mkdir \"dist/global\" && browserify src/Rx.global.js --outfile dist/global/Rx.js && npm run build_closure",
"build_global": "npm run build_operators && rm -rf dist/global && mkdir \"dist/global\" && browserify src/Rx.global.js --outfile dist/global/Rx.js && npm run build_closure",
"build_perf": "npm run build_cjs && npm run build_global && webdriver-manager update && npm run perf",
"build_test": "rm -rf dist/ && npm run lint && npm run build_cjs && jasmine",
"build_cover": "rm -rf dist/ && npm run lint && npm run build_cjs && npm run cover",
"build_docs": "./docgen.sh",
"lint_perf": "eslint perf/ --fix",
"lint_spec": "eslint spec/**/*.js --fix",
"lint_src": "tslint -c .tslintrc src/*.ts src/**/*.ts src/**/**/*.ts",
"lint_src": "tslint src/*.ts src/**/*.ts src/**/**/*.ts",
"lint": "npm run lint_src && npm run lint_spec && npm run lint_perf",
"cover": "istanbul cover -x \"*-spec.js index.js *-helper.js spec/helpers/*\" ./node_modules/jasmine/bin/jasmine.js && npm run cover_remapping",
"cover_remapping": "remap-istanbul -i coverage/coverage.json -o coverage/coverage-remapped.json && remap-istanbul -i coverage/coverage.json -o coverage/coverage-remapped.lcov -t lcovonly && remap-istanbul -i coverage/coverage.json -o coverage/coverage-remapped -t html",
Expand All @@ -33,7 +33,8 @@
"perf": "protractor protractor.conf.js",
"perf_micro": "node ./perf/micro/index.js",
"prepublish": "npm run build_all",
"commit": "git-cz"
"commit": "git-cz",
"build_operators": "node typingsgen.js"
},
"repository": {
"type": "git",
Expand Down
172 changes: 79 additions & 93 deletions src/CoreOperators.ts
Original file line number Diff line number Diff line change
@@ -1,94 +1,80 @@
import {Observable} from './Observable';
import {Scheduler} from './Scheduler';
import {ConnectableObservable} from './observables/ConnectableObservable';
import {Subject} from './Subject';
import {GroupedObservable} from './operators/groupBy-support';
import {Notification} from './Notification';

import * as operators from './operator-typings';
export interface CoreOperators<T> {
buffer?: (closingNotifier: Observable<any>) => Observable<T[]>;
bufferCount?: (bufferSize: number, startBufferEvery: number) => Observable<T[]>;
bufferTime?: (bufferTimeSpan: number, bufferCreationInterval?: number, scheduler?: Scheduler) => Observable<T[]>;
bufferToggle?: <O>(openings: Observable<O>, closingSelector?: (openValue: O) => Observable<any>) => Observable<T[]>;
bufferWhen?: (closingSelector: () => Observable<any>) => Observable<T[]>;
catch?: (selector: (err: any, source: Observable<T>, caught: Observable<any>) => Observable<any>) => Observable<T>;
combineAll?: <R>(project?: (...values: Array<any>) => R) => Observable<R>;
combineLatest?: <R>(...observables: Array<Observable<any> | ((...values: Array<any>) => R)>) => Observable<R>;
concat?: <R>(...observables: (Observable<any> | Scheduler)[]) => Observable<R>;
concatAll?: () => Observable<T>;
concatMap?: <R>(project: ((x: T, ix: number) => Observable<any>), projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
concatMapTo?: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
count?: (predicate?: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any) => Observable<number>;
dematerialize?: () => Observable<any>;
debounce?: (durationSelector: (value: T) => Observable<any> | Promise<any>) => Observable<T>;
debounceTime?: <R>(dueTime: number, scheduler?: Scheduler) => Observable<R>;
defaultIfEmpty?: <R>(defaultValue?: T | R) => Observable<T> | Observable<R>;
delay?: (delay: number, scheduler?: Scheduler) => Observable<T>;
distinctUntilChanged?: (compare?: (x: T, y: T) => boolean, thisArg?: any) => Observable<T>;
do?: (next?: (x: T) => void, error?: (e: any) => void, complete?: () => void) => Observable<T>;
expand?: <R>(project: (x: T, ix: number) => Observable<R>) => Observable<R>;
filter?: (predicate: (x: T) => boolean, ix?: number, thisArg?: any) => Observable<T>;
finally?: (ensure: () => void, thisArg?: any) => Observable<T>;
first?: <R>(predicate?: (value: T, index: number, source: Observable<T>) => boolean,
resultSelector?: (value: T, index: number) => R, thisArg?: any, defaultValue?: any) => Observable<T> | Observable<R>;
flatMap?: <R>(project: ((x: T, ix: number) => Observable<any>),
projectResult?: (x: T, y: any, ix: number, iy: number) => R,
concurrent?: number) => Observable<R>;
flatMapTo?: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R, concurrent?: number) => Observable<R>;
groupBy?: <R>(keySelector: (value: T) => string,
elementSelector?: (value: T) => R,
durationSelector?: (group: GroupedObservable<R>) => Observable<any>) => Observable<GroupedObservable<R>>;
ignoreElements?: () => Observable<T>;
last?: <R>(predicate?: (value: T, index: number) => boolean,
resultSelector?: (value: T, index: number) => R,
thisArg?: any, defaultValue?: any) => Observable<T> | Observable<R>;
every?: (predicate: (value: T, index: number) => boolean, thisArg?: any) => Observable<T>;
map?: <R>(project: (x: T, ix?: number) => R, thisArg?: any) => Observable<R>;
mapTo?: <R>(value: R) => Observable<R>;
materialize?: () => Observable<Notification<T>>;
merge?: (...observables: any[]) => Observable<any>;
mergeAll?: (concurrent?: number) => Observable<T>;
mergeMap?: <R>(project: ((x: T, ix: number) => Observable<any>),
projectResult?: (x: T, y: any, ix: number, iy: number) => R, concurrent?: number) => Observable<R>;
mergeMapTo?: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R, concurrent?: number) => Observable<R>;
multicast?: (subjectFactory: () => Subject<T>) => ConnectableObservable<T>;
observeOn?: (scheduler: Scheduler, delay?: number) => Observable<T>;
partition?: (predicate: (x: T) => boolean) => Observable<T>[];
publish?: () => ConnectableObservable<T>;
publishBehavior?: (value: any) => ConnectableObservable<T>;
publishReplay?: (bufferSize: number, windowTime: number, scheduler?: Scheduler) => ConnectableObservable<T>;
reduce?: <R>(project: (acc: R, x: T) => R, seed?: R) => Observable<R>;
repeat?: (count?: number) => Observable<T>;
retry?: (count?: number) => Observable<T>;
retryWhen?: (notifier: (errors: Observable<any>) => Observable<any>) => Observable<T>;
sample?: (notifier: Observable<any>) => Observable<T>;
sampleTime?: (delay: number, scheduler?: Scheduler) => Observable<T>;
scan?: <R>(project: (acc: R, x: T) => R, acc?: R) => Observable<R>;
share?: () => Observable<T>;
single?: (predicate?: (value: T, index: number) => boolean, thisArg?: any) => Observable<T>;
skip?: (count: number) => Observable<T>;
skipUntil?: (notifier: Observable<any>) => Observable<T>;
skipWhile?: (predicate: (x: T, index: number) => boolean, thisArg?: any) => Observable<T>;
startWith?: (x: T) => Observable<T>;
subscribeOn?: (scheduler: Scheduler, delay?: number) => Observable<T>;
switch?: () => Observable<T>;
switchMap?: <R>(project: ((x: T, ix: number) => Observable<any>), projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
switchMapTo?: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
take?: (count: number) => Observable<T>;
takeUntil?: (notifier: Observable<any>) => Observable<T>;
takeWhile?: (predicate: (value: T, index: number) => boolean, thisArg?: any) => Observable<T>;
throttle?: (durationSelector: (value: T) => Observable<any> | Promise<any>) => Observable<T>;
throttleTime?: (delay: number, scheduler?: Scheduler) => Observable<T>;
timeout?: (due: number | Date, errorToSend?: any, scheduler?: Scheduler) => Observable<T>;
timeoutWith?: <R>(due: number | Date, withObservable: Observable<R>, scheduler?: Scheduler) => Observable<T> | Observable<R>;
toArray?: () => Observable<T[]>;
toPromise?: (PromiseCtor: PromiseConstructor) => Promise<T>;
window?: (closingNotifier: Observable<any>) => Observable<Observable<T>>;
windowCount?: (windowSize: number, startWindowEvery: number) => Observable<Observable<T>>;
windowTime?: (windowTimeSpan: number, windowCreationInterval?: number, scheduler?: Scheduler) => Observable<Observable<T>>;
windowToggle?: <O>(openings: Observable<O>, closingSelector?: (openValue: O) => Observable<any>) => Observable<Observable<T>>;
windowWhen?: (closingSelector: () => Observable<any>) => Observable<Observable<T>>;
withLatestFrom?: <R>(...observables: Array<Observable<any> | ((...values: Array<any>) => R)>) => Observable<R>;
zip?: <R>(...observables: Array<Observable<any> | ((...values: Array<any>) => R)>) => Observable<R>;
zipAll?: <R>(project?: (...values: Array<any>) => R) => Observable<R>;
}
buffer: operators.operator_proto_buffer<T>;
bufferCount: operators.operator_proto_bufferCount<T>;
bufferTime: operators.operator_proto_bufferTime<T>;
bufferToggle: operators.operator_proto_bufferToggle<T>;
bufferWhen: operators.operator_proto_bufferWhen<T>;
catch: operators.operator_proto_catch<T>;
combineAll: operators.operator_proto_combineAll<T>;
combineLatest: operators.operator_proto_combineLatest<T>;
concat: operators.operator_proto_concat<T>;
concatAll: operators.operator_proto_concatAll<T>;
concatMap: operators.operator_proto_concatMap<T>;
concatMapTo: operators.operator_proto_concatMapTo<T>;
count: operators.operator_proto_count<T>;
dematerialize: operators.operator_proto_dematerialize<T>;
debounce: operators.operator_proto_debounce<T>;
debounceTime: operators.operator_proto_debounceTime<T>;
defaultIfEmpty: operators.operator_proto_defaultIfEmpty<T>;
delay: operators.operator_proto_delay<T>;
distinctUntilChanged: operators.operator_proto_distinctUntilChanged<T>;
do: operators.operator_proto_do<T>;
expand: operators.operator_proto_expand<T>;
filter: operators.operator_proto_filter<T>;
finally: operators.operator_proto_finally<T>;
first: operators.operator_proto_first<T>;
flatMap: operators.operator_proto_mergeMap<T>;
flatMapTo: operators.operator_proto_mergeMapTo<T>;
groupBy: operators.operator_proto_groupBy<T>;
ignoreElements: operators.operator_proto_ignoreElements<T>;
last: operators.operator_proto_last<T>;
every: operators.operator_proto_every<T>;
map: operators.operator_proto_map<T>;
mapTo: operators.operator_proto_mapTo<T>;
materialize: operators.operator_proto_materialize<T>;
merge: operators.operator_proto_merge<T>;
mergeAll: operators.operator_proto_mergeAll<T>;
mergeMap: operators.operator_proto_mergeMap<T>;
mergeMapTo: operators.operator_proto_mergeMapTo<T>;
multicast: operators.operator_proto_multicast<T>;
observeOn: operators.operator_proto_observeOn<T>;
partition: operators.operator_proto_partition<T>;
publish: operators.operator_proto_publish<T>;
publishBehavior: operators.operator_proto_publishBehavior<T>;
publishReplay: operators.operator_proto_publishReplay<T>;
reduce: operators.operator_proto_reduce<T>;
repeat: operators.operator_proto_repeat<T>;
retry: operators.operator_proto_retry<T>;
retryWhen: operators.operator_proto_retryWhen<T>;
sample: operators.operator_proto_sample<T>;
sampleTime: operators.operator_proto_sampleTime<T>;
scan: operators.operator_proto_scan<T>;
share: operators.operator_proto_share<T>;
single: operators.operator_proto_single<T>;
skip: operators.operator_proto_skip<T>;
skipUntil: operators.operator_proto_skipUntil<T>;
skipWhile: operators.operator_proto_skipWhile<T>;
startWith: operators.operator_proto_startWith<T>;
subscribeOn: operators.operator_proto_subscribeOn<T>;
switch: operators.operator_proto_switch<T>;
switchMap: operators.operator_proto_switchMap<T>;
switchMapTo: operators.operator_proto_switchMapTo<T>;
take: operators.operator_proto_take<T>;
takeUntil: operators.operator_proto_takeUntil<T>;
takeWhile: operators.operator_proto_takeWhile<T>;
throttle: operators.operator_proto_throttle<T>;
throttleTime: operators.operator_proto_throttleTime<T>;
timeout: operators.operator_proto_timeout<T>;
timeoutWith: operators.operator_proto_timeoutWith<T>;
toArray: operators.operator_proto_toArray<T>;
toPromise: operators.operator_proto_toPromise<T>;
window: operators.operator_proto_window<T>;
windowCount: operators.operator_proto_windowCount<T>;
windowTime: operators.operator_proto_windowTime<T>;
windowToggle: operators.operator_proto_windowToggle<T>;
windowWhen: operators.operator_proto_windowWhen<T>;
withLatestFrom: operators.operator_proto_withLatestFrom<T>;
zip: operators.operator_proto_zip<T>;
zipAll: operators.operator_proto_zipAll<T>;
}
2 changes: 1 addition & 1 deletion src/InnerSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export class InnerSubscriber<T, R> extends Subscriber<R> {
_complete() {
this.parent.notifyComplete(this);
}
}
}
15 changes: 15 additions & 0 deletions src/KitchenSinkOperators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as operators from './operator-typings';
import {CoreOperators} from './CoreOperators';
export interface KitchenSinkOperators<T> extends CoreOperators<T> {
isEmpty: operators.operator_proto_isEmpty<T>;
elementAt: operators.operator_proto_elementAt<T>;
distinctUntilKeyChanged: operators.operator_proto_distinctUntilKeyChanged<T>;
find: operators.operator_proto_find<T>;
findIndex: operators.operator_proto_findIndex<T>;
max: operators.operator_proto_max<T>;
min: operators.operator_proto_min<T>;
timeInterval: operators.operator_proto_timeInterval<T>;
mergeScan: operators.operator_proto_mergeScan<T>;
switchFirst: operators.operator_proto_switchFirst<T>;
switchMapFirst: operators.operator_proto_switchMapFirst<T>;
}
2 changes: 1 addition & 1 deletion src/Notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Notification<T> {
case 'E':
return Observable.throw(this.exception);
case 'C':
return Observable.empty();
return Observable.empty<T>();
}
}

Expand Down
Loading