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

[typescript/program-gen] Allow iterating dynamic entries in TypeScript #12961

Merged
merged 2 commits into from May 16, 2023

Conversation

Zaid-Ajaj
Copy link
Contributor

This PR fixes an issue in TypeScript program-gen to allow iterating over a dynamic variable. Treats them the same way maps and objects are handled.

This piece of code:

  validationOptions = [for entry in entries(validationOption) : {
    domainName       = entry.value["domain_name"]
    validationDomain = entry.value["validation_domain"]
  }]

used to compile to

// invalid TypeScript
validationOptions:  => ({key: k, value: v})).map(entry => ({
        domainName: entry.value.domain_name,
        validationDomain: entry.value.validation_domain,
    })),

but now fixed to compile to

validationOptions: Object.entries(validationOption).map(([k, v]) => ({key: k, value: v})).map(entry => ({
        domainName: entry.value.domain_name,
        validationDomain: entry.value.validation_domain,
    })),

See added test example for full code.

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@Zaid-Ajaj Zaid-Ajaj requested a review from justinvp May 16, 2023 18:16
@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2023-05-16)

Bug Fixes

  • [programgen/nodejs] Allow iterating dynamic entries in TypeScript
    #12961

@Zaid-Ajaj
Copy link
Contributor Author

@justinvp for some reason, compiling the generated TypeScript program seems to fail. I've confirmed that the generated code compiles and type-checks just fine from a fresh pulumi new typescript program 🤔 I'll skip the compilation for now and merge if all is green.

@Zaid-Ajaj
Copy link
Contributor Author

bors merge

@bors
Copy link
Contributor

bors bot commented May 16, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 0799713 into master May 16, 2023
47 of 52 checks passed
@bors bors bot deleted the zaid/typescript-dynamic-entries branch May 16, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants