Skip to content

Commit f9df84f

Browse files
committed
Make generated castJsonResult.ts files undefined-safe
1 parent 7855d4c commit f9df84f

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.2.7] - 2026-02-16
2+
3+
- Make generated castJsonResult.ts files undefined-safe
4+
15
## [1.2.6] - 2026-02-16
26

37
- Make use of guaranteed_to_exist to avoid marking present delegates as optional

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-typescript-remote-command-generator (1.2.6)
4+
foobara-typescript-remote-command-generator (1.2.7)
55
foobara (>= 0.1.16, < 2.0.0)
66
foobara-files-generator (< 2.0.0)
77

src/remote_generator/services/command_cast_result_generator.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,22 @@ def _ts_cast_expression(cast_tree, value:, parent: nil, property: nil)
190190
expression = "if (#{value} !== undefined) {\n"
191191

192192
expression += if type_symbol == :date || type_symbol == :datetime
193-
"#{lvalue} = new Date(#{present_value})\n"
193+
"#{lvalue} = new Date(#{present_value})"
194194
elsif type.model?
195195
ts_model_name = model_to_ts_model_name(type,
196196
association_depth:,
197197
initial: cast_tree.initial)
198198

199-
"#{lvalue} = new #{ts_model_name}(#{present_value})\n"
199+
"#{lvalue} = new #{ts_model_name}(#{present_value})"
200200
else
201201
# :nocov:
202202
raise "Not sure how to cast type #{type} to a Typescript expression"
203203
# :nocov:
204204
end
205205

206-
expression += "}"
206+
expression += "\n}"
207+
208+
expression
207209
end
208210

209211
def _construct_cast_tree(type_declaration, initial: false)

version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Foobara
22
module TypescriptRemoteCommandGenerator
33
module Version
4-
VERSION = "1.2.6".freeze
4+
VERSION = "1.2.7".freeze
55
MINIMUM_RUBY_VERSION = ">= 3.4.0".freeze
66
end
77
end

0 commit comments

Comments
 (0)