Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: build core type error (#4923)

Wenzhao Hu3d2d6d15e333
diff --git a/packages/core/src/shared/lifecycle.ts b/packages/core/src/shared/lifecycle.ts
index e61ea81a83..426dd34f3f 100644
--- a/packages/core/src/shared/lifecycle.ts
+++ b/packages/core/src/shared/lifecycle.ts
@@ -14,13 +14,18 @@
* limitations under the License.
*/
-import type { Subscription, SubscriptionLike } from 'rxjs';
+import type { SubscriptionLike } from 'rxjs';
import type { IDisposable } from '../common/di';
-import { Subject } from 'rxjs';
-import { isSubscription } from 'rxjs/internal/Subscription';
+import { Subject, Subscription } from 'rxjs';
type DisposableLike = IDisposable | SubscriptionLike | (() => void);
+// eslint-disable-next-line ts/no-explicit-any
+function isSubscriptionLike(value: any): value is SubscriptionLike {
+ return value instanceof Subscription || value instanceof Subject ||
+ (value && 'closed' in value && typeof value.unsubscribe !== 'undefined');
+}
+
export function toDisposable(disposable: IDisposable): IDisposable;
export function toDisposable(subscription: SubscriptionLike): IDisposable;
export function toDisposable(callback: () => void): IDisposable;
@@ -34,7 +39,7 @@ export function toDisposable(v: DisposableLike): IDisposable {
});
}
- if (isSubscription(v)) {
+ if (isSubscriptionLike(v)) {
return {
dispose: () => v.unsubscribe(),
};