|
2 | 2 | // flowlint uninitialized-instance-property:off
|
3 | 3 |
|
4 | 4 | import { isObjectLike } from '../jsutils/isObjectLike';
|
| 5 | +import type { Maybe } from '../jsutils/Maybe'; |
5 | 6 |
|
6 | 7 | import type { ASTNode } from '../language/ast';
|
7 | 8 | import type { Source } from '../language/source';
|
@@ -35,53 +36,53 @@ export class GraphQLError extends Error {
|
35 | 36 | *
|
36 | 37 | * Enumerable, and appears in the result of JSON.stringify().
|
37 | 38 | */
|
38 |
| - +locations: $ReadOnlyArray<SourceLocation> | void; |
| 39 | + readonly locations?: ReadonlyArray<SourceLocation>; |
39 | 40 |
|
40 | 41 | /**
|
41 | 42 | * An array describing the JSON-path into the execution response which
|
42 | 43 | * corresponds to this error. Only included for errors during execution.
|
43 | 44 | *
|
44 | 45 | * Enumerable, and appears in the result of JSON.stringify().
|
45 | 46 | */
|
46 |
| - +path: $ReadOnlyArray<string | number> | void; |
| 47 | + readonly path?: ReadonlyArray<string | number>; |
47 | 48 |
|
48 | 49 | /**
|
49 | 50 | * An array of GraphQL AST Nodes corresponding to this error.
|
50 | 51 | */
|
51 |
| - +nodes: $ReadOnlyArray<ASTNode> | void; |
| 52 | + readonly nodes?: ReadonlyArray<ASTNode>; |
52 | 53 |
|
53 | 54 | /**
|
54 | 55 | * The source GraphQL document for the first location of this error.
|
55 | 56 | *
|
56 | 57 | * Note that if this Error represents more than one node, the source may not
|
57 | 58 | * represent nodes after the first node.
|
58 | 59 | */
|
59 |
| - +source: Source | void; |
| 60 | + readonly source?: Source; |
60 | 61 |
|
61 | 62 | /**
|
62 | 63 | * An array of character offsets within the source GraphQL document
|
63 | 64 | * which correspond to this error.
|
64 | 65 | */
|
65 |
| - +positions: $ReadOnlyArray<number> | void; |
| 66 | + readonly positions?: ReadonlyArray<number>; |
66 | 67 |
|
67 | 68 | /**
|
68 | 69 | * The original error thrown from a field resolver during execution.
|
69 | 70 | */
|
70 |
| - +originalError: ?Error; |
| 71 | + readonly originalError: Maybe<Error>; |
71 | 72 |
|
72 | 73 | /**
|
73 | 74 | * Extension fields to add to the formatted error.
|
74 | 75 | */
|
75 |
| - +extensions: { [key: string]: mixed, ... } | void; |
| 76 | + readonly extensions?: { [key: string]: unknown }; |
76 | 77 |
|
77 | 78 | constructor(
|
78 | 79 | message: string,
|
79 |
| - nodes?: $ReadOnlyArray<ASTNode> | ASTNode | void | null, |
80 |
| - source?: ?Source, |
81 |
| - positions?: ?$ReadOnlyArray<number>, |
82 |
| - path?: ?$ReadOnlyArray<string | number>, |
83 |
| - originalError?: ?(Error & { +extensions?: mixed, ... }), |
84 |
| - extensions?: ?{ [key: string]: mixed, ... }, |
| 80 | + nodes?: ReadonlyArray<ASTNode> | ASTNode | null, |
| 81 | + source?: Maybe<Source>, |
| 82 | + positions?: Maybe<ReadonlyArray<number>>, |
| 83 | + path?: Maybe<ReadonlyArray<string | number>>, |
| 84 | + originalError?: Maybe<Error & { readonly extensions?: unknown }>, |
| 85 | + extensions?: Maybe<{ [key: string]: unknown }>, |
85 | 86 | ) {
|
86 | 87 | super(message);
|
87 | 88 |
|
@@ -133,7 +134,7 @@ export class GraphQLError extends Error {
|
133 | 134 | }
|
134 | 135 | }
|
135 | 136 |
|
136 |
| - // $FlowFixMe[cannot-write] FIXME |
| 137 | + // @ts-expect-error FIXME |
137 | 138 | Object.defineProperties(this, {
|
138 | 139 | name: { value: 'GraphQLError' },
|
139 | 140 | message: {
|
@@ -212,7 +213,7 @@ export class GraphQLError extends Error {
|
212 | 213 | }
|
213 | 214 |
|
214 | 215 | // FIXME: workaround to not break chai comparisons, should be remove in v16
|
215 |
| - // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet |
| 216 | + // @ts-expect-error Flow doesn't support computed properties yet |
216 | 217 | get [Symbol.toStringTag](): string {
|
217 | 218 | return 'Object';
|
218 | 219 | }
|
|
0 commit comments