diff --git a/compiler/crates/relay-typegen/src/typescript.rs b/compiler/crates/relay-typegen/src/typescript.rs index 03c69e279df1f..478d1cd6afb47 100644 --- a/compiler/crates/relay-typegen/src/typescript.rs +++ b/compiler/crates/relay-typegen/src/typescript.rs @@ -278,11 +278,12 @@ impl TypeScriptPrinter { } Prop::GetterSetterPair(getter_setter_pair) => { // Write the getter + self.write_indentation()?; write!(&mut self.result, "get ")?; self.write(&AST::Identifier(getter_setter_pair.key))?; write!(&mut self.result, "(): ")?; self.write(&getter_setter_pair.getter_return_value)?; - writeln!(&mut self.result, ",")?; + writeln!(&mut self.result, ";")?; // Write the setter self.write_indentation()?; @@ -290,7 +291,7 @@ impl TypeScriptPrinter { self.write(&AST::Identifier(getter_setter_pair.key))?; write!(&mut self.result, "(value: ")?; self.write(&getter_setter_pair.setter_parameter)?; - writeln!(&mut self.result, "): void,")?; + writeln!(&mut self.result, ");")?; } } } diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment-plural.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment-plural.expected index d64c6f58ad964..0c32fcd40b0c5 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment-plural.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment-plural.expected @@ -17,20 +17,20 @@ fragment Assignable_user on User @assignable { import { FragmentRefs } from "relay-runtime"; export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get node(): { + get node(): { readonly __typename: "User"; -get parents(): ReadonlyArray<{}>, + get parents(): ReadonlyArray<{}>; set parents(value: ReadonlyArray<{ readonly __typename: "User"; readonly __id: string; readonly " $fragmentSpreads": "Assignable_user"; - }>): void, + }>); } | { // This will never be '%other', but we need some // value in case none of the concrete values match. readonly __typename: "%other"; - } | null, - set node(value: null | void): void, + } | null; + set node(value: null | void); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment.expected index a931210f25274..2472a2e757d3f 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragment.expected @@ -12,12 +12,12 @@ fragment Assignable_viewer on Viewer @assignable { import { FragmentRefs } from "relay-runtime"; export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get viewer(): {} | null, + get viewer(): {} | null; set viewer(value: { readonly __typename: "Viewer"; readonly __id: string; readonly " $fragmentSpreads": "Assignable_viewer"; - } | null): void, + } | null); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragments-within-narrowing.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragments-within-narrowing.expected index 1d9af2aef97f8..7fd56e290a157 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragments-within-narrowing.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-assignable-fragments-within-narrowing.expected @@ -25,8 +25,8 @@ fragment Assignable_page on Page @assignable { import { FragmentRefs } from "relay-runtime"; export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get me(): { -get actor(): { + get me(): { + get actor(): { readonly __typename: "Page"; } | { readonly __typename: "User"; @@ -34,7 +34,7 @@ get actor(): { // This will never be '%other', but we need some // value in case none of the concrete values match. readonly __typename: "%other"; - } | null, + } | null; set actor(value: { readonly __typename: "Page"; readonly __id: string; @@ -43,9 +43,9 @@ get actor(): { readonly __typename: "User"; readonly __id: string; readonly " $fragmentSpreads": "Assignable_user"; - } | null): void, - } | null, - set me(value: null | void): void, + } | null); + } | null; + set me(value: null | void); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-multiple-assignable-fragments.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-multiple-assignable-fragments.expected index eb70042fb762b..d61f64269d1ae 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-multiple-assignable-fragments.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-multiple-assignable-fragments.expected @@ -21,11 +21,11 @@ fragment Assignable_page on Page @assignable { import { FragmentRefs } from "relay-runtime"; export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get me(): { -get actor(): { + get me(): { + get actor(): { lastName: string | null; name: string | null; - } | null, + } | null; set actor(value: { readonly __typename: "Page"; readonly __id: string; @@ -34,9 +34,9 @@ get actor(): { readonly __id: string; readonly __isAssignable_node: string; readonly " $fragmentSpreads": "Assignable_node"; - } | null): void, - } | null, - set me(value: null | void): void, + } | null); + } | null; + set me(value: null | void); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-no-spreads.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-no-spreads.expected index 8cefbf1569ebc..20c04d13ab445 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-no-spreads.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-no-spreads.expected @@ -7,10 +7,10 @@ query UpdatableQuery @updatable { ==================================== OUTPUT =================================== export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get nodes(): ReadonlyArray<{ + get nodes(): ReadonlyArray<{ readonly id: string; - } | null> | null, - set nodes(value: []): void, + } | null> | null; + set nodes(value: []); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-with-spreads.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-with-spreads.expected index b357f5cb934ae..4417f814bcd33 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-with-spreads.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-plural-field-with-spreads.expected @@ -12,12 +12,12 @@ fragment Updatable_user on User @assignable { import { FragmentRefs } from "relay-runtime"; export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get nodes(): ReadonlyArray<{} | null> | null, + get nodes(): ReadonlyArray<{} | null> | null; set nodes(value: ReadonlyArray<{ readonly __typename: "User"; readonly __id: string; readonly " $fragmentSpreads": "Updatable_user"; - }>): void, + }>); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-special-fields.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-special-fields.expected index 0f4a5fee2043e..fdd3893e6a778 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-special-fields.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-special-fields.expected @@ -12,15 +12,15 @@ query UpdatableQuery @updatable { ==================================== OUTPUT =================================== export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get me(): { + get me(): { readonly __typename: "User"; readonly __id: string; readonly aliased_double_under_id: string; readonly aliased_id: string; readonly aliased_typename: "User"; readonly id: string; - } | null, - set me(value: null | void): void, + } | null; + set me(value: null | void); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-type-refinement.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-type-refinement.expected index 7bcaa4120e9e3..df7e57550e734 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-type-refinement.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation-type-refinement.expected @@ -17,22 +17,22 @@ query UpdatableQuery @updatable { ==================================== OUTPUT =================================== export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get maybeNodeInterface(): { + get maybeNodeInterface(): { readonly __typename: "NonNodeNoID"; name: string | null; } | { readonly __typename: "Story"; actorCount: number | null; -get address(): { + get address(): { city: string | null; - } | null, - set address(value: null | void): void, + } | null; + set address(value: null | void); } | { // This will never be '%other', but we need some // value in case none of the concrete values match. readonly __typename: "%other"; - } | null, - set maybeNodeInterface(value: null | void): void, + } | null; + set maybeNodeInterface(value: null | void); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation.expected index bca9726a7fd0e..d8a05f586f7a6 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/updatable-operation.expected @@ -8,11 +8,11 @@ query UpdatableQuery @updatable { ==================================== OUTPUT =================================== export type UpdatableQuery$variables = {}; export type UpdatableQuery$data = { -get me(): { + get me(): { actorCount: number | null; name: string | null; - } | null, - set me(value: null | void): void, + } | null; + set me(value: null | void); }; export type UpdatableQuery = { response: UpdatableQuery$data; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/mod.rs b/compiler/crates/relay-typegen/tests/generate_typescript/mod.rs index 462937972df9a..b825d64912db1 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/mod.rs +++ b/compiler/crates/relay-typegen/tests/generate_typescript/mod.rs @@ -15,8 +15,8 @@ use common::SourceLocationKey; use fixture_tests::Fixture; use fnv::FnvBuildHasher; use fnv::FnvHashMap; -use graphql_ir::OperationDefinitionName; use graphql_ir::build; +use graphql_ir::OperationDefinitionName; use graphql_ir::Program; use graphql_syntax::parse_executable; use indexmap::IndexMap;