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

Commit 831872d

Browse files
authored
Merge pull request #13 from kastermester/issue-11
Fixes issue #11
2 parents bf75388 + 7606762 commit 831872d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/TypeScriptGenerator.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function selectionsToAST(
148148
otherProp,
149149
ts.SyntaxKind.MultiLineCommentTrivia,
150150
"This will never be '% other', but we need some\n" +
151-
"value in case none of the concrete values match.",
151+
"value in case none of the concrete values match.",
152152
true
153153
);
154154
types.push([otherPropWithComment]);
@@ -338,8 +338,8 @@ function createVisitor(options: TypeGeneratorOptions) {
338338
const baseType = selectionsToAST(selections, state, refTypeName);
339339
const type = isPlural(node)
340340
? ts.createTypeReferenceNode(ts.createIdentifier("ReadonlyArray"), [
341-
baseType
342-
])
341+
baseType
342+
])
343343
: baseType;
344344
return [
345345
...getFragmentImports(state),
@@ -355,13 +355,13 @@ function createVisitor(options: TypeGeneratorOptions) {
355355
return flattenArray(node.selections).map(typeSelection => {
356356
return isAbstractType(typeCondition)
357357
? {
358-
...typeSelection,
359-
conditional: true
360-
}
358+
...typeSelection,
359+
conditional: true
360+
}
361361
: {
362-
...typeSelection,
363-
concreteType: typeCondition.toString()
364-
};
362+
...typeSelection,
363+
concreteType: typeCondition.toString()
364+
};
365365
});
366366
},
367367
Condition(node: any) {
@@ -525,7 +525,7 @@ function getEnumDefinitions({ enumsHasteModule, usedEnums }: State) {
525525
}
526526

527527
function stringLiteralTypeAnnotation(name: string): ts.TypeNode {
528-
return ts.createTypeReferenceNode(name, undefined);
528+
return ts.createLiteralTypeNode(ts.createLiteral(name));
529529
}
530530

531531
function getRefTypeName(name: string): string {

test/__snapshots__/TypeScriptGenerator-test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ fragment ScalarField on User {
473473
}
474474
475475
~~~~~~~~~~ OUTPUT ~~~~~~~~~~
476-
export type PersonalityTraits = CHEERFUL | DERISIVE | HELPFUL | SNARKY | %future added value;
476+
export type PersonalityTraits = "CHEERFUL" | "DERISIVE" | "HELPFUL" | "SNARKY" | "%future added value";
477477
import { FragmentReference } from "relay-runtime";
478478
export enum ScalarField_ref {
479479
}

0 commit comments

Comments
 (0)