Skip to content

Commit

Permalink
TS: add 'declare' to function typings (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Dec 9, 2021
1 parent 285cb2d commit ffc7d38
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/connection/arrayConnection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ArraySliceMetaInfo {
* a connection object for use in GraphQL. It uses array offsets as pagination,
* so pagination will only work if the array is static.
*/
export function connectionFromArray<T>(
export declare function connectionFromArray<T>(
data: ReadonlyArray<T>,
args: ConnectionArguments,
): Connection<T>;
Expand All @@ -23,7 +23,7 @@ export function connectionFromArray<T>(
* A version of `connectionFromArray` that takes a promised array, and returns a
* promised connection.
*/
export function connectionFromPromisedArray<T>(
export declare function connectionFromPromisedArray<T>(
dataPromise: Promise<ReadonlyArray<T>>,
args: ConnectionArguments,
): Promise<Connection<T>>;
Expand All @@ -37,7 +37,7 @@ export function connectionFromPromisedArray<T>(
* to materialize the entire array, and instead wish pass in a slice of the
* total result large enough to cover the range specified in `args`.
*/
export function connectionFromArraySlice<T>(
export declare function connectionFromArraySlice<T>(
arraySlice: ReadonlyArray<T>,
args: ConnectionArguments,
meta: ArraySliceMetaInfo,
Expand All @@ -47,7 +47,7 @@ export function connectionFromArraySlice<T>(
* A version of `connectionFromArraySlice` that takes a promised array slice,
* and returns a promised connection.
*/
export function connectionFromPromisedArraySlice<T>(
export declare function connectionFromPromisedArraySlice<T>(
dataPromise: Promise<ReadonlyArray<T>>,
args: ConnectionArguments,
arrayInfo: ArraySliceMetaInfo,
Expand All @@ -56,17 +56,17 @@ export function connectionFromPromisedArraySlice<T>(
/**
* Creates the cursor string from an offset.
*/
export function offsetToCursor(offset: number): ConnectionCursor;
export declare function offsetToCursor(offset: number): ConnectionCursor;

/**
* Extracts the offset from the cursor string.
*/
export function cursorToOffset(cursor: ConnectionCursor): number;
export declare function cursorToOffset(cursor: ConnectionCursor): number;

/**
* Return the cursor associated with an object in an array.
*/
export function cursorForObjectInConnection<T>(
export declare function cursorForObjectInConnection<T>(
data: ReadonlyArray<T>,
object: T,
): ConnectionCursor | null;
Expand All @@ -76,7 +76,7 @@ export function cursorForObjectInConnection<T>(
* to use; if the cursor contains a valid offset, that will be used,
* otherwise it will be the default.
*/
export function getOffsetWithDefault(
export declare function getOffsetWithDefault(
cursor: ConnectionCursor | null | undefined,
defaultOffset: number,
): number;
2 changes: 1 addition & 1 deletion src/connection/connection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface GraphQLConnectionDefinitions {
* Returns a GraphQLObjectType for a connection with the given name,
* and whose nodes are of the specified type.
*/
export function connectionDefinitions(
export declare function connectionDefinitions(
config: ConnectionConfig,
): GraphQLConnectionDefinitions;

Expand Down
2 changes: 1 addition & 1 deletion src/mutation/mutation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ interface MutationConfig {
* Returns a GraphQLFieldConfig for the mutation described by the
* provided MutationConfig.
*/
export function mutationWithClientMutationId(
export declare function mutationWithClientMutationId(
config: MutationConfig,
): GraphQLFieldConfig<any, any>;
8 changes: 4 additions & 4 deletions src/node/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface GraphQLNodeDefinitions<TContext> {
* handled with the `isTypeOf` method on object types, as with any GraphQL
* interface without a provided `resolveType` method.
*/
export function nodeDefinitions<TContext>(
export declare function nodeDefinitions<TContext>(
fetchById: (
id: string,
context: TContext,
Expand All @@ -39,21 +39,21 @@ interface ResolvedGlobalId {
* Takes a type name and an ID specific to that type name, and returns a
* "global ID" that is unique among all types.
*/
export function toGlobalId(type: string | number, id: string): string;
export declare function toGlobalId(type: string | number, id: string): string;

/**
* Takes the "global ID" created by toGlobalID, and returns the type name and ID
* used to create it.
*/
export function fromGlobalId(globalId: string): ResolvedGlobalId;
export declare function fromGlobalId(globalId: string): ResolvedGlobalId;

/**
* Creates the configuration for an id field on a node, using `toGlobalId` to
* construct the ID from the provided typename. The type-specific ID is fetched
* by calling idFetcher on the object, or if not provided, by accessing the `id`
* property on the object.
*/
export function globalIdField<TContext>(
export declare function globalIdField<TContext>(
typeName?: string,
idFetcher?: (
obj: any,
Expand Down
2 changes: 1 addition & 1 deletion src/node/plural.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ interface PluralIdentifyingRootFieldConfig {
description?: string;
}

export function pluralIdentifyingRootField(
export declare function pluralIdentifyingRootField(
config: PluralIdentifyingRootFieldConfig,
): GraphQLFieldConfig<any, any>;

0 comments on commit ffc7d38

Please sign in to comment.