Skip to content

Commit bef5534

Browse files
Fix: make public API compatible with 'exactOptionalPropertyTypes' (#3670)
1 parent ffe37cb commit bef5534

17 files changed

+178
-150
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { GraphQLScalarType } from 'graphql/type';
2+
import { GraphQLError } from 'graphql/error';
3+
import type { NameNode } from 'graphql/language';
4+
import { Kind } from 'graphql/language';
5+
6+
// Test subset of public APIs with "exactOptionalPropertyTypes" flag enabled
7+
new GraphQLScalarType({
8+
name: 'SomeScalar',
9+
serialize: undefined,
10+
parseValue: undefined,
11+
parseLiteral: undefined,
12+
});
13+
14+
new GraphQLError('test', { nodes: undefined });
15+
16+
const nameNode: NameNode = { kind: Kind.NAME, loc: undefined, value: 'test' };

integrationTests/ts/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"compilerOptions": {
33
"module": "commonjs",
44
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
5-
"strict": true,
65
"noEmit": true,
7-
"types": []
6+
"types": [],
7+
"strict": true,
8+
"exactOptionalPropertyTypes": true
89
}
910
}

src/error/GraphQLError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface GraphQLErrorExtensions {
2121
}
2222

2323
export interface GraphQLErrorOptions {
24-
nodes?: ReadonlyArray<ASTNode> | ASTNode | null;
24+
nodes?: ReadonlyArray<ASTNode> | ASTNode | null | undefined;
2525
source?: Maybe<Source>;
2626
positions?: Maybe<ReadonlyArray<number>>;
2727
path?: Maybe<ReadonlyArray<string | number>>;

src/execution/__tests__/union-interface-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class Cat {
4444

4545
class Person {
4646
name: string;
47-
pets?: ReadonlyArray<Dog | Cat>;
48-
friends?: ReadonlyArray<Dog | Cat | Person>;
47+
pets: ReadonlyArray<Dog | Cat> | undefined;
48+
friends: ReadonlyArray<Dog | Cat | Person> | undefined;
4949

5050
constructor(
5151
name: string,

src/execution/values.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export function getArgumentValues(
238238
*/
239239
export function getDirectiveValues(
240240
directiveDef: GraphQLDirective,
241-
node: { readonly directives?: ReadonlyArray<DirectiveNode> },
241+
node: { readonly directives?: ReadonlyArray<DirectiveNode> | undefined },
242242
variableValues?: Maybe<ObjMap<unknown>>,
243243
): undefined | { [argument: string]: unknown } {
244244
const directiveNode = node.directives?.find(

0 commit comments

Comments
 (0)