Skip to content

Commit a34e553

Browse files
committed
GraphQLError: switch constructor overload order
The GraphQLError constructor has two overloads. The GraphQLErrorArgs one is recommended and the one with a bunch of position arguments is deprecated. When typechecking, TypeScript chooses the *first* matching overload (see eg microsoft/TypeScript#1860 (comment)). Passing just a message argument matches both overloads, so this currently displays as deprecated. This PR reverses the order so that passing just a message does not display as deprecated.
1 parent da57238 commit a34e553

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/error/GraphQLError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export class GraphQLError extends Error {
111111
*/
112112
readonly extensions: GraphQLErrorExtensions;
113113

114+
constructor(message: string, args?: GraphQLErrorArgs);
114115
/**
115116
* @deprecated Please use the `GraphQLErrorArgs` constructor overload instead.
116117
*/
@@ -123,7 +124,6 @@ export class GraphQLError extends Error {
123124
originalError?: Maybe<Error & { readonly extensions?: unknown }>,
124125
extensions?: Maybe<GraphQLErrorExtensions>,
125126
);
126-
constructor(message: string, args?: GraphQLErrorArgs);
127127
constructor(message: string, ...rawArgs: BackwardsCompatibleArgs) {
128128
const { nodes, source, positions, path, originalError, extensions } =
129129
toNormalizedArgs(rawArgs);

0 commit comments

Comments
 (0)