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 15, 2021
1 parent 6fa819b commit 2f45a2a
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 2f45a2a

Please sign in to comment.