Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove polyfills for Symbol #2913

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/error/GraphQLError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// flowlint uninitialized-instance-property:off

import isObjectLike from '../jsutils/isObjectLike';
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';

import type { ASTNode } from '../language/ast';
import type { Source } from '../language/source';
Expand Down Expand Up @@ -213,7 +212,7 @@ export class GraphQLError extends Error {

// FIXME: workaround to not break chai comparisons, should be remove in v16
// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG](): string {
get [Symbol.toStringTag](): string {
return 'Object';
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/jsutils/isAsyncIterable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { SYMBOL_ASYNC_ITERATOR } from '../polyfills/symbols';

/**
* Returns true if the provided object implements the AsyncIterator protocol via
* either implementing a `Symbol.asyncIterator` or `"@@asyncIterator"` method.
Expand All @@ -9,5 +7,5 @@ declare function isAsyncIterable(value: mixed): boolean %checks(value instanceof

// eslint-disable-next-line no-redeclare
export default function isAsyncIterable(maybeAsyncIterable) {
return typeof maybeAsyncIterable?.[SYMBOL_ASYNC_ITERATOR] === 'function';
return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function';
}
4 changes: 1 addition & 3 deletions src/jsutils/isCollection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { SYMBOL_ITERATOR } from '../polyfills/symbols';

/**
* Returns true if the provided object is an Object (i.e. not a string literal)
* and is either Iterable or Array-like.
Expand Down Expand Up @@ -37,5 +35,5 @@ export default function isCollection(obj) {
}

// Is Iterable?
return typeof obj[SYMBOL_ITERATOR] === 'function';
return typeof obj[Symbol.iterator] === 'function';
}
4 changes: 1 addition & 3 deletions src/language/source.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';

import inspect from '../jsutils/inspect';
import devAssert from '../jsutils/devAssert';
import instanceOf from '../jsutils/instanceOf';
Expand Down Expand Up @@ -45,7 +43,7 @@ export class Source {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'Source';
}
}
Expand Down
19 changes: 0 additions & 19 deletions src/polyfills/symbols.js

This file was deleted.

6 changes: 2 additions & 4 deletions src/subscription/mapAsyncIterator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { SYMBOL_ASYNC_ITERATOR } from '../polyfills/symbols';

import type { PromiseOrValue } from '../jsutils/PromiseOrValue';

/**
Expand All @@ -12,7 +10,7 @@ export default function mapAsyncIterator<T, U>(
rejectCallback?: (any) => PromiseOrValue<U>,
): AsyncGenerator<U, void, void> {
// $FlowFixMe[prop-missing]
const iteratorMethod = iterable[SYMBOL_ASYNC_ITERATOR];
const iteratorMethod = iterable[Symbol.asyncIterator];
const iterator: any = iteratorMethod.call(iterable);
let $return: any;
let abruptClose;
Expand Down Expand Up @@ -55,7 +53,7 @@ export default function mapAsyncIterator<T, U>(
}
return Promise.reject(error).catch(abruptClose);
},
[SYMBOL_ASYNC_ITERATOR]() {
[Symbol.asyncIterator]() {
return this;
},
}: $FlowFixMe);
Expand Down
17 changes: 8 additions & 9 deletions src/type/definition.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import objectEntries from '../polyfills/objectEntries';
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';

import type { Path } from '../jsutils/Path';
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
Expand Down Expand Up @@ -366,7 +365,7 @@ export class GraphQLList<+T: GraphQLType> {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLList';
}
}
Expand Down Expand Up @@ -415,7 +414,7 @@ export class GraphQLNonNull<+T: GraphQLNullableType> {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLNonNull';
}
}
Expand Down Expand Up @@ -627,7 +626,7 @@ export class GraphQLScalarType {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLScalarType';
}
}
Expand Down Expand Up @@ -774,7 +773,7 @@ export class GraphQLObjectType {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLObjectType';
}
}
Expand Down Expand Up @@ -1094,7 +1093,7 @@ export class GraphQLInterfaceType {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLInterfaceType';
}
}
Expand Down Expand Up @@ -1204,7 +1203,7 @@ export class GraphQLUnionType {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLUnionType';
}
}
Expand Down Expand Up @@ -1385,7 +1384,7 @@ export class GraphQLEnumType /* <T> */ {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLEnumType';
}
}
Expand Down Expand Up @@ -1537,7 +1536,7 @@ export class GraphQLInputObjectType {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLInputObjectType';
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/type/directives.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import objectEntries from '../polyfills/objectEntries';
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';

import type { ReadOnlyObjMap, ReadOnlyObjMapLike } from '../jsutils/ObjMap';
import inspect from '../jsutils/inspect';
Expand Down Expand Up @@ -105,7 +104,7 @@ export class GraphQLDirective {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLDirective';
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/type/schema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import objectValues from '../polyfills/objectValues';
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';

import type {
ObjMap,
Expand Down Expand Up @@ -346,7 +345,7 @@ export class GraphQLSchema {
}

// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
get [SYMBOL_TO_STRING_TAG]() {
get [Symbol.toStringTag]() {
return 'GraphQLSchema';
}
}
Expand Down