From 6395e3fa88c6d2e25f26319c1d6d6bdc844f614e Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Mon, 12 Apr 2021 09:27:17 -0700 Subject: [PATCH] fix(symbol): revert unique symbol in #5874 - closes #5919 --- api_guard/dist/types/index.d.ts | 2 +- src/internal/symbol/observable.ts | 9 +++++++++ src/internal/types.ts | 16 ---------------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index a079b65c08..f314fc5706 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -238,7 +238,7 @@ export interface ObjectUnsubscribedError extends Error { export declare const ObjectUnsubscribedError: ObjectUnsubscribedErrorCtor; -export declare const observable: string | SymbolConstructor["observable"]; +export declare const observable: string | symbol; export declare class Observable implements Subscribable { protected operator: Operator | undefined; diff --git a/src/internal/symbol/observable.ts b/src/internal/symbol/observable.ts index 35e7c27da6..974e73b1e8 100644 --- a/src/internal/symbol/observable.ts +++ b/src/internal/symbol/observable.ts @@ -1,2 +1,11 @@ +/** Symbol.observable addition */ +/* Note: This will add Symbol.observable globally for all TypeScript users, + however, we are no longer polyfilling Symbol.observable */ +declare global { + interface SymbolConstructor { + readonly observable: symbol; + } +} + /** Symbol.observable or a string "@@observable". Used for interop */ export const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')(); diff --git a/src/internal/types.ts b/src/internal/types.ts index 5d3f8b9881..944bfc1d45 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -4,22 +4,6 @@ import { Observable } from './Observable'; import { Subscription } from './Subscription'; -/** - * NOTE: This will add Symbol.observable globally for all TypeScript users, - * however, we are no longer polyfilling Symbol.observable. Note that this will be at - * odds with older version of @types/node and symbol-observable which incorrectly define - * `Symbol.observable` as `symbol` rather than `unique symbol`. "What about not defining - * this non-standard symbol at all?" you might ask... Well, that ship has sailed. There are - * dozens of libraries using this symbol now and many of them are quite popular. - * So here we are, and it's probably my fault. Sorry, "the web", if I have hurt you, - * the world just needed a standard way to provide interop for these types. -Ben - */ -declare global { - interface SymbolConstructor { - readonly observable: unique symbol; - } -} - /** OPERATOR INTERFACES */ export interface UnaryFunction {