diff --git a/compiler/crates/relay-typegen/src/visit.rs b/compiler/crates/relay-typegen/src/visit.rs index 857f3890acd29..0521391c665ff 100644 --- a/compiler/crates/relay-typegen/src/visit.rs +++ b/compiler/crates/relay-typegen/src/visit.rs @@ -1543,7 +1543,14 @@ fn make_prop( if linked_field.node_type.is_list() { AST::RawType(intern!("[]")) } else { - AST::RawType(intern!("null | void")) + let typegen_language = + typegen_context.project_config.typegen_config.language; + + if typegen_language == TypegenLanguage::TypeScript { + AST::RawType(intern!("null | undefined")) + } else { + AST::RawType(intern!("null | void")) + } } } else { let setter_parameter = AST::Union( 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 0c32fcd40b0c5..f2eb8c4391e4a 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 @@ -30,7 +30,7 @@ export type UpdatableQuery$data = { // value in case none of the concrete values match. readonly __typename: "%other"; } | null; - set node(value: null | void); + set node(value: null | undefined); }; 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 7fd56e290a157..4fc63abd12f7f 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 @@ -45,7 +45,7 @@ export type UpdatableQuery$data = { readonly " $fragmentSpreads": "Assignable_user"; } | null); } | null; - set me(value: null | void); + set me(value: null | undefined); }; 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 d61f64269d1ae..6da7b354dae32 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 @@ -36,7 +36,7 @@ export type UpdatableQuery$data = { readonly " $fragmentSpreads": "Assignable_node"; } | null); } | null; - set me(value: null | void); + set me(value: null | undefined); }; 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 fdd3893e6a778..2d2d7e5ea0f8c 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 @@ -20,7 +20,7 @@ export type UpdatableQuery$data = { readonly aliased_typename: "User"; readonly id: string; } | null; - set me(value: null | void); + set me(value: null | undefined); }; 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 df7e57550e734..c3cafea523182 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 @@ -26,13 +26,13 @@ export type UpdatableQuery$data = { get address(): { city: string | null; } | null; - set address(value: null | void); + set address(value: null | undefined); } | { // 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); + set maybeNodeInterface(value: null | undefined); }; 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 d8a05f586f7a6..6f1e7bdc23f12 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 @@ -12,7 +12,7 @@ export type UpdatableQuery$data = { actorCount: number | null; name: string | null; } | null; - set me(value: null | void); + set me(value: null | undefined); }; export type UpdatableQuery = { response: UpdatableQuery$data;