diff --git a/src/jsutils/__tests__/instanceOf-test.js b/src/jsutils/__tests__/instanceOf-test.js index 2fa4fb39fd..3739587c5f 100644 --- a/src/jsutils/__tests__/instanceOf-test.js +++ b/src/jsutils/__tests__/instanceOf-test.js @@ -2,7 +2,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { instanceOf } from '../instanceOf'; -import { SYMBOL_TO_STRING_TAG } from '../../polyfills/symbols'; import { GraphQLScalarType, GraphQLObjectType, @@ -57,13 +56,13 @@ describe('instanceOf', () => { } function getTag(from: any): string { - return from[SYMBOL_TO_STRING_TAG]; + return from[Symbol.toStringTag]; } it('does not fail if dynamically-defined tags differ', () => { checkSameNameClasses((tag) => { class Foo {} - Object.defineProperty(Foo.prototype, SYMBOL_TO_STRING_TAG, { + Object.defineProperty(Foo.prototype, Symbol.toStringTag, { value: tag, }); return Foo; @@ -73,7 +72,7 @@ describe('instanceOf', () => { it('does not fail if dynamically-defined tag getters differ', () => { checkSameNameClasses((tag) => { class Foo {} - Object.defineProperty(Foo.prototype, SYMBOL_TO_STRING_TAG, { + Object.defineProperty(Foo.prototype, Symbol.toStringTag, { get() { return tag; }, @@ -85,7 +84,7 @@ describe('instanceOf', () => { it('does not fail for anonymous classes', () => { checkSameNameClasses((tag) => { const Foo = class {}; - Object.defineProperty(Foo.prototype, SYMBOL_TO_STRING_TAG, { + Object.defineProperty(Foo.prototype, Symbol.toStringTag, { get() { return tag; }, @@ -97,7 +96,7 @@ describe('instanceOf', () => { it('does not fail if prototype property tags differ', () => { checkSameNameClasses((tag) => { class Foo {} - (Foo.prototype: any)[SYMBOL_TO_STRING_TAG] = tag; + (Foo.prototype: any)[Symbol.toStringTag] = tag; return Foo; }); }); @@ -106,7 +105,7 @@ describe('instanceOf', () => { checkSameNameClasses((tag) => { class Foo { // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet - get [SYMBOL_TO_STRING_TAG]() { + get [Symbol.toStringTag]() { return tag; } } diff --git a/src/jsutils/instanceOf.js b/src/jsutils/instanceOf.js index 638c483c65..02b62999fd 100644 --- a/src/jsutils/instanceOf.js +++ b/src/jsutils/instanceOf.js @@ -1,5 +1,3 @@ -import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols'; - /** * A replacement for instanceof which includes an error warning when multi-realm * constructors are detected. @@ -18,7 +16,7 @@ export const instanceOf: (mixed, mixed) => boolean = } if (value) { const proto = constructor && constructor.prototype; - const classTag = proto && proto[SYMBOL_TO_STRING_TAG]; + const classTag = proto && proto[Symbol.toStringTag]; const className = classTag || constructor.name; // When the constructor class defines a Symbol.toStringTag // property, as most classes exported by graphql-js do, use it @@ -32,8 +30,8 @@ export const instanceOf: (mixed, mixed) => boolean = // they could be minified to the same short string, even though // value is legitimately _not_ instanceof constructor. const valueName = classTag - ? value[SYMBOL_TO_STRING_TAG] - : value.constructor && value.constructor.name; + ? value[Symbol.toStringTag] + : value.constructor && value.constructor.name; if (typeof className === 'string' && valueName === className) { throw new Error( `Cannot use ${className} "${value}" from another module or realm.