Skip to content

Commit 68b6588

Browse files
committed
convert : (flow) with extends (TS)
1 parent 65fb7a8 commit 68b6588

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

src/language/visitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type ShapeMap<O, F> = $Shape<$ObjMap<O, F>>;
2525
* A visitor is comprised of visit functions, which are called on each node
2626
* during the visitor's traversal.
2727
*/
28-
export type VisitFn<TAnyNode, TVisitedNode: TAnyNode = TAnyNode> = (
28+
export type VisitFn<TAnyNode, TVisitedNode extends TAnyNode = TAnyNode> = (
2929
// The current node being visiting.
3030
node: TVisitedNode,
3131
// The index or key to this node from the parent node or Array.

src/subscription/__tests__/subscribe-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const EmailEventType = new GraphQLObjectType({
6868

6969
const emailSchema = emailSchemaWithResolvers();
7070

71-
function emailSchemaWithResolvers<T: unknown>(
71+
function emailSchemaWithResolvers<T extends unknown>(
7272
subscribeFn?: (T) => unknown,
7373
resolveFn?: (T) => unknown,
7474
) {

src/type/__tests__/validation-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const SomeInputObjectType = assertInputObjectType(
6868

6969
const SomeDirective = assertDirective(SomeSchema.getDirective('SomeDirective'));
7070

71-
function withModifiers<T: GraphQLNamedType>(
71+
function withModifiers<T extends GraphQLNamedType>(
7272
type: T,
7373
): Array<T | GraphQLList<T> | GraphQLNonNull<T | GraphQLList<T>>> {
7474
return [

src/type/definition.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ export function assertAbstractType(type: unknown): GraphQLAbstractType {
344344
* })
345345
*
346346
*/
347-
export class GraphQLList<+T: GraphQLType> {
348-
+ofType: T;
347+
export class GraphQLList<T extends GraphQLType> {
348+
readonly ofType: T;
349349

350350
constructor(ofType: T) {
351351
devAssert(
@@ -390,8 +390,8 @@ export class GraphQLList<+T: GraphQLType> {
390390
*
391391
* Note: the enforcement of non-nullability occurs within the executor.
392392
*/
393-
export class GraphQLNonNull<+T: GraphQLNullableType> {
394-
+ofType: T;
393+
export class GraphQLNonNull<T extends GraphQLNullableType> {
394+
readonly ofType: T;
395395

396396
constructor(ofType: T) {
397397
devAssert(
@@ -458,7 +458,7 @@ export function assertNullableType(type: unknown): GraphQLNullableType {
458458

459459
/* eslint-disable no-redeclare */
460460
declare function getNullableType(type: void | null): void;
461-
declare function getNullableType<T: GraphQLNullableType>(type: T): T;
461+
declare function getNullableType<T extends GraphQLNullableType>(type: T): T;
462462
declare function getNullableType<T>(type: GraphQLNonNull<T>): T;
463463
export function getNullableType(type) {
464464
/* eslint-enable no-redeclare */

src/type/validate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ type SDLDefinedObject<T, K> = {
617617
readonly extensionASTNodes?: Maybe<ReadonlyArray<K>>,
618618
};
619619

620-
function getAllNodes<T: ASTNode, K: ASTNode>(
620+
function getAllNodes<T extends ASTNode, K extends ASTNode>(
621621
object: SDLDefinedObject<T, K>,
622622
): ReadonlyArray<T | K> {
623623
const { astNode, extensionASTNodes } = object;
@@ -628,7 +628,7 @@ function getAllNodes<T: ASTNode, K: ASTNode>(
628628
: extensionASTNodes ?? [];
629629
}
630630

631-
function getAllSubNodes<T: ASTNode, K: ASTNode, L: ASTNode>(
631+
function getAllSubNodes<T extends ASTNode, K extends ASTNode, L extends ASTNode>(
632632
object: SDLDefinedObject<T, K>,
633633
getter: (T | K) => Maybe<(L | ReadonlyArray<L>)>,
634634
): ReadonlyArray<L> {

src/utilities/extendSchema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export function extendSchemaImpl(
220220
// Below are functions used for producing this schema that have closed over
221221
// this scope and have access to the schema, cache, and newly defined types.
222222

223-
function replaceType<T: GraphQLType>(type: T): T {
223+
function replaceType<T extends GraphQLType>(type: T): T {
224224
if (isListType(type)) {
225225
// $FlowFixMe[incompatible-return]
226226
return new GraphQLList(replaceType(type.ofType));
@@ -232,7 +232,7 @@ export function extendSchemaImpl(
232232
return replaceNamedType(type);
233233
}
234234

235-
function replaceNamedType<T: GraphQLNamedType>(type: T): T {
235+
function replaceNamedType<T extends GraphQLNamedType>(type: T): T {
236236
// Note: While this could make early assertions to get the correctly
237237
// typed values, that would throw immediately while type system
238238
// validation with validateSchema() will produce more actionable results.

src/utilities/findBreakingChanges.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ function stringifyValue(value: unknown, type: GraphQLInputType): string {
551551
return print(sortedAST);
552552
}
553553

554-
function diff<T: { name: string }>(
554+
function diff<T extends { name: string }>(
555555
oldArray: ReadonlyArray<T>,
556556
newArray: ReadonlyArray<T>,
557557
): {

src/utilities/getIntrospectionQuery.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ export type IntrospectionInputObjectType = {
224224
};
225225

226226
export type IntrospectionListTypeRef<
227-
T: IntrospectionTypeRef = IntrospectionTypeRef,
227+
T extends IntrospectionTypeRef = IntrospectionTypeRef,
228228
> = {
229229
readonly kind: 'LIST',
230230
readonly ofType: T,
231231
};
232232

233233
export type IntrospectionNonNullTypeRef<
234-
T: IntrospectionTypeRef = IntrospectionTypeRef,
234+
T extends IntrospectionTypeRef = IntrospectionTypeRef,
235235
> = {
236236
readonly kind: 'NON_NULL',
237237
readonly ofType: T,
@@ -261,7 +261,7 @@ export type IntrospectionInputTypeRef =
261261
>;
262262

263263
export type IntrospectionNamedTypeRef<
264-
T: IntrospectionType = IntrospectionType,
264+
T extends IntrospectionType = IntrospectionType,
265265
> = {
266266
readonly kind: $PropertyType<T, 'kind'>,
267267
readonly name: string,

src/utilities/lexicographicSortSchema.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {
5656
subscription: replaceMaybeType(schemaConfig.subscription),
5757
});
5858

59-
function replaceType<T: GraphQLType>(type: T): T {
59+
function replaceType<T extends GraphQLType>(type: T): T {
6060
if (isListType(type)) {
6161
// $FlowFixMe[incompatible-return]
6262
return new GraphQLList(replaceType(type.ofType));
@@ -67,11 +67,11 @@ export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {
6767
return replaceNamedType(type);
6868
}
6969

70-
function replaceNamedType<T: GraphQLNamedType>(type: T): T {
70+
function replaceNamedType<T extends GraphQLNamedType>(type: T): T {
7171
return ((typeMap[type.name]: any): T);
7272
}
7373

74-
function replaceMaybeType<T: Maybe<GraphQLNamedType>>(maybeType: T): T {
74+
function replaceMaybeType<T extends Maybe<GraphQLNamedType>>(maybeType: T): T {
7575
return maybeType && replaceNamedType(maybeType);
7676
}
7777

@@ -106,11 +106,11 @@ export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {
106106
}));
107107
}
108108

109-
function sortTypes<T: GraphQLNamedType>(arr: ReadonlyArray<T>): Array<T> {
109+
function sortTypes<T extends GraphQLNamedType>(arr: ReadonlyArray<T>): Array<T> {
110110
return sortByName(arr).map(replaceNamedType);
111111
}
112112

113-
function sortNamedType<T: GraphQLNamedType>(type: T) {
113+
function sortNamedType<T extends GraphQLNamedType>(type: T) {
114114
if (isScalarType(type) || isIntrospectionType(type)) {
115115
return type;
116116
}
@@ -168,7 +168,7 @@ function sortObjMap<T, R>(map: ObjMap<T>, sortValueFn?: (T) => R): ObjMap<R> {
168168
return sortedMap;
169169
}
170170

171-
function sortByName<T: { readonly name: string }>(
171+
function sortByName<T extends { readonly name: string }>(
172172
array: ReadonlyArray<T>,
173173
): Array<T> {
174174
return sortBy(array, (obj) => obj.name);

0 commit comments

Comments
 (0)