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

TS: use unknown (TS) for mixed (flow) #3003

Merged
merged 1 commit into from Mar 30, 2021
Merged
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: 2 additions & 2 deletions src/error/GraphQLError.d.ts
Expand Up @@ -18,7 +18,7 @@ export class GraphQLError extends Error {
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>,
extensions?: Maybe<{ [key: string]: unknown }>,
);

/**
Expand Down Expand Up @@ -77,7 +77,7 @@ export class GraphQLError extends Error {
/**
* Extension fields to add to the formatted error.
*/
readonly extensions: { [key: string]: any } | undefined;
readonly extensions: { [key: string]: unknown } | undefined;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/error/formatError.d.ts
Expand Up @@ -12,7 +12,7 @@ export function formatError(error: GraphQLError): GraphQLFormattedError;
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
*/
export interface GraphQLFormattedError<
TExtensions extends Record<string, any> = Record<string, any>
TExtensions extends Record<string, unknown> = Record<string, unknown>
> {
/**
* A short, human-readable summary of the problem that **SHOULD NOT** change
Expand Down
2 changes: 1 addition & 1 deletion src/error/locatedError.d.ts
Expand Up @@ -10,7 +10,7 @@ import { GraphQLError } from './GraphQLError';
* document responsible for the original Error.
*/
export function locatedError(
rawOriginalError: any,
rawOriginalError: unknown,
nodes: ASTNode | ReadonlyArray<ASTNode> | undefined,
path?: Maybe<ReadonlyArray<string | number>>,
): GraphQLError;
32 changes: 16 additions & 16 deletions src/execution/execute.d.ts
Expand Up @@ -51,10 +51,10 @@ import {
export interface ExecutionContext {
schema: GraphQLSchema;
fragments: { [key: string]: FragmentDefinitionNode };
rootValue: any;
contextValue: any;
rootValue: unknown;
contextValue: unknown;
operation: OperationDefinitionNode;
variableValues: { [key: string]: any };
variableValues: { [key: string]: unknown };
fieldResolver: GraphQLFieldResolver<any, any>;
typeResolver: GraphQLTypeResolver<any, any>;
errors: Array<GraphQLError>;
Expand Down Expand Up @@ -90,9 +90,9 @@ export interface FormattedExecutionResult<
export interface ExecutionArgs {
schema: GraphQLSchema;
document: DocumentNode;
rootValue?: any;
contextValue?: any;
variableValues?: Maybe<{ [key: string]: any }>;
rootValue?: unknown;
contextValue?: unknown;
variableValues?: Maybe<{ [key: string]: unknown }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
Expand Down Expand Up @@ -126,7 +126,7 @@ export function executeSync(args: ExecutionArgs): ExecutionResult;
export function assertValidExecutionArguments(
schema: GraphQLSchema,
document: DocumentNode,
rawVariableValues: Maybe<{ [key: string]: any }>,
rawVariableValues: Maybe<{ [key: string]: unknown }>,
): void;

/**
Expand All @@ -140,12 +140,12 @@ export function assertValidExecutionArguments(
export function buildExecutionContext(
schema: GraphQLSchema,
document: DocumentNode,
rootValue: any,
contextValue: any,
rawVariableValues: Maybe<{ [key: string]: any }>,
rootValue: unknown,
contextValue: unknown,
rawVariableValues: Maybe<{ [key: string]: unknown }>,
operationName: Maybe<string>,
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
fieldResolver: Maybe<GraphQLFieldResolver<unknown, unknown>>,
typeResolver?: Maybe<GraphQLTypeResolver<unknown, unknown>>,
): ReadonlyArray<GraphQLError> | ExecutionContext;

/**
Expand All @@ -171,7 +171,7 @@ export function collectFields(
*/
export function buildResolveInfo(
exeContext: ExecutionContext,
fieldDef: GraphQLField<any, any>,
fieldDef: GraphQLField<unknown, unknown>,
fieldNodes: ReadonlyArray<FieldNode>,
parentType: GraphQLObjectType,
path: Path,
Expand All @@ -187,15 +187,15 @@ export function buildResolveInfo(
* Otherwise, test each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
export const defaultTypeResolver: GraphQLTypeResolver<any, any>;
export const defaultTypeResolver: GraphQLTypeResolver<unknown, unknown>;

/**
* If a resolve function is not given, then a default resolve behavior is used
* which takes the property of the source object of the same name as the field
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context value.
*/
export const defaultFieldResolver: GraphQLFieldResolver<any, any>;
export const defaultFieldResolver: GraphQLFieldResolver<unknown, unknown>;

/**
* This method looks up the field on the given type definition.
Expand All @@ -212,4 +212,4 @@ export function getFieldDef(
schema: GraphQLSchema,
parentType: GraphQLObjectType,
fieldName: string,
): Maybe<GraphQLField<any, any>>;
): Maybe<GraphQLField<unknown, unknown>>;
14 changes: 7 additions & 7 deletions src/execution/values.d.ts
Expand Up @@ -13,7 +13,7 @@ import { GraphQLField } from '../type/definition';

type CoercedVariableValues =
| { errors: ReadonlyArray<GraphQLError>; coerced?: never }
| { errors?: never; coerced: { [key: string]: any } };
| { errors?: never; coerced: { [key: string]: unknown } };

/**
* Prepares an object map of variableValues of the correct type based on the
Expand All @@ -27,7 +27,7 @@ type CoercedVariableValues =
export function getVariableValues(
schema: GraphQLSchema,
varDefNodes: ReadonlyArray<VariableDefinitionNode>,
inputs: { [key: string]: any },
inputs: { [key: string]: unknown },
options?: { maxErrors?: number },
): CoercedVariableValues;

Expand All @@ -40,10 +40,10 @@ export function getVariableValues(
* Object prototype.
*/
export function getArgumentValues(
def: GraphQLField<any, any> | GraphQLDirective,
def: GraphQLField<unknown, unknown> | GraphQLDirective,
node: FieldNode | DirectiveNode,
variableValues?: Maybe<{ [key: string]: any }>,
): { [key: string]: any };
variableValues?: Maybe<{ [key: string]: unknown }>,
): { [key: string]: unknown };

/**
* Prepares an object map of argument values given a directive definition
Expand All @@ -61,5 +61,5 @@ export function getDirectiveValues(
node: {
readonly directives?: ReadonlyArray<DirectiveNode>;
},
variableValues?: Maybe<{ [key: string]: any }>,
): undefined | { [key: string]: any };
variableValues?: Maybe<{ [key: string]: unknown }>,
): undefined | { [key: string]: unknown };
6 changes: 3 additions & 3 deletions src/graphql.d.ts
Expand Up @@ -47,9 +47,9 @@ import { ExecutionResult } from './execution/execute';
export interface GraphQLArgs {
schema: GraphQLSchema;
source: string | Source;
rootValue?: any;
contextValue?: any;
variableValues?: Maybe<{ [key: string]: any }>;
rootValue?: unknown;
contextValue?: unknown;
variableValues?: Maybe<{ [key: string]: unknown }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
Expand Down
2 changes: 1 addition & 1 deletion src/language/ast.d.ts
Expand Up @@ -100,7 +100,7 @@ export class Token {
/**
* @internal
*/
export function isNode(maybeNode: any): maybeNode is ASTNode;
export function isNode(maybeNode: unknown): maybeNode is ASTNode;

/**
* The list of all possible AST node types.
Expand Down
2 changes: 1 addition & 1 deletion src/language/source.d.ts
Expand Up @@ -23,4 +23,4 @@ export class Source {
*
* @internal
*/
export function isSource(source: any): source is Source;
export function isSource(source: unknown): source is Source;
14 changes: 7 additions & 7 deletions src/subscription/subscribe.d.ts
Expand Up @@ -8,9 +8,9 @@ import { GraphQLFieldResolver } from '../type/definition';
export interface SubscriptionArgs {
schema: GraphQLSchema;
document: DocumentNode;
rootValue?: any;
contextValue?: any;
variableValues?: Maybe<Record<string, any>>;
rootValue?: unknown;
contextValue?: unknown;
variableValues?: Maybe<Record<string, unknown>>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
Expand Down Expand Up @@ -72,9 +72,9 @@ export function subscribe(
export function createSourceEventStream(
schema: GraphQLSchema,
document: DocumentNode,
rootValue?: any,
contextValue?: any,
variableValues?: { [key: string]: any },
rootValue?: unknown,
contextValue?: unknown,
variableValues?: { [key: string]: unknown },
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
): Promise<AsyncIterable<any> | ExecutionResult>;
): Promise<AsyncIterable<unknown> | ExecutionResult>;