Skip to content

Commit

Permalink
Replace void with undefined for TypeScript parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-tengler committed Jul 17, 2023
1 parent 2724a11 commit 10f87a7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
9 changes: 8 additions & 1 deletion compiler/crates/relay-typegen/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 10f87a7

Please sign in to comment.