From 38e7f2c6e23a094bca32d532cce8f22e405b0305 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Tue, 8 Aug 2023 16:35:27 +0200 Subject: [PATCH] fix: inferred structs from a namespace should be taken from namespace --- .../infer_namespaced_struct_from_union.cs | 6 ++++ .../infer_namespaced_struct_from_union.go | 8 ++++++ .../infer_namespaced_struct_from_union.java | 6 ++++ .../infer_namespaced_struct_from_union.py | 6 ++++ .../infer_namespaced_struct_from_union.ts | 28 +++++++++++++++++++ 5 files changed, 54 insertions(+) create mode 100644 test/translations/structs/infer_namespaced_struct_from_union.cs create mode 100644 test/translations/structs/infer_namespaced_struct_from_union.go create mode 100644 test/translations/structs/infer_namespaced_struct_from_union.java create mode 100644 test/translations/structs/infer_namespaced_struct_from_union.py create mode 100644 test/translations/structs/infer_namespaced_struct_from_union.ts diff --git a/test/translations/structs/infer_namespaced_struct_from_union.cs b/test/translations/structs/infer_namespaced_struct_from_union.cs new file mode 100644 index 00000000..afeb7d49 --- /dev/null +++ b/test/translations/structs/infer_namespaced_struct_from_union.cs @@ -0,0 +1,6 @@ +Takes(new MyProps { + Struct = new MyLib.SomeStruct { + Enabled = false, + Option = "option" + } +}); \ No newline at end of file diff --git a/test/translations/structs/infer_namespaced_struct_from_union.go b/test/translations/structs/infer_namespaced_struct_from_union.go new file mode 100644 index 00000000..7389f65b --- /dev/null +++ b/test/translations/structs/infer_namespaced_struct_from_union.go @@ -0,0 +1,8 @@ +takes(&myProps{ + Struct: &myLib.someStruct{ + Enabled: jsii.Boolean(false), + Option: jsii.String("option"), + }, +}) + + diff --git a/test/translations/structs/infer_namespaced_struct_from_union.java b/test/translations/structs/infer_namespaced_struct_from_union.java new file mode 100644 index 00000000..9967d0a6 --- /dev/null +++ b/test/translations/structs/infer_namespaced_struct_from_union.java @@ -0,0 +1,6 @@ +takes(MyProps.builder() + .struct(MyLib.SomeStruct.builder() + .enabled(false) + .option("option") + .build()) + .build()); \ No newline at end of file diff --git a/test/translations/structs/infer_namespaced_struct_from_union.py b/test/translations/structs/infer_namespaced_struct_from_union.py new file mode 100644 index 00000000..8802e34f --- /dev/null +++ b/test/translations/structs/infer_namespaced_struct_from_union.py @@ -0,0 +1,6 @@ +takes( + struct=MyLib.SomeStruct( + enabled=False, + option="option" + ) +) diff --git a/test/translations/structs/infer_namespaced_struct_from_union.ts b/test/translations/structs/infer_namespaced_struct_from_union.ts new file mode 100644 index 00000000..885a7a64 --- /dev/null +++ b/test/translations/structs/infer_namespaced_struct_from_union.ts @@ -0,0 +1,28 @@ +/// !hide +/// fake-from-jsii +interface IResolvable { + resolve(): any; +} + +namespace MyLib { + /// fake-from-jsii + interface SomeStruct { + readonly enabled: boolean | IResolvable; + readonly option?: string | IResolvable; + } + + /// fake-from-jsii + export interface MyProps { + readonly struct?: IResolvable | SomeStruct; + } +} + +function takes(props: MyLib.MyProps) {} +/// !show + +takes({ + struct: { + enabled: false, + option: 'option', + }, +});