Skip to content

Commit 21dd3bd

Browse files
authored
fix(node/TS): eliminate incompatable types to protected properties (#3544)
Resolves an issue in Node and TypeScript where if a project had more than one copy of RxJS, even if it was the same version, types would be incompatable between say, Observable and Observable, due to protected fields in the dts files. As all of these fields are really implementation details of the library, and my be removed at any time do to architectural changes, it is prudent to mark them as deprecated. Marking them as public only serves to eliminate the type incompatibilities.
1 parent 451aa11 commit 21dd3bd

21 files changed

+62
-33
lines changed

src/internal/AsyncSubject.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export class AsyncSubject<T> extends Subject<T> {
1010
private hasNext: boolean = false;
1111
private hasCompleted: boolean = false;
1212

13-
protected _subscribe(subscriber: Subscriber<any>): Subscription {
13+
/** @deprecated This is an internal implementation detail, do not use. */
14+
_subscribe(subscriber: Subscriber<any>): Subscription {
1415
if (this.hasError) {
1516
subscriber.error(this.thrownError);
1617
return Subscription.EMPTY;

src/internal/BehaviorSubject.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export class BehaviorSubject<T> extends Subject<T> {
1717
return this.getValue();
1818
}
1919

20-
protected _subscribe(subscriber: Subscriber<T>): Subscription {
20+
/** @deprecated This is an internal implementation detail, do not use. */
21+
_subscribe(subscriber: Subscriber<T>): Subscription {
2122
const subscription = super._subscribe(subscriber);
2223
if (subscription && !(<SubscriptionLike>subscription).closed) {
2324
subscriber.next(this._value);

src/internal/Observable.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ export class Observable<T> implements Subscribable<T> {
2121
/** Internal implementation detail, do not use directly. */
2222
public _isScalar: boolean = false;
2323

24-
protected source: Observable<any>;
24+
/** @deprecated This is an internal implementation detail, do not use. */
25+
source: Observable<any>;
2526

26-
protected operator: Operator<any, T>;
27+
/** @deprecated This is an internal implementation detail, do not use. */
28+
operator: Operator<any, T>;
2729

2830
/**
2931
* @constructor
@@ -208,7 +210,8 @@ export class Observable<T> implements Subscribable<T> {
208210
return sink;
209211
}
210212

211-
protected _trySubscribe(sink: Subscriber<T>): TeardownLogic {
213+
/** @deprecated This is an internal implementation detail, do not use. */
214+
_trySubscribe(sink: Subscriber<T>): TeardownLogic {
212215
try {
213216
return this._subscribe(sink);
214217
} catch (err) {
@@ -247,8 +250,8 @@ export class Observable<T> implements Subscribable<T> {
247250
}) as Promise<void>;
248251
}
249252

250-
/** @internal */
251-
protected _subscribe(subscriber: Subscriber<any>): TeardownLogic {
253+
/** @deprecated This is an internal implementation detail, do not use. */
254+
_subscribe(subscriber: Subscriber<any>): TeardownLogic {
252255
const { source } = this;
253256
return source && source.subscribe(subscriber);
254257
}

src/internal/ReplaySubject.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export class ReplaySubject<T> extends Subject<T> {
4949
super.next(value);
5050
}
5151

52-
protected _subscribe(subscriber: Subscriber<T>): Subscription {
52+
/** @deprecated This is an internal implementation detail, do not use. */
53+
_subscribe(subscriber: Subscriber<T>): Subscription {
5354
// When `_infiniteTimeWindow === true` then the buffer is already trimmed
5455
const _infiniteTimeWindow = this._infiniteTimeWindow;
5556
const _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();

src/internal/Subject.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,17 @@ export class Subject<T> extends Observable<T> implements SubscriptionLike {
100100
this.observers = null;
101101
}
102102

103-
protected _trySubscribe(subscriber: Subscriber<T>): TeardownLogic {
103+
/** @deprecated This is an internal implementation detail, do not use. */
104+
_trySubscribe(subscriber: Subscriber<T>): TeardownLogic {
104105
if (this.closed) {
105106
throw new ObjectUnsubscribedError();
106107
} else {
107108
return super._trySubscribe(subscriber);
108109
}
109110
}
110111

111-
protected _subscribe(subscriber: Subscriber<T>): Subscription {
112+
/** @deprecated This is an internal implementation detail, do not use. */
113+
_subscribe(subscriber: Subscriber<T>): Subscription {
112114
if (this.closed) {
113115
throw new ObjectUnsubscribedError();
114116
} else if (this.hasError) {
@@ -160,7 +162,8 @@ export class AnonymousSubject<T> extends Subject<T> {
160162
}
161163
}
162164

163-
protected _subscribe(subscriber: Subscriber<T>): Subscription {
165+
/** @deprecated This is an internal implementation detail, do not use. */
166+
_subscribe(subscriber: Subscriber<T>): Subscription {
164167
const { source } = this;
165168
if (source) {
166169
return this.source.subscribe(subscriber);

src/internal/Subscriber.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ export class Subscriber<T> extends Subscription implements Observer<T> {
152152
this.unsubscribe();
153153
}
154154

155-
protected _unsubscribeAndRecycle(): Subscriber<T> {
155+
/** @deprecated This is an internal implementation detail, do not use. */
156+
_unsubscribeAndRecycle(): Subscriber<T> {
156157
const { _parent, _parents } = this;
157158
this._parent = null;
158159
this._parents = null;
@@ -296,7 +297,8 @@ class SafeSubscriber<T> extends Subscriber<T> {
296297
return false;
297298
}
298299

299-
protected _unsubscribe(): void {
300+
/** @deprecated This is an internal implementation detail, do not use. */
301+
_unsubscribe(): void {
300302
const { _parentSubscriber } = this;
301303
this._context = null;
302304
this._parentSubscriber = null;

src/internal/observable/ConnectableObservable.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ export class ConnectableObservable<T> extends Observable<T> {
1717
/** @internal */
1818
_isComplete = false;
1919

20-
constructor(protected source: Observable<T>,
20+
constructor(public source: Observable<T>,
2121
protected subjectFactory: () => Subject<T>) {
2222
super();
2323
}
2424

25-
protected _subscribe(subscriber: Subscriber<T>) {
25+
/** @deprecated This is an internal implementation detail, do not use. */
26+
_subscribe(subscriber: Subscriber<T>) {
2627
return this.getSubject().subscribe(subscriber);
2728
}
2829

src/internal/observable/SubscribeOnObservable.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class SubscribeOnObservable<T> extends Observable<T> {
3939
}
4040
}
4141

42-
protected _subscribe(subscriber: Subscriber<T>) {
42+
/** @deprecated This is an internal implementation detail, do not use. */
43+
_subscribe(subscriber: Subscriber<T>) {
4344
const delay = this.delayTime;
4445
const source = this.source;
4546
const scheduler = this.scheduler;

src/internal/observable/dom/AjaxObservable.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ export class AjaxObservable<T> extends Observable<T> {
179179
this.request = request;
180180
}
181181

182-
protected _subscribe(subscriber: Subscriber<T>): TeardownLogic {
182+
/** @deprecated This is an internal implementation detail, do not use. */
183+
_subscribe(subscriber: Subscriber<T>): TeardownLogic {
183184
return new AjaxSubscriber(subscriber, this.request);
184185
}
185186
}

src/internal/observable/dom/WebSocketSubject.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
6868

6969
private _config: WebSocketSubjectConfig<T>;
7070

71-
protected _output: Subject<T>;
71+
/** @deprecated This is an internal implementation detail, do not use. */
72+
_output: Subject<T>;
7273

7374
private _socket: WebSocket;
7475

@@ -263,7 +264,8 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
263264
};
264265
}
265266

266-
protected _subscribe(subscriber: Subscriber<T>): Subscription {
267+
/** @deprecated This is an internal implementation detail, do not use. */
268+
_subscribe(subscriber: Subscriber<T>): Subscription {
267269
const { source } = this;
268270
if (source) {
269271
return source.subscribe(subscriber);

0 commit comments

Comments
 (0)