Skip to content

Commit ffc4e68

Browse files
ChristianKohlerbenlesh
authored andcommittedMay 10, 2019
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

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎src/internal/Subscription.ts

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

0 commit comments

Comments
 (0)
Please sign in to comment.