Skip to content

Commit 3a3b7e8

Browse files
committed
remove instanceof
1 parent 0254e5f commit 3a3b7e8

File tree

6 files changed

+11
-153
lines changed

6 files changed

+11
-153
lines changed

Diff for: src/jsutils/__tests__/instanceOf-test.ts

-79
This file was deleted.

Diff for: src/jsutils/instanceOf.ts

-59
This file was deleted.

Diff for: src/language/source.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { devAssert } from '../jsutils/devAssert.js';
2-
import { instanceOf } from '../jsutils/instanceOf.js';
32

43
interface Location {
54
line: number;
@@ -47,5 +46,5 @@ export class Source {
4746
* @internal
4847
*/
4948
export function isSource(source: unknown): source is Source {
50-
return instanceOf(source, Source);
49+
return source instanceof Source;
5150
}

Diff for: src/type/definition.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { devAssert } from '../jsutils/devAssert.js';
22
import { didYouMean } from '../jsutils/didYouMean.js';
33
import { identityFunc } from '../jsutils/identityFunc.js';
44
import { inspect } from '../jsutils/inspect.js';
5-
import { instanceOf } from '../jsutils/instanceOf.js';
65
import { keyMap } from '../jsutils/keyMap.js';
76
import { keyValMap } from '../jsutils/keyValMap.js';
87
import { mapValue } from '../jsutils/mapValue.js';
@@ -78,7 +77,7 @@ export function assertType(type: unknown): GraphQLType {
7877
* There are predicates for each kind of GraphQL type.
7978
*/
8079
export function isScalarType(type: unknown): type is GraphQLScalarType {
81-
return instanceOf(type, GraphQLScalarType);
80+
return type instanceof GraphQLScalarType;
8281
}
8382

8483
export function assertScalarType(type: unknown): GraphQLScalarType {
@@ -89,7 +88,7 @@ export function assertScalarType(type: unknown): GraphQLScalarType {
8988
}
9089

9190
export function isObjectType(type: unknown): type is GraphQLObjectType {
92-
return instanceOf(type, GraphQLObjectType);
91+
return type instanceof GraphQLObjectType;
9392
}
9493

9594
export function assertObjectType(type: unknown): GraphQLObjectType {
@@ -100,7 +99,7 @@ export function assertObjectType(type: unknown): GraphQLObjectType {
10099
}
101100

102101
export function isInterfaceType(type: unknown): type is GraphQLInterfaceType {
103-
return instanceOf(type, GraphQLInterfaceType);
102+
return type instanceof GraphQLInterfaceType;
104103
}
105104

106105
export function assertInterfaceType(type: unknown): GraphQLInterfaceType {
@@ -113,7 +112,7 @@ export function assertInterfaceType(type: unknown): GraphQLInterfaceType {
113112
}
114113

115114
export function isUnionType(type: unknown): type is GraphQLUnionType {
116-
return instanceOf(type, GraphQLUnionType);
115+
return type instanceof GraphQLUnionType;
117116
}
118117

119118
export function assertUnionType(type: unknown): GraphQLUnionType {
@@ -124,7 +123,7 @@ export function assertUnionType(type: unknown): GraphQLUnionType {
124123
}
125124

126125
export function isEnumType(type: unknown): type is GraphQLEnumType {
127-
return instanceOf(type, GraphQLEnumType);
126+
return type instanceof GraphQLEnumType;
128127
}
129128

130129
export function assertEnumType(type: unknown): GraphQLEnumType {
@@ -137,7 +136,7 @@ export function assertEnumType(type: unknown): GraphQLEnumType {
137136
export function isInputObjectType(
138137
type: unknown,
139138
): type is GraphQLInputObjectType {
140-
return instanceOf(type, GraphQLInputObjectType);
139+
return type instanceof GraphQLInputObjectType;
141140
}
142141

143142
export function assertInputObjectType(type: unknown): GraphQLInputObjectType {
@@ -157,7 +156,7 @@ export function isListType(
157156
): type is GraphQLList<GraphQLOutputType>;
158157
export function isListType(type: unknown): type is GraphQLList<GraphQLType>;
159158
export function isListType(type: unknown): type is GraphQLList<GraphQLType> {
160-
return instanceOf(type, GraphQLList);
159+
return type instanceof GraphQLList;
161160
}
162161

163162
export function assertListType(type: unknown): GraphQLList<GraphQLType> {
@@ -179,7 +178,7 @@ export function isNonNullType(
179178
export function isNonNullType(
180179
type: unknown,
181180
): type is GraphQLNonNull<GraphQLNullableType> {
182-
return instanceOf(type, GraphQLNonNull);
181+
return type instanceof GraphQLNonNull;
183182
}
184183

185184
export function assertNonNullType(

Diff for: src/type/directives.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { inspect } from '../jsutils/inspect.js';
2-
import { instanceOf } from '../jsutils/instanceOf.js';
32
import type { Maybe } from '../jsutils/Maybe.js';
43
import { toObjMap } from '../jsutils/toObjMap.js';
54

@@ -22,7 +21,7 @@ import { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.js';
2221
* Test if the given value is a GraphQL directive.
2322
*/
2423
export function isDirective(directive: unknown): directive is GraphQLDirective {
25-
return instanceOf(directive, GraphQLDirective);
24+
return directive instanceof GraphQLDirective;
2625
}
2726

2827
export function assertDirective(directive: unknown): GraphQLDirective {

Diff for: src/type/schema.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { inspect } from '../jsutils/inspect.js';
2-
import { instanceOf } from '../jsutils/instanceOf.js';
32
import type { Maybe } from '../jsutils/Maybe.js';
43
import type { ObjMap } from '../jsutils/ObjMap.js';
54
import { toObjMap } from '../jsutils/toObjMap.js';
@@ -41,7 +40,7 @@ import {
4140
* Test if the given value is a GraphQL schema.
4241
*/
4342
export function isSchema(schema: unknown): schema is GraphQLSchema {
44-
return instanceOf(schema, GraphQLSchema);
43+
return schema instanceof GraphQLSchema;
4544
}
4645

4746
export function assertSchema(schema: unknown): GraphQLSchema {

0 commit comments

Comments
 (0)