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

Allow Custom String Representation of Constructs #361

Open
skorfmann opened this issue Sep 7, 2020 · 0 comments
Open

Allow Custom String Representation of Constructs #361

skorfmann opened this issue Sep 7, 2020 · 0 comments
Labels
cdktf enhancement New feature or request priority/backlog Low priority (though possibly still important). Unlikely to be worked on within the next 6 months. upstream/jsii Pending upstream work on JSII

Comments

@skorfmann
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

For some constructs / resources allowing custom type coercions could be very useful to enable an idiomatic usage.

For TerraformLocals I think it would make sense to add the following to the Typescript classes.

    public toString(): string {
        return this.asString
    }

This would allow to use it like my-first-table-${local} rather than my-first-table-${local.asString}.

The issue is, that this would only work for Typescript, but none of the other target languages. Python would look like this: "my-first-sns-topic-<cdktf.TerraformLocal object at 0x10cd45190>"

It doesn't look like, that Jsii is handling this automatically if there's toString() function defined. Defining the required method for Python in the Typescript class manually only works as @internal and therefore wouldn't be compiled via jsii.

 /** @internal */
    public __str__(): string {
        return this.asString
    }

I think there are more cases where this becomes relevant. In the best case this would be addressed in Jsii directly.

References

@skorfmann skorfmann added enhancement New feature or request cdktf upstream/jsii Pending upstream work on JSII labels Sep 7, 2020
@xiehan xiehan added the priority/backlog Low priority (though possibly still important). Unlikely to be worked on within the next 6 months. label Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cdktf enhancement New feature or request priority/backlog Low priority (though possibly still important). Unlikely to be worked on within the next 6 months. upstream/jsii Pending upstream work on JSII
Projects
None yet
Development

No branches or pull requests

2 participants