Skip to content

Commit c18ce9a

Browse files
saihajIvanGoncharov
authored andcommitted
Fix TSC errors
1 parent fb9d028 commit c18ce9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+199
-98
lines changed

src/error/GraphQLError.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ export class GraphQLError extends Error {
9898
_source = _nodes[0].loc?.source;
9999
}
100100

101-
let _positions = positions;
102-
if (!_positions && _nodes) {
101+
let _positions;
102+
if (positions) {
103+
_positions = positions;
104+
} else if (_nodes) {
103105
_positions = [];
104106
for (const node of _nodes) {
105107
if (node.loc) {
@@ -131,7 +133,6 @@ export class GraphQLError extends Error {
131133
}
132134
}
133135

134-
// @ts-expect-error FIXME
135136
Object.defineProperties(this, {
136137
name: { value: 'GraphQLError' },
137138
message: {
@@ -210,7 +211,6 @@ export class GraphQLError extends Error {
210211
}
211212

212213
// FIXME: workaround to not break chai comparisons, should be remove in v16
213-
// @ts-expect-error Flow doesn't support computed properties yet
214214
get [Symbol.toStringTag](): string {
215215
return 'Object';
216216
}

src/error/__tests__/formatError-test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ describe('formatError: default error formatter', () => {
4545
});
4646

4747
it('rejects null and undefined errors', () => {
48-
// @ts-expect-error
4948
expect(() => formatError(undefined)).to.throw(
5049
'Received null or undefined error.',
5150
);
5251

53-
// @ts-expect-error
5452
expect(() => formatError(null)).to.throw(
5553
'Received null or undefined error.',
5654
);

src/error/locatedError.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function locatedError(
2222
: new Error('Unexpected error value: ' + inspect(rawOriginalError));
2323

2424
// Note: this uses a brand-check to support GraphQL errors originating from other contexts.
25+
// @ts-expect-error FIXME: TS Conversion
2526
if (Array.isArray(originalError.path)) {
2627
// @ts-expect-error
2728
return originalError;

src/execution/execute.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
191191
// field and its descendants will be omitted, and sibling fields will still
192192
// be executed. An execution which encounters errors will still result in a
193193
// resolved Promise.
194+
// @ts-expect-error FIXME: TS Conversion
194195
const data = executeOperation(exeContext, exeContext.operation, rootValue);
196+
// @ts-expect-error FIXME: TS Conversion
195197
return buildResponse(exeContext, data);
196198
}
197199

@@ -313,7 +315,6 @@ export function buildExecutionContext(
313315
return coercedVariableValues.errors;
314316
}
315317

316-
// @ts-expect-error
317318
return {
318319
schema,
319320
fragments,
@@ -1078,7 +1079,7 @@ function _collectSubfields(
10781079
fieldNodes: ReadonlyArray<FieldNode>,
10791080
): Map<string, Array<FieldNode>> {
10801081
let subFieldNodes = new Map();
1081-
const visitedFragmentNames = new Set();
1082+
const visitedFragmentNames = new Set<string>();
10821083
for (const node of fieldNodes) {
10831084
if (node.selectionSet) {
10841085
subFieldNodes = collectFields(

src/jsutils/__tests__/identityFunc-test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { identityFunc } from '../identityFunc';
55

66
describe('identityFunc', () => {
77
it('returns the first argument it receives', () => {
8+
// @ts-expect-error
89
expect(identityFunc()).to.equal(undefined);
910
expect(identityFunc(undefined)).to.equal(undefined);
1011
expect(identityFunc(null)).to.equal(null);

src/jsutils/__tests__/inspect-test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('inspect', () => {
124124
});
125125

126126
it('detect circular objects', () => {
127-
const obj = {};
127+
const obj: { [name: string]: unknown } = {};
128128
obj.self = obj;
129129
obj.deepSelf = { self: obj };
130130

@@ -165,7 +165,6 @@ describe('inspect', () => {
165165

166166
expect(inspect([[new Foo()]])).to.equal('[[[Foo]]]');
167167

168-
// @ts-expect-error
169168
Foo.prototype[Symbol.toStringTag] = 'Bar';
170169
expect(inspect([[new Foo()]])).to.equal('[[[Bar]]]');
171170

src/jsutils/__tests__/isIterableObject-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('isIterableObject', () => {
6060
};
6161
expect(isIterableObject(invalidIterable)).to.equal(false);
6262

63-
const arrayLike = {};
63+
const arrayLike: { [key: string]: unknown } = {};
6464
arrayLike[0] = 'Alpha';
6565
arrayLike[1] = 'Bravo';
6666
arrayLike[2] = 'Charlie';

src/jsutils/inspect.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ function formatObjectValue(
3535

3636
const seenValues = [...previouslySeenValues, value];
3737

38+
// @ts-expect-error FIXME: TS Conversion
3839
if (typeof value.toJSON === 'function') {
40+
// @ts-expect-error FIXME: TS Conversion
3941
const jsonValue = (value.toJSON as () => unknown)();
4042

4143
// check for infinite recursion

src/jsutils/isPromise.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
* otherwise returns false.
44
*/
55
export function isPromise(value: unknown): value is Promise<unknown> {
6-
return typeof value?.then === 'function';
6+
// eslint-disable-next-line @typescript-eslint/dot-notation
7+
return typeof value?.['then'] === 'function';
78
}

src/language/__tests__/printer-test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { print } from '../printer';
99

1010
describe('Printer: Query document', () => {
1111
it('prints minimal ast', () => {
12-
const ast = { kind: 'Field', name: { kind: 'Name', value: 'foo' } };
12+
const ast = {
13+
kind: 'Field',
14+
name: { kind: 'Name', value: 'foo' },
15+
} as const;
1316
expect(print(ast)).to.equal('foo');
1417
});
1518

src/language/__tests__/schema-printer-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Printer: SDL document', () => {
1212
const ast = {
1313
kind: 'ScalarTypeDefinition',
1414
name: { kind: 'Name', value: 'foo' },
15-
};
15+
} as const;
1616
expect(print(ast)).to.equal('scalar foo');
1717
});
1818

src/language/__tests__/toJSONDeep.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export function toJSONDeep(value: unknown): unknown {
1111
}
1212

1313
if (typeof value.toJSON === 'function') {
14-
// @ts-expect-error
1514
return value.toJSON();
1615
}
1716

src/language/__tests__/visitor-test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { describe, it } from 'mocha';
44
import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery';
55

66
import type { ASTNode } from '../ast';
7+
import { isNode } from '../ast';
78
import { Kind } from '../kinds';
89
import { parse } from '../parser';
910
import { visit, visitInParallel, BREAK } from '../visitor';
@@ -50,6 +51,7 @@ function checkVisitorFnArgs(ast: any, args: any, isEdited: boolean = false) {
5051
}
5152

5253
function getValue(node: ASTNode) {
54+
// @ts-expect-error FIXME
5355
return node.value != null ? node.value : undefined;
5456
}
5557

@@ -263,6 +265,7 @@ describe('Visitor', () => {
263265
if (node.kind === 'Field' && node.name.value === 'a') {
264266
return {
265267
kind: 'Field',
268+
// @ts-expect-error FIXME
266269
selectionSet: [addedField].concat(node.selectionSet),
267270
};
268271
}
@@ -522,7 +525,7 @@ describe('Visitor', () => {
522525
'enter',
523526
node.kind,
524527
key,
525-
parent?.kind != null ? parent.kind : undefined,
528+
isNode(parent) ? parent.kind : undefined,
526529
]);
527530

528531
checkVisitorFnArgs(ast, arguments);
@@ -534,7 +537,7 @@ describe('Visitor', () => {
534537
'leave',
535538
node.kind,
536539
key,
537-
parent?.kind != null ? parent.kind : undefined,
540+
isNode(parent) ? parent.kind : undefined,
538541
]);
539542

540543
expect(argsStack.pop()).to.deep.equal([...arguments]);

src/language/ast.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ export class Token {
125125
* @internal
126126
*/
127127
export function isNode(maybeNode: unknown): maybeNode is ASTNode {
128-
return maybeNode != null && typeof maybeNode.kind === 'string';
128+
// eslint-disable-next-line @typescript-eslint/dot-notation
129+
return typeof maybeNode?.['kind'] === 'string';
129130
}
130131

131132
/**

0 commit comments

Comments
 (0)