Skip to content

Commit

Permalink
[BUGFIX 3.12] Backport Symbol fix (#6416)
Browse files Browse the repository at this point in the history
* Add a Symbol-like symbol (thank you glimmer-vm)

This is similar to what is implemented here:
https://github.com/glimmerjs/glimmer-vm/blob/72718d0d6ebb2614ec984f51435a44830d410e4c/packages/%40glimmer/reference/lib/validators.ts

* Replace `Symbol`s that may be iterable by `symbol`s

These occurences of Symbol might be replaced by this `symbol`, similar
but different in the sense it is iterable.
  • Loading branch information
dcyriller authored and runspired committed Sep 11, 2019
1 parent ddec675 commit 47a8052
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/store/addon/-private/ts-interfaces/utils/brand.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { symbol } from './symbol';

/**
@module @ember-data/store
*/
Expand All @@ -14,4 +16,5 @@
*
* @internal
*/
export const BRAND_SYMBOL = Symbol(`DEBUG-ts-brand`);

export const BRAND_SYMBOL: unique symbol = symbol('DEBUG-ts-brand');
19 changes: 19 additions & 0 deletions packages/store/addon/-private/ts-interfaces/utils/symbol.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
@module @ember-data/store
*/

/**
* This symbol provides a Symbol replacement for browsers that do not have it
* (eg. IE 11).
*
* The replacement is different from the native Symbol in some ways. It is a
* function that produces an output:
* - iterable;
* - that is a string, not a symbol.
*
* @internal
*/
export const symbol =
typeof Symbol !== 'undefined'
? Symbol
: (key: string) => `__${key}${Math.floor(Math.random() * Date.now())}__` as any;

0 comments on commit 47a8052

Please sign in to comment.