Support arbitrary additional fields as map or dictionary type #2928
Labels
feature-request
A feature should be added or improved.
module/jsii
Issues affecting the `jsii` module.
p1
馃殌 Feature Request
Affected Languages
TypeScript
orJavascript
Python
Java
C#
,F#
, ...)Go
General Information
Description
By default, empty interfaces in TypeScript allow adding any arbitrary properties. In addition, it is possible to allow arbitrary properties in interfaces with existing fields through index signatures:
Currently, neither method of supporting arbitrary fields are transliterated to Python (or other languages AFAIK). So if the interface is empty, than no properties can be added in the constructor (even though it's possible in TypeScript). This limitation came up in cdk8s-team/cdk8s-cli#33.
Proposed Solution
In Python, these interfaces should probably be transliterated into parameters with the
**kwargs
syntax. For other languages, I'm not sure if there are as clean equivalents. For example in Java, it might be necessary to have some reserved keyword for use in interfaces likeextraFields
which is simply typed as a mapping from strings to objects.This obviously presents some questions about runtime and type safety, so if that is an issue, or the feature isn't feasible for other technical reasons, perhaps it's worth adding some kind of optional validation as part of jsii that checks that index signatures are used in publicly exported interfaces? This part I'm not as sure about.
If this feature/issue has already been reported somewhere please let me know!
The text was updated successfully, but these errors were encountered: