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

Fix: make public API compatible with 'exactOptionalPropertyTypes' #3670

Merged
merged 1 commit into from
Jul 21, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions integrationTests/ts/kitchenSink-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GraphQLScalarType } from 'graphql/type';
import { GraphQLError } from 'graphql/error';
import type { NameNode } from 'graphql/language';
import { Kind } from 'graphql/language';

// Test subset of public APIs with "exactOptionalPropertyTypes" flag enabled
new GraphQLScalarType({
name: 'SomeScalar',
serialize: undefined,
parseValue: undefined,
parseLiteral: undefined,
});

new GraphQLError('test', { nodes: undefined });

const nameNode: NameNode = { kind: Kind.NAME, loc: undefined, value: 'test' };
5 changes: 3 additions & 2 deletions integrationTests/ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"compilerOptions": {
"module": "commonjs",
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
"strict": true,
"noEmit": true,
"types": []
"types": [],
"strict": true,
"exactOptionalPropertyTypes": true
}
}
2 changes: 1 addition & 1 deletion src/error/GraphQLError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface GraphQLErrorExtensions {
}

export interface GraphQLErrorOptions {
nodes?: ReadonlyArray<ASTNode> | ASTNode | null;
nodes?: ReadonlyArray<ASTNode> | ASTNode | null | undefined;
source?: Maybe<Source>;
positions?: Maybe<ReadonlyArray<number>>;
path?: Maybe<ReadonlyArray<string | number>>;
Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/union-interface-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class Cat {

class Person {
name: string;
pets?: ReadonlyArray<Dog | Cat>;
friends?: ReadonlyArray<Dog | Cat | Person>;
pets: ReadonlyArray<Dog | Cat> | undefined;
friends: ReadonlyArray<Dog | Cat | Person> | undefined;

constructor(
name: string,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export function getArgumentValues(
*/
export function getDirectiveValues(
directiveDef: GraphQLDirective,
node: { readonly directives?: ReadonlyArray<DirectiveNode> },
node: { readonly directives?: ReadonlyArray<DirectiveNode> | undefined },
variableValues?: Maybe<ObjMap<unknown>>,
): undefined | { [argument: string]: unknown } {
const directiveNode = node.directives?.find(
Expand Down
Loading