Skip to content

Commit

Permalink
babel: Stop transpiling optional chaining operator (#3078)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 12, 2021
1 parent 98dcac3 commit 740de80
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
7 changes: 6 additions & 1 deletion .babelrc.json
@@ -1,4 +1,9 @@
{
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
"presets": [
[
"@babel/preset-env",
{ "bugfixes": true, "targets": { "node": "current" } }
]
]
}
19 changes: 3 additions & 16 deletions src/type/validate.js
Expand Up @@ -183,11 +183,7 @@ function validateDirectives(context: SchemaValidationContext): void {
if (isRequiredArgument(arg) && arg.deprecationReason != null) {
context.reportError(
`Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`,
[
getDeprecatedDirectiveNode(arg.astNode),
// istanbul ignore next (TODO need to write coverage tests)
arg.astNode?.type,
],
[getDeprecatedDirectiveNode(arg.astNode), arg.astNode?.type],
);
}
}
Expand Down Expand Up @@ -299,11 +295,7 @@ function validateFields(
if (isRequiredArgument(arg) && arg.deprecationReason != null) {
context.reportError(
`Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`,
[
getDeprecatedDirectiveNode(arg.astNode),
// istanbul ignore next (TODO need to write coverage tests)
arg.astNode?.type,
],
[getDeprecatedDirectiveNode(arg.astNode), arg.astNode?.type],
);
}
}
Expand Down Expand Up @@ -376,12 +368,7 @@ function validateTypeImplementsInterface(
`Interface field ${iface.name}.${fieldName} expects type ` +
`${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` +
`is type ${inspect(typeField.type)}.`,
[
// istanbul ignore next (TODO need to write coverage tests)
ifaceField.astNode?.type,
// istanbul ignore next (TODO need to write coverage tests)
typeField.astNode?.type,
],
[ifaceField.astNode?.type, typeField.astNode?.type],
);
}

Expand Down
1 change: 0 additions & 1 deletion src/utilities/__tests__/buildASTSchema-test.js
Expand Up @@ -51,7 +51,6 @@ function cycleSDL(sdl: string): string {
}

function expectASTNode(obj: ?{ +astNode: ?ASTNode, ... }) {
// istanbul ignore next (FIXME)
invariant(obj?.astNode != null);
return expect(print(obj.astNode));
}
Expand Down
1 change: 0 additions & 1 deletion src/utilities/__tests__/extendSchema-test.js
Expand Up @@ -43,7 +43,6 @@ function expectExtensionASTNodes(obj: {
}

function expectASTNode(obj: ?{ +astNode: ?ASTNode, ... }) {
// istanbul ignore next (FIXME)
invariant(obj?.astNode != null);
return expect(print(obj.astNode));
}
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/__tests__/getOperationRootType-test.js
Expand Up @@ -36,7 +36,7 @@ const subscriptionType = new GraphQLObjectType({

function getOperationNode(doc: DocumentNode) {
const operationNode = doc.definitions[0];
invariant(operationNode && operationNode.kind === Kind.OPERATION_DEFINITION);
invariant(operationNode.kind === Kind.OPERATION_DEFINITION);
return operationNode;
}

Expand Down Expand Up @@ -76,7 +76,7 @@ describe('getOperationRootType', () => {
`);

const schemaNode = doc.definitions[0];
invariant(schemaNode && schemaNode.kind === Kind.SCHEMA_DEFINITION);
invariant(schemaNode.kind === Kind.SCHEMA_DEFINITION);
const [
queryNode,
mutationNode,
Expand Down

0 comments on commit 740de80

Please sign in to comment.