Skip to content

Commit db11cba

Browse files
committed
function overloading
1 parent aeb3a7d commit db11cba

File tree

5 files changed

+21
-34
lines changed

5 files changed

+21
-34
lines changed

src/jsutils/didYouMean.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ const MAX_SUGGESTIONS = 5;
33
/**
44
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
55
*/
6-
declare function didYouMean(suggestions: ReadonlyArray<string>): string;
7-
// eslint-disable-next-line no-redeclare
8-
declare function didYouMean(
6+
export function didYouMean(suggestions: ReadonlyArray<string>): string;
7+
export function didYouMean(
98
subMessage: string,
109
suggestions: ReadonlyArray<string>,
1110
): string;
12-
13-
// eslint-disable-next-line no-redeclare
14-
export function didYouMean(firstArg, secondArg) {
11+
export function didYouMean(
12+
firstArg: string | ReadonlyArray<string>,
13+
secondArg?: ReadonlyArray<string>,
14+
) {
1515
const [subMessage, suggestionsArg] =
1616
typeof firstArg === 'string'
1717
? [firstArg, secondArg]

src/jsutils/isAsyncIterable.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
* Returns true if the provided object implements the AsyncIterator protocol via
33
* implementing a `Symbol.asyncIterator` method.
44
*/
5-
declare function isAsyncIterable(
6-
value: unknown,
7-
// $FlowFixMe[invalid-in-rhs]
8-
): value is AsyncIterable<unknown>;
9-
10-
// eslint-disable-next-line no-redeclare
11-
export function isAsyncIterable(maybeAsyncIterable) {
5+
export function isAsyncIterable(
6+
maybeAsyncIterable: unknown,
7+
): maybeAsyncIterable is AsyncIterable<unknown> {
128
return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function';
139
}

src/jsutils/isIterableObject.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
* isIterableObject({ key: 'value' }) // false
1515
* isIterableObject({ length: 1, 0: 'Alpha' }) // false
1616
*/
17-
declare function isIterableObject(
18-
value: unknown,
19-
// $FlowFixMe[invalid-in-rhs]
20-
): value is Iterable<unknown>;
21-
22-
// eslint-disable-next-line no-redeclare
23-
export function isIterableObject(maybeIterable: unknown): boolean {
17+
export function isIterableObject(
18+
maybeIterable: unknown,
19+
): maybeIteratable is Iterable<unknown> {
2420
return (
2521
typeof maybeIterable === 'object' &&
2622
typeof maybeIterable?.[Symbol.iterator] === 'function'

src/jsutils/toObjMap.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import type {
55
ReadOnlyObjMapLike,
66
} from './ObjMap';
77

8-
/* eslint-disable no-redeclare */
9-
declare function toObjMap<T>(obj: ObjMapLike<T>): ObjMap<T>;
10-
declare function toObjMap<T>(obj: ReadOnlyObjMapLike<T>): ReadOnlyObjMap<T>;
11-
12-
export function toObjMap(obj) {
13-
/* eslint-enable no-redeclare */
8+
export function toObjMap<T>(obj: ObjMapLike<T>): ObjMap<T>;
9+
export function toObjMap<T>(obj: ReadOnlyObjMapLike<T>): ReadOnlyObjMap<T>;
10+
export function toObjMap<T>(obj: ObjMapLike<T> | ReadOnlyObjMapLike<T>) {
1411
if (Object.getPrototypeOf(obj) === null) {
1512
return obj;
1613
}

src/utilities/typeFromAST.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@ import { GraphQLList, GraphQLNonNull } from '../type/definition';
2020
* the type called "User" found in the schema. If a type called "User" is not
2121
* found in the schema, then undefined will be returned.
2222
*/
23-
/* eslint-disable no-redeclare */
24-
declare function typeFromAST(
23+
export function typeFromAST(
2524
schema: GraphQLSchema,
2625
typeNode: NamedTypeNode,
27-
): GraphQLNamedType | void;
28-
declare function typeFromAST(
26+
): GraphQLNamedType | undefined;
27+
export function typeFromAST(
2928
schema: GraphQLSchema,
3029
typeNode: ListTypeNode,
31-
): GraphQLList<any> | void;
32-
declare function typeFromAST(
30+
): GraphQLList<any> | undefined;
31+
export function typeFromAST(
3332
schema: GraphQLSchema,
3433
typeNode: NonNullTypeNode,
35-
): GraphQLNonNull<any> | void;
34+
): GraphQLNonNull<any> | undefined;
3635
export function typeFromAST(schema, typeNode) {
37-
/* eslint-enable no-redeclare */
3836
let innerType;
3937
if (typeNode.kind === Kind.LIST_TYPE) {
4038
innerType = typeFromAST(schema, typeNode.type);

0 commit comments

Comments
 (0)