Skip to content

Commit ac739e6

Browse files
chore: merge main
2 parents c2b2b2d + 0da4749 commit ac739e6

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/libs/macros/src/functions/derive.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ fn derive_struct(
6565
.map(|f| {
6666
let fname = &f.ident;
6767
if has_nested_attr(f) {
68-
quote! { #fname: input.#fname.into(), }
68+
if unwrap_option(&f.ty).is_some() {
69+
quote! { #fname: input.#fname.map(|v| v.into()), }
70+
} else {
71+
quote! { #fname: input.#fname.into(), }
72+
}
6973
} else {
7074
quote! { #fname: input.#fname, }
7175
}
@@ -77,7 +81,11 @@ fn derive_struct(
7781
.map(|f| {
7882
let fname = &f.ident;
7983
if has_nested_attr(f) {
80-
quote! { #fname: json_data.#fname.into(), }
84+
if unwrap_option(&f.ty).is_some() {
85+
quote! { #fname: json_data.#fname.map(|v| v.into()), }
86+
} else {
87+
quote! { #fname: json_data.#fname.into(), }
88+
}
8189
} else {
8290
quote! { #fname: json_data.#fname, }
8391
}

src/sputnik/src/js/apis/node/llrt/llrt_url/url_class.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![allow(clippy::inherent_to_string)]
2-
32
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
43
// SPDX-License-Identifier: Apache-2.0
54
#![allow(clippy::uninlined_format_args)]

src/sputnik/src/js/apis/node/llrt/llrt_url/url_search_params.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,3 @@ fn get_coerced_string_value<'js>(ctx: &Ctx<'js>, value: Opt<Value<'js>>) -> Opti
414414
};
415415
None
416416
}
417-

src/tests/fixtures/test_sputnik/resources/custom-functions-option.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ export const demoAntonio = defineQuery({
3434

3535
// Assertion which would make the npm run build:test-sputnik fail
3636

37+
const PreferencesSchema = j.strictObject({
38+
theme: j.string()
39+
});
40+
41+
export const testQuery = defineQuery({
42+
result: j.strictObject({
43+
// Issue: Option<nested struct> fields with #[json_data(nested)] generated `.into()`
44+
// instead of `.map(|v| v.into())`, causing a missing From trait bound at compile time.
45+
preferences: PreferencesSchema.optional()
46+
}),
47+
handler: () => ({
48+
preferences: undefined
49+
})
50+
});
51+
3752
export const testQuery2 = defineQuery({
3853
result: j.strictObject({
3954
// Issue: optional enum fields incorrectly emitted #[json_data(nested)] because

0 commit comments

Comments
 (0)