Skip to content

Commit ffc4e68

Browse files
ChristianKohlerbenlesh
authored andcommitted
fix(Subscription): Return Empty when teardown === null (#4575)
* fix(Subscription): Return Empty when teardown === null `typeof teardown` returns object when null. It breaks later when rxjs tries to access the closed property. The commit fixes that by first checking for null/undefined. * fix(Subscription): tslint errors
1 parent 126d2b6 commit ffc4e68

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/internal/Subscription.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ export class Subscription implements SubscriptionLike {
130130
*/
131131
add(teardown: TeardownLogic): Subscription{
132132
letsubscription=(<Subscription>teardown);
133+
134+
if(!(<any>teardown)){
135+
returnSubscription.EMPTY;
136+
}
137+
133138
switch(typeofteardown){
134139
case'function':
135140
subscription=newSubscription(<(()=>void)>teardown);
@@ -147,9 +152,6 @@ export class Subscription implements SubscriptionLike {
147152
}
148153
break;
149154
default: {
150-
if(!(<any>teardown)){
151-
returnSubscription.EMPTY;
152-
}
153155
thrownewError('unrecognized teardown '+teardown+' added to Subscription.');
154156
}
155157
}

0 commit comments

Comments
 (0)