Skip to content

Commit 740de80

Browse files
babel: Stop transpiling optional chaining operator (#3078)
1 parent 98dcac3 commit 740de80

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

.babelrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
22
"plugins": ["@babel/plugin-transform-flow-strip-types"],
3-
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
3+
"presets": [
4+
[
5+
"@babel/preset-env",
6+
{ "bugfixes": true, "targets": { "node": "current" } }
7+
]
8+
]
49
}

src/type/validate.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ function validateDirectives(context: SchemaValidationContext): void {
183183
if (isRequiredArgument(arg) && arg.deprecationReason != null) {
184184
context.reportError(
185185
`Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`,
186-
[
187-
getDeprecatedDirectiveNode(arg.astNode),
188-
// istanbul ignore next (TODO need to write coverage tests)
189-
arg.astNode?.type,
190-
],
186+
[getDeprecatedDirectiveNode(arg.astNode), arg.astNode?.type],
191187
);
192188
}
193189
}
@@ -299,11 +295,7 @@ function validateFields(
299295
if (isRequiredArgument(arg) && arg.deprecationReason != null) {
300296
context.reportError(
301297
`Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`,
302-
[
303-
getDeprecatedDirectiveNode(arg.astNode),
304-
// istanbul ignore next (TODO need to write coverage tests)
305-
arg.astNode?.type,
306-
],
298+
[getDeprecatedDirectiveNode(arg.astNode), arg.astNode?.type],
307299
);
308300
}
309301
}
@@ -376,12 +368,7 @@ function validateTypeImplementsInterface(
376368
`Interface field ${iface.name}.${fieldName} expects type ` +
377369
`${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` +
378370
`is type ${inspect(typeField.type)}.`,
379-
[
380-
// istanbul ignore next (TODO need to write coverage tests)
381-
ifaceField.astNode?.type,
382-
// istanbul ignore next (TODO need to write coverage tests)
383-
typeField.astNode?.type,
384-
],
371+
[ifaceField.astNode?.type, typeField.astNode?.type],
385372
);
386373
}
387374

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function cycleSDL(sdl: string): string {
5151
}
5252

5353
function expectASTNode(obj: ?{ +astNode: ?ASTNode, ... }) {
54-
// istanbul ignore next (FIXME)
5554
invariant(obj?.astNode != null);
5655
return expect(print(obj.astNode));
5756
}

src/utilities/__tests__/extendSchema-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function expectExtensionASTNodes(obj: {
4343
}
4444

4545
function expectASTNode(obj: ?{ +astNode: ?ASTNode, ... }) {
46-
// istanbul ignore next (FIXME)
4746
invariant(obj?.astNode != null);
4847
return expect(print(obj.astNode));
4948
}

src/utilities/__tests__/getOperationRootType-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const subscriptionType = new GraphQLObjectType({
3636

3737
function getOperationNode(doc: DocumentNode) {
3838
const operationNode = doc.definitions[0];
39-
invariant(operationNode && operationNode.kind === Kind.OPERATION_DEFINITION);
39+
invariant(operationNode.kind === Kind.OPERATION_DEFINITION);
4040
return operationNode;
4141
}
4242

@@ -76,7 +76,7 @@ describe('getOperationRootType', () => {
7676
`);
7777

7878
const schemaNode = doc.definitions[0];
79-
invariant(schemaNode && schemaNode.kind === Kind.SCHEMA_DEFINITION);
79+
invariant(schemaNode.kind === Kind.SCHEMA_DEFINITION);
8080
const [
8181
queryNode,
8282
mutationNode,

0 commit comments

Comments
 (0)