@@ -65,7 +65,7 @@ export type GraphQLType =
65
65
| GraphQLList < any >
66
66
| GraphQLNonNull < any > ;
67
67
68
- export function isType ( type : unknown ) : boolean {
68
+ export function isType ( type : unknown ) : type is GraphQLType {
69
69
return (
70
70
isScalarType ( type ) ||
71
71
isObjectType ( type ) ||
@@ -88,10 +88,7 @@ export function assertType(type: unknown): GraphQLType {
88
88
/**
89
89
* There are predicates for each kind of GraphQL type.
90
90
*/
91
-
92
- declare function isScalarType ( type : unknown ) : boolean ;
93
- // eslint-disable-next-line no-redeclare
94
- export function isScalarType ( type ) {
91
+ export function isScalarType ( type : unknown ) : type is GraphQLScalarType {
95
92
return instanceOf ( type , GraphQLScalarType ) ;
96
93
}
97
94
@@ -102,9 +99,7 @@ export function assertScalarType(type: unknown): GraphQLScalarType {
102
99
return type ;
103
100
}
104
101
105
- declare function isObjectType ( type : unknown ) : boolean ;
106
- // eslint-disable-next-line no-redeclare
107
- export function isObjectType ( type ) {
102
+ export function isObjectType ( type : unknown ) : type is GraphQLObjectType {
108
103
return instanceOf ( type , GraphQLObjectType ) ;
109
104
}
110
105
@@ -115,9 +110,7 @@ export function assertObjectType(type: unknown): GraphQLObjectType {
115
110
return type ;
116
111
}
117
112
118
- declare function isInterfaceType ( type : unknown ) : boolean ;
119
- // eslint-disable-next-line no-redeclare
120
- export function isInterfaceType ( type ) {
113
+ export function isInterfaceType ( type : unknown ) : type is GraphQLInterfaceType {
121
114
return instanceOf ( type , GraphQLInterfaceType ) ;
122
115
}
123
116
@@ -130,9 +123,7 @@ export function assertInterfaceType(type: unknown): GraphQLInterfaceType {
130
123
return type ;
131
124
}
132
125
133
- declare function isUnionType ( type : unknown ) : boolean ;
134
- // eslint-disable-next-line no-redeclare
135
- export function isUnionType ( type ) {
126
+ export function isUnionType ( type : unknown ) : type is GraphQLUnionType {
136
127
return instanceOf ( type , GraphQLUnionType ) ;
137
128
}
138
129
@@ -143,9 +134,7 @@ export function assertUnionType(type: unknown): GraphQLUnionType {
143
134
return type ;
144
135
}
145
136
146
- declare function isEnumType ( type : unknown ) : boolean ;
147
- // eslint-disable-next-line no-redeclare
148
- export function isEnumType ( type ) {
137
+ export function isEnumType ( type : unknown ) : type is GraphQLEnumType {
149
138
return instanceOf ( type , GraphQLEnumType ) ;
150
139
}
151
140
@@ -156,9 +145,7 @@ export function assertEnumType(type: unknown): GraphQLEnumType {
156
145
return type ;
157
146
}
158
147
159
- declare function isInputObjectType ( type : unknown ) : boolean ;
160
- // eslint-disable-next-line no-redeclare
161
- export function isInputObjectType ( type ) {
148
+ export function isInputObjectType ( type : unknown ) : type is GraphQLInputObjectType {
162
149
return instanceOf ( type , GraphQLInputObjectType ) ;
163
150
}
164
151
@@ -171,9 +158,7 @@ export function assertInputObjectType(type: unknown): GraphQLInputObjectType {
171
158
return type ;
172
159
}
173
160
174
- declare function isListType ( type : unknown ) : boolean ;
175
- // eslint-disable-next-line no-redeclare
176
- export function isListType ( type ) {
161
+ export function isListType ( type : unknown ) : type is GraphQLList < any > {
177
162
return instanceOf ( type , GraphQLList ) ;
178
163
}
179
164
@@ -184,9 +169,7 @@ export function assertListType(type: unknown): GraphQLList<any> {
184
169
return type ;
185
170
}
186
171
187
- declare function isNonNullType ( type : unknown ) : boolean ;
188
- // eslint-disable-next-line no-redeclare
189
- export function isNonNullType ( type ) {
172
+ export function isNonNullType ( type : unknown ) : type is GraphQLNonNull < any > {
190
173
return instanceOf ( type , GraphQLNonNull ) ;
191
174
}
192
175
@@ -212,7 +195,7 @@ export type GraphQLInputType =
212
195
| GraphQLList < GraphQLInputType > ,
213
196
> ;
214
197
215
- export function isInputType ( type : unknown ) : boolean {
198
+ export function isInputType ( type : unknown ) : type is GraphQLInputType {
216
199
return (
217
200
isScalarType ( type ) ||
218
201
isEnumType ( type ) ||
@@ -247,7 +230,7 @@ export type GraphQLOutputType =
247
230
| GraphQLList < GraphQLOutputType > ,
248
231
> ;
249
232
250
- export function isOutputType ( type : unknown ) : boolean {
233
+ export function isOutputType ( type : unknown ) : type is GraphQLOutputType {
251
234
return (
252
235
isScalarType ( type ) ||
253
236
isObjectType ( type ) ||
@@ -270,7 +253,7 @@ export function assertOutputType(type: unknown): GraphQLOutputType {
270
253
*/
271
254
export type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType ;
272
255
273
- export function isLeafType ( type : unknown ) : boolean {
256
+ export function isLeafType ( type : unknown ) : type is GraphQLLeafType {
274
257
return isScalarType ( type ) || isEnumType ( type ) ;
275
258
}
276
259
@@ -289,7 +272,7 @@ export type GraphQLCompositeType =
289
272
| GraphQLInterfaceType
290
273
| GraphQLUnionType ;
291
274
292
- export function isCompositeType ( type : unknown ) : boolean {
275
+ export function isCompositeType ( type : unknown ) : type is GraphQLCompositeType {
293
276
return isObjectType ( type ) || isInterfaceType ( type ) || isUnionType ( type ) ;
294
277
}
295
278
@@ -307,7 +290,7 @@ export function assertCompositeType(type: unknown): GraphQLCompositeType {
307
290
*/
308
291
export type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType ;
309
292
310
- export function isAbstractType ( type : unknown ) : boolean {
293
+ export function isAbstractType ( type : unknown ) : type is GraphQLAbstractType {
311
294
return isInterfaceType ( type ) || isUnionType ( type ) ;
312
295
}
313
296
@@ -414,7 +397,7 @@ export class GraphQLNonNull<T extends GraphQLNullableType> {
414
397
415
398
export type GraphQLWrappingType = GraphQLList < any > | GraphQLNonNull < any > ;
416
399
417
- export function isWrappingType ( type : unknown ) : boolean {
400
+ export function isWrappingType ( type : unknown ) : type is GraphQLWrappingType {
418
401
return isListType ( type ) || isNonNullType ( type ) ;
419
402
}
420
403
@@ -437,7 +420,7 @@ export type GraphQLNullableType =
437
420
| GraphQLInputObjectType
438
421
| GraphQLList < any > ;
439
422
440
- export function isNullableType ( type : unknown ) : boolean {
423
+ export function isNullableType ( type : unknown ) : type is GraphQLNullableType {
441
424
return isType ( type ) && ! isNonNullType ( type ) ;
442
425
}
443
426
@@ -448,12 +431,11 @@ export function assertNullableType(type: unknown): GraphQLNullableType {
448
431
return type ;
449
432
}
450
433
451
- /* eslint-disable no-redeclare */
452
- declare function getNullableType ( type : void | null ) : void ;
453
- declare function getNullableType < T extends GraphQLNullableType > ( type : T ) : T ;
454
- declare function getNullableType < T > ( type : GraphQLNonNull < T > ) : T ;
434
+
435
+ export function getNullableType ( type : void | null ) : void ;
436
+ export function getNullableType < T extends GraphQLNullableType > ( type : T ) : T ;
437
+ export function getNullableType < T extends GraphQLNullableType > ( type : GraphQLNonNull < T > ) : T ;
455
438
export function getNullableType ( type ) {
456
- /* eslint-enable no-redeclare */
457
439
if ( type ) {
458
440
return isNonNullType ( type ) ? type . ofType : type ;
459
441
}
@@ -470,7 +452,7 @@ export type GraphQLNamedType =
470
452
| GraphQLEnumType
471
453
| GraphQLInputObjectType ;
472
454
473
- export function isNamedType ( type : unknown ) : boolean {
455
+ export function isNamedType ( type : unknown ) : type is GraphQLNamedType {
474
456
return (
475
457
isScalarType ( type ) ||
476
458
isObjectType ( type ) ||
@@ -488,11 +470,9 @@ export function assertNamedType(type: unknown): GraphQLNamedType {
488
470
return type ;
489
471
}
490
472
491
- /* eslint-disable no-redeclare */
492
- declare function getNamedType ( type : void | null ) : void ;
493
- declare function getNamedType ( type : GraphQLType ) : GraphQLNamedType ;
473
+ export function getNamedType ( type : void | null ) : void ;
474
+ export function getNamedType ( type : GraphQLType ) : GraphQLNamedType ;
494
475
export function getNamedType ( type ) {
495
- /* eslint-enable no-redeclare */
496
476
if ( type ) {
497
477
let unwrappedType = type ;
498
478
while ( isWrappingType ( unwrappedType ) ) {
0 commit comments