Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 31fc127

Browse files
JiaLiPassionmhevery
authored andcommitted
feat(build): Upgrade to TypeScript 2.9 and rxjs6 (#1122)
This includes a migration to TS2.9, and a migration to RxJS 6 (which is required for TS2.9 support).
1 parent 9c96904 commit 31fc127

52 files changed

Lines changed: 669 additions & 734 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎karma-base.conf.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = function(config) {
1717
{pattern: 'node_modules/rxjs/**/**/*.js.map',included: false,watched: false},
1818
{pattern: 'node_modules/rxjs/**/*.js',included: false,watched: false},
1919
{pattern: 'node_modules/es6-promise/**/*.js',included: false,watched: false},
20+
{pattern: 'node_modules/core-js/**/*.js',included: false,watched: false},
2021
{pattern: 'node_modules/rxjs/**/*.js.map',included: false,watched: false},
2122
{pattern: 'test/assets/**/*.*',watched: true,served: true,included: false},
2223
{pattern: 'build/**/*.js.map',watched: true,served: true,included: false},

‎lib/rxjs/rxjs-fake-async.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import{Scheduler}from'rxjs/Scheduler';
10-
import{asap}from'rxjs/scheduler/asap';
11-
import{async}from'rxjs/scheduler/async';
9+
import{asapScheduler,asyncScheduler,Scheduler}from'rxjs';
1210

1311
Zone.__load_patch('rxjs.Scheduler.now',(global: any,Zone: ZoneType,api: _ZonePrivate)=>{
1412
api.patchMethod(Scheduler,'now',(delegate: Function)=>(self: any,args: any[])=>{
1513
returnDate.now.apply(self,args);
1614
});
17-
api.patchMethod(async,'now',(delegate: Function)=>(self: any,args: any[])=>{
15+
api.patchMethod(asyncScheduler,'now',(delegate: Function)=>(self: any,args: any[])=>{
1816
returnDate.now.apply(self,args);
1917
});
20-
api.patchMethod(asap,'now',(delegate: Function)=>(self: any,args: any[])=>{
18+
api.patchMethod(asapScheduler,'now',(delegate: Function)=>(self: any,args: any[])=>{
2119
returnDate.now.apply(self,args);
2220
});
2321
});

‎lib/rxjs/rxjs.ts‎

Lines changed: 52 additions & 226 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,20 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import'rxjs/add/observable/bindCallback';
10-
import'rxjs/add/observable/bindNodeCallback';
11-
import'rxjs/add/observable/defer';
12-
import'rxjs/add/observable/forkJoin';
13-
import'rxjs/add/observable/fromEventPattern';
14-
import'rxjs/add/operator/multicast';
9+
import{Observable,Subscriber,Subscription}from'rxjs';
1510

16-
import{Observable}from'rxjs/Observable';
17-
import{asap}from'rxjs/scheduler/asap';
18-
import{Subscriber}from'rxjs/Subscriber';
19-
import{Subscription}from'rxjs/Subscription';
20-
import{rxSubscriber}from'rxjs/symbol/rxSubscriber';
21-
22-
(Zoneasany).__load_patch('rxjs',(global: any,Zone: ZoneType)=>{
11+
(Zoneasany).__load_patch('rxjs',(global: any,Zone: ZoneType,api: _ZonePrivate)=>{
2312
constsymbol: (symbolString: string)=>string=(Zoneasany).__symbol__;
2413
constnextSource='rxjs.Subscriber.next';
2514
consterrorSource='rxjs.Subscriber.error';
2615
constcompleteSource='rxjs.Subscriber.complete';
2716

2817
constObjectDefineProperties=Object.defineProperties;
2918

30-
constempty={
31-
closed: true,
32-
next(value: any): void{},
33-
error(err: any): void{
34-
throwerr;
35-
},
36-
complete(): void{}
37-
};
38-
39-
functiontoSubscriber<T>(
40-
nextOrObserver?: any,error?: (error: any)=>void,complete?: ()=>void): Subscriber<T>{
41-
if(nextOrObserver){
42-
if(nextOrObserverinstanceofSubscriber){
43-
return(<Subscriber<T>>nextOrObserver);
44-
}
45-
46-
if(nextOrObserver[rxSubscriber]){
47-
returnnextOrObserver[rxSubscriber]();
48-
}
49-
}
50-
51-
if(!nextOrObserver&&!error&&!complete){
52-
returnnewSubscriber(empty);
53-
}
54-
55-
returnnewSubscriber(nextOrObserver,error,complete);
56-
}
57-
5819
constpatchObservable=function(){
5920
constObservablePrototype: any=Observable.prototype;
60-
constsymbolSubscribe=symbol('subscribe');
6121
const_symbolSubscribe=symbol('_subscribe');
6222
const_subscribe=ObservablePrototype[_symbolSubscribe]=ObservablePrototype._subscribe;
63-
constsubscribe=ObservablePrototype[symbolSubscribe]=ObservablePrototype.subscribe;
6423

6524
ObjectDefineProperties(Observable.prototype,{
6625
_zone: {value: null,writable: true,configurable: true},
@@ -89,30 +48,58 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber';
8948
},
9049
set: function(this: Observable<any>,subscribe: any){
9150
(thisasany)._zone=Zone.current;
92-
(thisasany)._zoneSubscribe=subscribe;
51+
(thisasany)._zoneSubscribe=function(){
52+
if(this._zone&&this._zone!==Zone.current){
53+
consttearDown=this._zone.run(subscribe,this,arguments);
54+
if(tearDown&&typeoftearDown==='function'){
55+
constzone=this._zone;
56+
returnfunction(){
57+
if(zone!==Zone.current){
58+
returnzone.run(tearDown,this,arguments);
59+
}
60+
returntearDown.apply(this,arguments);
61+
};
62+
}
63+
returntearDown;
64+
}
65+
returnsubscribe.apply(this,arguments);
66+
};
9367
}
9468
},
95-
subscribe: {
96-
writable: true,
97-
configurable: true,
98-
value: function(this: Observable<any>,observerOrNext: any,error: any,complete: any){
99-
// Only grab a zone if we Zone exists and it is different from the current zone.
100-
const_zone=(thisasany)._zone;
101-
if(_zone&&_zone!==Zone.current){
102-
// Current Zone is different from the intended zone.
103-
// Restore the zone before invoking the subscribe callback.
104-
return_zone.run(subscribe,this,[toSubscriber(observerOrNext,error,complete)]);
105-
}
106-
returnsubscribe.call(this,observerOrNext,error,complete);
69+
subjectFactory: {
70+
get: function(){
71+
return(thisasany)._zoneSubjectFactory;
72+
},
73+
set: function(factory: any){
74+
constzone=this._zone;
75+
this._zoneSubjectFactory=function(){
76+
if(zone&&zone!==Zone.current){
77+
returnzone.run(factory,this,arguments);
78+
}
79+
returnfactory.apply(this,arguments);
80+
};
10781
}
10882
}
10983
});
11084
};
11185

86+
api.patchMethod(Observable.prototype,'lift',(delegate: any)=>(self: any,args: any[])=>{
87+
constobservable: any=delegate.apply(self,args);
88+
if(observable.operator){
89+
observable.operator._zone=Zone.current;
90+
api.patchMethod(
91+
observable.operator,'call',
92+
(operatorDelegate: any)=>(operatorSelf: any,operatorArgs: any[])=>{
93+
if(operatorSelf._zone&&operatorSelf._zone!==Zone.current){
94+
returnoperatorSelf._zone.run(operatorDelegate,operatorSelf,operatorArgs);
95+
}
96+
returnoperatorDelegate.apply(operatorSelf,operatorArgs);
97+
});
98+
}
99+
returnobservable;
100+
});
101+
112102
constpatchSubscription=function(){
113-
constunsubscribeSymbol=symbol('unsubscribe');
114-
constunsubscribe=(Subscription.prototypeasany)[unsubscribeSymbol]=
115-
Subscription.prototype.unsubscribe;
116103
ObjectDefineProperties(Subscription.prototype,{
117104
_zone: {value: null,writable: true,configurable: true},
118105
_zoneUnsubscribe: {value: null,writable: true,configurable: true},
@@ -126,22 +113,12 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber';
126113
},
127114
set: function(this: Subscription,unsubscribe: any){
128115
(thisasany)._zone=Zone.current;
129-
(thisasany)._zoneUnsubscribe=unsubscribe;
130-
}
131-
},
132-
unsubscribe: {
133-
writable: true,
134-
configurable: true,
135-
value: function(this: Subscription){
136-
// Only grab a zone if we Zone exists and it is different from the current zone.
137-
const_zone: Zone=(thisasany)._zone;
138-
if(_zone&&_zone!==Zone.current){
139-
// Current Zone is different from the intended zone.
140-
// Restore the zone before invoking the subscribe callback.
141-
_zone.run(unsubscribe,this);
142-
}else{
143-
unsubscribe.apply(this);
144-
}
116+
(thisasany)._zoneUnsubscribe=function(){
117+
if(this._zone&&this._zone!==Zone.current){
118+
returnthis._zone.run(unsubscribe,this,arguments);
119+
}
120+
returnunsubscribe.apply(this,arguments);
121+
};
145122
}
146123
}
147124
});
@@ -205,158 +182,7 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber';
205182
};
206183
};
207184

208-
constpatchObservableInstance=function(observable: any){
209-
observable._zone=Zone.current;
210-
};
211-
212-
constpatchObservableFactoryCreator=function(obj: any,factoryName: string){
213-
constsymbolFactory: string=symbol(factoryName);
214-
if(obj[symbolFactory]){
215-
return;
216-
}
217-
constfactoryCreator: any=obj[symbolFactory]=obj[factoryName];
218-
if(!factoryCreator){
219-
return;
220-
}
221-
obj[factoryName]=function(){
222-
constfactory: any=factoryCreator.apply(this,arguments);
223-
returnfunction(){
224-
constobservable=factory.apply(this,arguments);
225-
patchObservableInstance(observable);
226-
returnobservable;
227-
};
228-
};
229-
};
230-
231-
constpatchObservableFactory=function(obj: any,factoryName: string){
232-
constsymbolFactory: string=symbol(factoryName);
233-
if(obj[symbolFactory]){
234-
return;
235-
}
236-
constfactory: any=obj[symbolFactory]=obj[factoryName];
237-
if(!factory){
238-
return;
239-
}
240-
obj[factoryName]=function(){
241-
constobservable=factory.apply(this,arguments);
242-
patchObservableInstance(observable);
243-
returnobservable;
244-
};
245-
};
246-
247-
constpatchObservableFactoryArgs=function(obj: any,factoryName: string){
248-
constsymbolFactory: string=symbol(factoryName);
249-
if(obj[symbolFactory]){
250-
return;
251-
}
252-
constfactory: any=obj[symbolFactory]=obj[factoryName];
253-
if(!factory){
254-
return;
255-
}
256-
obj[factoryName]=function(){
257-
constinitZone=Zone.current;
258-
constargs=Array.prototype.slice.call(arguments);
259-
for(leti=0;i<args.length;i++){
260-
constarg=args[i];
261-
if(typeofarg==='function'){
262-
args[i]=function(){
263-
constargArgs=Array.prototype.slice.call(arguments);
264-
construnningZone=Zone.current;
265-
if(initZone&&runningZone&&initZone!==runningZone){
266-
returninitZone.run(arg,this,argArgs);
267-
}else{
268-
returnarg.apply(this,argArgs);
269-
}
270-
};
271-
}
272-
}
273-
274-
constobservable=factory.apply(this,args);
275-
patchObservableInstance(observable);
276-
returnobservable;
277-
};
278-
};
279-
280-
constpatchMulticast=function(){
281-
constobj: any=Observable.prototype;
282-
constfactoryName: string='multicast';
283-
constsymbolFactory: string=symbol(factoryName);
284-
if(obj[symbolFactory]){
285-
return;
286-
}
287-
constfactory: any=obj[symbolFactory]=obj[factoryName];
288-
if(!factory){
289-
return;
290-
}
291-
obj[factoryName]=function(){
292-
const_zone: any=Zone.current;
293-
constargs=Array.prototype.slice.call(arguments);
294-
letsubjectOrSubjectFactory: any=args.length>0 ? args[0] : undefined;
295-
if(typeofsubjectOrSubjectFactory!=='function'){
296-
constoriginalFactory: any=subjectOrSubjectFactory;
297-
subjectOrSubjectFactory=function(){
298-
returnoriginalFactory;
299-
};
300-
}
301-
args[0]=function(){
302-
letsubject: any;
303-
if(_zone&&_zone!==Zone.current){
304-
subject=_zone.run(subjectOrSubjectFactory,this,arguments);
305-
}else{
306-
subject=subjectOrSubjectFactory.apply(this,arguments);
307-
}
308-
if(subject&&_zone){
309-
subject._zone=_zone;
310-
}
311-
returnsubject;
312-
};
313-
constobservable=factory.apply(this,args);
314-
patchObservableInstance(observable);
315-
returnobservable;
316-
};
317-
};
318-
319-
constpatchImmediate=function(asap: any){
320-
if(!asap){
321-
return;
322-
}
323-
324-
constscheduleSymbol=symbol('scheduleSymbol');
325-
constzoneSymbol=symbol('zone');
326-
if(asap[scheduleSymbol]){
327-
return;
328-
}
329-
330-
constschedule=asap[scheduleSymbol]=asap.schedule;
331-
asap.schedule=function(){
332-
constargs=Array.prototype.slice.call(arguments);
333-
constwork=args.length>0 ? args[0] : undefined;
334-
constdelay=args.length>1 ? args[1] : 0;
335-
conststate=(args.length>2 ? args[2] : undefined)||{};
336-
state[zoneSymbol]=Zone.current;
337-
338-
constpatchedWork=function(){
339-
constworkArgs=Array.prototype.slice.call(arguments);
340-
constaction=workArgs.length>0 ? workArgs[0] : undefined;
341-
constscheduleZone=action&&action[zoneSymbol];
342-
if(scheduleZone&&scheduleZone!==Zone.current){
343-
returnscheduleZone.runGuarded(work,this,arguments);
344-
}else{
345-
returnwork.apply(this,arguments);
346-
}
347-
};
348-
returnschedule.call(this,patchedWork,delay,state);
349-
};
350-
};
351-
352185
patchObservable();
353186
patchSubscription();
354187
patchSubscriber();
355-
patchObservableFactoryCreator(Observable,'bindCallback');
356-
patchObservableFactoryCreator(Observable,'bindNodeCallback');
357-
patchObservableFactory(Observable,'defer');
358-
patchObservableFactory(Observable,'forkJoin');
359-
patchObservableFactoryArgs(Observable,'fromEventPattern');
360-
patchMulticast();
361-
patchImmediate(asap);
362188
});

‎package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"clang-format": "^1.2.3",
6767
"concurrently": "^2.2.0",
6868
"conventional-changelog": "^1.1.7",
69+
"core-js": "^2.5.7",
6970
"es6-promise": "^3.0.2",
7071
"google-closure-compiler": "^20170409.0.0",
7172
"gulp": "^3.8.11",
@@ -93,13 +94,13 @@
9394
"phantomjs": "^2.1.7",
9495
"promises-aplus-tests": "^2.1.2",
9596
"pump": "^1.0.1",
96-
"rxjs": "^5.5.3",
97+
"rxjs": "^6.2.1",
9798
"selenium-webdriver": "^3.4.0",
9899
"systemjs": "^0.19.37",
99100
"ts-loader": "^0.6.0",
100101
"tslint": "^4.1.1",
101102
"tslint-eslint-rules": "^3.1.0",
102-
"typescript": "2.5.2",
103+
"typescript": "2.9.2",
103104
"vrsource-tslint-rules": "^4.0.0",
104105
"webdriver-manager": "^12.0.6",
105106
"webdriverio": "^4.8.0",

‎test/browser_entry_point.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import'core-js/features/set';
10+
import'core-js/features/map';
911
// List all tests here:
1012
import'./common_tests';
1113
import'./browser/browser.spec';

0 commit comments

Comments
 (0)