Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit a149f83

Browse files
authored
style: format code (#453)
1 parent c89811c commit a149f83

File tree

4 files changed

+41
-41
lines changed

4 files changed

+41
-41
lines changed

src/FindGraphQLTags.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ function visit(node: ts.Node, addGraphQLTag: (tag: GraphQLTag) => void): void {
7979
// We tested for this
8080
const propAssignment = prop as ts.PropertyAssignment;
8181

82-
const taggedTemplate = propAssignment.initializer as ts.TaggedTemplateExpression;
82+
const taggedTemplate =
83+
propAssignment.initializer as ts.TaggedTemplateExpression;
8384
invariant(
8485
isGraphQLTag(taggedTemplate.tag),
8586
"FindGraphQLTags: `%s` expects fragment definitions to be tagged " +

src/TypeScriptGenerator.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ function createVisitor(
447447
selectionsToAST(
448448
schema,
449449
/* $FlowFixMe: selections have already been transformed */
450-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>,
450+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>,
451451
state,
452452
false
453453
)
@@ -521,7 +521,7 @@ function createVisitor(
521521
Fragment(node) {
522522
const flattenedSelections: Selection[] = flattenArray(
523523
/* $FlowFixMe: selections have already been transformed */
524-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
524+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
525525
);
526526
const numConcreteSelections = flattenedSelections.filter(
527527
(s) => s.concreteType
@@ -605,7 +605,7 @@ function createVisitor(
605605
InlineFragment(node) {
606606
return flattenArray(
607607
/* $FlowFixMe: selections have already been transformed */
608-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
608+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
609609
).map((typeSelection) => {
610610
return schema.isAbstractType(node.typeCondition)
611611
? {
@@ -621,7 +621,7 @@ function createVisitor(
621621
Condition(node: Condition) {
622622
return flattenArray(
623623
/* $FlowFixMe: selections have already been transformed */
624-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
624+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
625625
).map((selection) => {
626626
return {
627627
...selection,
@@ -692,7 +692,7 @@ function visitLinkedField(node: LinkedField) {
692692
nodeSelections: selectionsToMap(
693693
flattenArray(
694694
/* $FlowFixMe: selections have already been transformed */
695-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
695+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
696696
),
697697
/*
698698
* append concreteType to key so overlapping fields with different
@@ -879,7 +879,7 @@ function createRawResponseTypeVisitor(
879879
selectionsToRawResponseBabel(
880880
schema,
881881
/* $FlowFixMe: selections have already been transformed */
882-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>,
882+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>,
883883
state,
884884
null
885885
)
@@ -890,7 +890,7 @@ function createRawResponseTypeVisitor(
890890

891891
return flattenArray(
892892
/* $FlowFixMe: selections have already been transformed */
893-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
893+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
894894
).map((typeSelection) => {
895895
return schema.isAbstractType(typeCondition)
896896
? typeSelection
@@ -906,7 +906,7 @@ function createRawResponseTypeVisitor(
906906
ClientExtension(node) {
907907
return flattenArray(
908908
/* $FlowFixMe: selections have already been transformed */
909-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
909+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
910910
).map((sel) => ({
911911
...sel,
912912
conditional: true,
@@ -916,19 +916,19 @@ function createRawResponseTypeVisitor(
916916
Condition(node) {
917917
return flattenArray(
918918
/* $FlowFixMe: selections have already been transformed */
919-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
919+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
920920
);
921921
},
922922
Defer(node) {
923923
return flattenArray(
924924
/* $FlowFixMe: selections have already been transformed */
925-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
925+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
926926
);
927927
},
928928
Stream(node) {
929929
return flattenArray(
930930
/* $FlowFixMe: selections have already been transformed */
931-
(node.selections as any) as ReadonlyArray<ReadonlyArray<Selection>>
931+
node.selections as any as ReadonlyArray<ReadonlyArray<Selection>>
932932
);
933933
},
934934
ModuleImport(node) {

src/TypeScriptTypeTransformers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ function transformNonNullableInputType(
174174

175175
return property;
176176
});
177-
state.generatedInputObjectTypes[
178-
typeIdentifier
179-
] = ts.factory.createTypeLiteralNode(props);
177+
state.generatedInputObjectTypes[typeIdentifier] =
178+
ts.factory.createTypeLiteralNode(props);
180179
return ts.factory.createTypeReferenceNode(
181180
ts.factory.createIdentifier(typeIdentifier),
182181
[]

src/formatGeneratedModule.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,44 +59,44 @@ function formatContent(
5959
return requireToImport(rawContent);
6060
}
6161

62-
export const formatterFactory = (
63-
compilerOptions: ts.CompilerOptions = {}
64-
): FormatModule => ({
65-
moduleName,
66-
documentType,
67-
docText,
68-
concreteText,
69-
typeText,
70-
hash,
71-
sourceHash,
72-
}) => {
73-
const { noImplicitAny, module = -1 } = compilerOptions;
62+
export const formatterFactory =
63+
(compilerOptions: ts.CompilerOptions = {}): FormatModule =>
64+
({
65+
moduleName,
66+
documentType,
67+
docText,
68+
concreteText,
69+
typeText,
70+
hash,
71+
sourceHash,
72+
}) => {
73+
const { noImplicitAny, module = -1 } = compilerOptions;
7474

75-
const documentTypeImport = documentType
76-
? `import { ${documentType} } from "relay-runtime";`
77-
: "";
78-
const docTextComment = docText ? "\n/*\n" + docText.trim() + "\n*/\n" : "";
79-
let nodeStatement = `const node: ${
80-
documentType || "never"
81-
} = ${concreteText};`;
82-
if (noImplicitAny) {
83-
nodeStatement = addAnyTypeCast(nodeStatement).trim();
84-
}
85-
const rawContent = `${typeText || ""}
75+
const documentTypeImport = documentType
76+
? `import { ${documentType} } from "relay-runtime";`
77+
: "";
78+
const docTextComment = docText ? "\n/*\n" + docText.trim() + "\n*/\n" : "";
79+
let nodeStatement = `const node: ${
80+
documentType || "never"
81+
} = ${concreteText};`;
82+
if (noImplicitAny) {
83+
nodeStatement = addAnyTypeCast(nodeStatement).trim();
84+
}
85+
const rawContent = `${typeText || ""}
8686
8787
${docTextComment}
8888
${nodeStatement}
8989
(node as any).hash = '${sourceHash}';
9090
export default node;
9191
`;
9292

93-
const content = `/* tslint:disable */
93+
const content = `/* tslint:disable */
9494
/* eslint-disable */
9595
// @ts-nocheck
9696
${hash ? `/* ${hash} */\n` : ""}
9797
${documentTypeImport}
9898
${formatContent(rawContent, {
9999
replaceRequire: module >= ts.ModuleKind.ES2015,
100100
})}`;
101-
return content;
102-
};
101+
return content;
102+
};

0 commit comments

Comments
 (0)