-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rosetta): gets confused by type unions (#3156)
Rosetta gets confused by type unions when it's trying to derive the type of a struct. This bites CDK as we're generating examples for L1s, and they all have unions with `IResolvable` in all their properties. If we can match a struct, let's do so. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
- Loading branch information
Showing
5 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/jsii-rosetta/test/translations/structs/infer_struct_from_union.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Takes(new MyProps { | ||
Struct = new SomeStruct { | ||
Enabled = false, | ||
Option = "option" | ||
} | ||
}); |
6 changes: 6 additions & 0 deletions
6
packages/jsii-rosetta/test/translations/structs/infer_struct_from_union.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
takes(MyProps.builder() | ||
.struct(SomeStruct.builder() | ||
.enabled(false) | ||
.option("option") | ||
.build()) | ||
.build()); |
6 changes: 6 additions & 0 deletions
6
packages/jsii-rosetta/test/translations/structs/infer_struct_from_union.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
takes( | ||
struct=SomeStruct( | ||
enabled=False, | ||
option="option" | ||
) | ||
) |
29 changes: 29 additions & 0 deletions
29
packages/jsii-rosetta/test/translations/structs/infer_struct_from_union.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// !hide | ||
/// fake-from-jsii | ||
interface IResolvable { | ||
resolve(): any; | ||
} | ||
|
||
/// fake-from-jsii | ||
interface SomeStruct { | ||
readonly enabled: boolean | IResolvable; | ||
readonly option?: string | IResolvable; | ||
} | ||
|
||
/// fake-from-jsii | ||
interface MyProps { | ||
readonly struct?: IResolvable | SomeStruct; | ||
} | ||
|
||
function takes(props: MyProps) { | ||
} | ||
/// !show | ||
|
||
takes({ | ||
struct: { | ||
enabled: false, | ||
option: 'option', | ||
}, | ||
}); | ||
|
||
|