Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(rosetta): incorrect translation of inferred types to c# #3027

Closed
nija-at opened this issue Oct 5, 2021 · 1 comment · Fixed by #3047
Closed

(rosetta): incorrect translation of inferred types to c# #3027

nija-at opened this issue Oct 5, 2021 · 1 comment · Fixed by #3047
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@nija-at
Copy link
Contributor

nija-at commented Oct 5, 2021

🐛 Bug Report

In some cases, variables with inferred types get translated as __object in typescript.
This seems to happen when the type signature on the method is any.

See example below.

================= 7fbf857fd1de77d132905edb0484ed62d5d56ab4fe814ae1a79d0bf91aa83f57 =================
const expected = {
  Foo: 'Bar',
  Baz: 5,
  Qux: [ 'Waldo', 'Fred' ],
};
template.hasResourceProperties('Foo::Bar', expected);
----------- csharp -----------
__object expected = new Dictionary<string, object> {
    { "Foo", "Bar" },
    { "Baz", 5 },
    { "Qux", new [] { "Waldo", "Fred" } }
};
template.HasResourceProperties("Foo::Bar", expected);

The signature of the method used here is -

hasResourceProperties(type: string, props: any): void
@nija-at nija-at added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 5, 2021
@mergify mergify bot closed this as completed in #3047 Oct 11, 2021
mergify bot pushed a commit that referenced this issue Oct 11, 2021
)

(The diff of this PR will clean up after #3044 has been merged)

The error was in conflating "detecting a map type but not knowing
what the element type was" and "not detecting a map type" (these
cases could not be distinguished because both would result in
`undefined`).

Also remove an unnecessary argument to
`keyValueObjectLiteralExpression`.

Fixes #3026, fixes #3027.


---

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
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant