Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added .d.ts files for test utils #2616

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/__fixtures__/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare const bigSchemaSDL: string;
export declare const bigSchemaIntrospectionResult: { data: unknown };
export declare const kitchenSinkSDL: string;
export declare const kitchenSinkQuery: string;
2 changes: 1 addition & 1 deletion src/error/GraphQLError.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SourceLocation } from '../language/location';
export class GraphQLError extends Error {
constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode,
nodes?: Maybe<ReadonlyArray<ASTNode> | ASTNode>,
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
Expand Down
15 changes: 15 additions & 0 deletions src/jsutils/ObjMap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface ObjMap<T> {
[key: string]: T;
__proto__: never;
}

export type ObjMapLike<T> = ObjMap<T> | { [key: string]: T };

export interface ReadOnlyObjMap<T> {
readonly [key: string]: T;
__proto__: never;
}

export type ReadOnlyObjMapLike<T> =
| ReadOnlyObjMap<T>
| { readonly [key: string]: T };
10 changes: 10 additions & 0 deletions src/jsutils/didYouMean.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
*/
declare function didYouMean(suggestions: ReadonlyArray<string>): string;
declare function didYouMean(
subMessage: string,
suggestions: ReadonlyArray<string>,
): string;
dotansimha marked this conversation as resolved.
Show resolved Hide resolved

export default didYouMean;
4 changes: 4 additions & 0 deletions src/jsutils/identityFunc.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Returns the first argument it receives.
*/
export default function identityFunc<T>(x?: T): T;
4 changes: 4 additions & 0 deletions src/jsutils/inspect.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Used to print values in error messages.
*/
export default function inspect(value: any): string;
5 changes: 5 additions & 0 deletions src/jsutils/instanceOf.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* A replacement for instanceof which includes an error warning when multi-realm
* constructors are detected.
*/
export default function instanceOf(value: any, constructor: any): boolean;
1 change: 1 addition & 0 deletions src/jsutils/invariant.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function invariant(condition: any, message?: string): void;
22 changes: 22 additions & 0 deletions src/jsutils/isCollection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Returns true if the provided object is an Object (i.e. not a string literal)
* and is either Iterable or Array-like.
*
* This may be used in place of [Array.isArray()][isArray] to determine if an
* object should be iterated-over. It always excludes string literals and
* includes Arrays (regardless of if it is Iterable). It also includes other
* Array-like objects such as NodeList, TypedArray, and Buffer.
*
* @example
*
* isCollection([ 1, 2, 3 ]) // true
* isCollection('ABC') // false
* isCollection({ length: 1, 0: 'Alpha' }) // true
* isCollection({ key: 'value' }) // false
* isCollection(new Map()) // true
*
* @param obj
* An Object value which might implement the Iterable or Array-like protocols.
* @return true if Iterable or Array-like Object.
*/
export default function isCollection(obj: any): boolean;
5 changes: 5 additions & 0 deletions src/jsutils/isObjectLike.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Return true if `value` is object-like. A value is object-like if it's not
* `null` and has a `typeof` result of "object".
*/
export default function isObjectLike(value: any): boolean;
3 changes: 3 additions & 0 deletions src/jsutils/nodejsCustomInspectSymbol.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare const nodejsCustomInspectSymbol: symbol | undefined;

export default nodejsCustomInspectSymbol;
8 changes: 8 additions & 0 deletions src/jsutils/suggestionList.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Given an invalid input string and a list of valid options, returns a filtered
* list of valid options sorted based on their similarity with the input.
*/
export default function suggestionList(
input: string,
options: ReadonlyArray<string>,
): Array<string>;
11 changes: 11 additions & 0 deletions src/jsutils/toObjMap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {
ObjMap,
ObjMapLike,
ReadOnlyObjMap,
ReadOnlyObjMapLike,
} from './ObjMap';

declare function toObjMap<T>(obj: ObjMapLike<T>): ObjMap<T>;
declare function toObjMap<T>(obj: ReadOnlyObjMapLike<T>): ReadOnlyObjMap<T>;

export default toObjMap;