cdk-monitoring-constructs icon indicating copy to clipboard operation
cdk-monitoring-constructs copied to clipboard

Upgrade jsii and TypeScript

Open kfritz opened this issue 6 months ago • 3 comments

Feature scope

All

Describe your suggested feature

Hello friends.

Currently, cdk-monitoring-constructs is using an older version of jsii. Two years ago, AWS released jsii-5.x with the goal of enabling more TypeScript features. It also sets up a versioning scheme where the jsii version number would more-or-less follow the supported TypeScript version number.

As a developer seeking to implement features in cdk-monitoring-constructs, I would like to avail myself of these new language features. Additionally, jsii-1.x that the library currently uses is out-of-support by AWS, so it would be helpful to upgrade.

Implementation considerations

For what it's worth, I took a look at what would be required to update cdk-monitoring-constructs to jsii-5.7.3 and TypeScript-5.7.3. Most of the code works fine, except for the MonitoringAspect features. These types fail to compile with jsii-5 because of the generic type declaration of MonitoringAspectType<T>. As stated in the jsii documentation:

Parameterized types are not consistently supported in all supported target languages. Go support for generics is relatively limited (for good reasons) compared to TypeScript and most Object-Oriented languages, and the differences in generic semantics between TypeScript, C# and Java make it difficult to correctly represent such types in all those languages. As a consequence, jsii does not support declaring parameterized types.

Given the limitation described above, it makes sense why MonitoringAspectType<T> doesn't work with jsii-5.x. In fact, it shouldn't work in jsii-1.x either, and it's not clear to me why it is compiling without error in jsii-1.x. My best guess for what's happening in jsii-1.x comes from this note in the jsii-5.x announcement:

The 1.x release line silently ignores index signatures (these are hence unavailable in other languages), and the 5.0.x release starts explicitly rejecting these

That's not really talking about generic types, but I'm guess it's the same situation? Perhaps jsii-1.x is just dropping the monitoring aspect feature in non-TS/JS languages, while jsii-5.x explicitly rejects it. If so, we'd need to decide how to handle this situation if we upgrade to jsii-5.x:

  • Find a way to keep aspect monitoring for TS/JS-only. I tried putting @jsii ignore on all the types, but it didn't work the way I expected -- could use some help from someone more familiar with jsii.
  • Delete the aspect monitoring feature completely. Clearly, that's a regrettable option, but could be worth discussing.

kfritz avatar Apr 01 '25 17:04 kfritz