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

docs(constructs.mdx) #3711

Closed
wants to merge 1 commit into from
Closed

docs(constructs.mdx) #3711

wants to merge 1 commit into from

Conversation

polyglotm
Copy link

I changed the example.

In TaggedS3Bucket example this documents re-assigne value into this.tagsInput with spread operator like this.

this.tagsInput = {
     ...this.tagsInput,
     owner: "my-team",
     purpose: "storage",
};

I changed to

Object.assign(this.tagsInput, {
    owner: "my-team",
    purpose: "storage"
});

What’s the difference?

When use … AKA spread operator is a kind of duplicate mechanism
And usually use for dont want impact to original value.

When using Object.assign it’s just extend the original object

In this document example …this.tagsInput is used for assing itself.
which means generate new object and assign to original object
It’s working but not best practice.

If you change to Object.assign approach (my offer)

  1. There are tiny performance difference
  2. And who read this documents they instintly understand ‘oh this guy extends object’

I love Terraform, and I wish Terraform document offer best practice
Thank you.

I changed example code for best practice
Copy link

hashicorp-cla-app bot commented Aug 21, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@polyglotm polyglotm closed this Aug 21, 2024
@polyglotm polyglotm deleted the patch-2 branch August 21, 2024 08:11
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant