Skip to content

Commit

Permalink
fix(symbol): revert unique symbol in #5874
Browse files Browse the repository at this point in the history
- closes #5919
  • Loading branch information
kwonoj committed Apr 12, 2021
1 parent 5d0552b commit 6395e3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api_guard/dist/types/index.d.ts
Expand Up @@ -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<T> implements Subscribable<T> {
protected operator: Operator<any, T> | undefined;
Expand Down
9 changes: 9 additions & 0 deletions 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')();
16 changes: 0 additions & 16 deletions src/internal/types.ts
Expand Up @@ -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<T, R> {
Expand Down

0 comments on commit 6395e3f

Please sign in to comment.