chore(cdk-lib): migrate to jsii@5.0 / jsii-rosetta@5.0#24425
chore(cdk-lib): migrate to jsii@5.0 / jsii-rosetta@5.0#24425mergify[bot] merged 36 commits intomainfrom
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
RomainMuller
left a comment
There was a problem hiding this comment.
The bulk of code changes here fall into one of these categories:
Promise<void>must be explicitly typed, or TypeScript will require a parameter be provided to theresolvehandler.catchbindings areunknownby default, explicitly typed asanyin places where this was assumed, and removed the binding entirely in the few places where it was not used.abstract asyncis no longer valid, removed theasynckeyword (the contract really is just "returns a promise", which is expressed fully with the return type declaration)- Some generic helper methods needed tweaking due to hardened type checking safety around uses of
Object.keys,Object.values,Object.entries. - Some places blindly assumed
Object.keysreturns onlystring, but it could containSymbolobjects which have a throwingtoString(they need to be strigified asString(sym)). The 4.9 TypeScript compiler actually reports this as an error. Hardened such uses. - Adding
overrideskeywords as I am proposing to enablenoImplicitOverride
Then, there are some more annoying aspects where jsii@v4.9 checks (and prohibits) things that v1 silently ignores or mis-interprets (back-porting of these checks to v1 is planned, but they'll likely need to be WARNING there). I am adding a comment on each use-case to facilitate discussion.
| connection: Port, | ||
| fromTo: 'from' | 'to', | ||
| remoteRule?: boolean): [SecurityGroupBase, string] { | ||
| remoteRule?: boolean): RuleScope { |
There was a problem hiding this comment.
This is incorrectly processed by jsii@v1, which treats it the same as object, resulting in the JSON primitive type.
The API is protected. Is it intended for external use? Can it be made @internal?
Changing the return type to an object here is a breaking change, but provides better semantics... This API is currently very awkward to use in non-JS/TS languages.
There was a problem hiding this comment.
Note - I could not find any use of this API outside of the CDK Construct library on a cursory search on GitHub.
| @@ -1,7 +1,7 @@ | |||
| #!/bin/bash | |||
| set -euo pipefail | |||
|
|
|||
| export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}" | |||
| export NODE_OPTIONS="--max-old-space-size=8196 ${NODE_OPTIONS:-}" | |||
There was a problem hiding this comment.
Uniformed the --max-old-space-size= in all the scripts to the highest value that was in any of them.
I've had jsii run out of heap building aws-cdk-lib here, with ~4G heap (the default on my system). Bumping to 8G fixed that...
We may want to review jsii's memory usage separately to see whether there are avenues for improvement (last similar exercise we did concluded that the bulk of the use was TypeScript itself, but it can't hurt to reassess).
| @@ -47,7 +48,7 @@ describe('CustomResourceHandler', () => { | |||
| const nocked = nockUp((body) => { | |||
| return body.Status === 'SUCCESS' | |||
| && body.Reason === 'OK' | |||
| && body.Data === {} | |||
| && isDeepStrictEqual(body.Data, {}) | |||
There was a problem hiding this comment.
The TypeScript 4.9 compiler considers comparing an object literal expression as an error, since this would be a reference comparison, and not a value comparison, and the ECMAScript standard mandates that each individual object literal is an individual object (so such comparisons can never be true).
It is unclear to me how this test could have succeeded. Perhaps a V8-specific quirk?
packages/@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts
Show resolved
Hide resolved
640ff29 to
eed8bd4
Compare
f8351c2 to
b279f89
Compare
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
Naumel
left a comment
There was a problem hiding this comment.
Relevant: https://github.com/aws/aws-cdk/pull/24425/files?diff=split&w=1#r1134057642, therefore approving √
I am marking the PR as pr/do-not-merge to allow others to review, if they chose to do so.
| } | ||
|
|
||
| function undefinedIfNoKeys<A>(obj: A): A | undefined { | ||
| function undefinedIfNoKeys<A extends { [key: string]: unknown }>(obj: A): A | undefined { |
There was a problem hiding this comment.
[breadcrumb] Anything is assignable to unknown, but unknown isn't assignable to anything but itself. Diff from any.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Co-authored-by: Naumel <104374999+Naumel@users.noreply.github.com>
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Updates dependencies & code as necessary to use `jsii@5.0` to build the AWS CDK. BREAKING CHANGE: The return type of `aws-cdk-lib.aws_ec2.SecurityGroup.determineRuleScope` was changed from a tuple (`[SecurityGroupBase, string]`) to a struct with the same values, because tuple types are not supported over the jsii interoperability layer, but `jsii@v1` was incorrectly allowing this to be represented as the `JSON` primitive type. This made the API unusable in non-JS languages. The type of the `metadata` property of `aws-cdk-lib.aws_s3_deployment.BucketDeploymentProps` was changed from an index-only struct to an inline map, because `jsii@v1` silently ignored the index signature (which is otherwise un-supported), resulting in an empty object in non-JS/TS languages. As a consequence, the values of that map can no longer be `undefined` (as `jsii` does not currently support nullable elements in collections). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Updates dependencies & code as necessary to use
jsii@5.0to build the AWS CDK.BREAKING CHANGE: The return type of
aws-cdk-lib.aws_ec2.SecurityGroup.determineRuleScopewas changed from a tuple ([SecurityGroupBase, string]) to a struct with the same values, because tuple types are not supported over the jsii interoperability layer, butjsii@v1was incorrectly allowing this to be represented as theJSONprimitive type. This made the API unusable in non-JS languages. The type of themetadataproperty ofaws-cdk-lib.aws_s3_deployment.BucketDeploymentPropswas changed from an index-only struct to an inline map, becausejsii@v1silently ignored the index signature (which is otherwise un-supported), resulting in an empty object in non-JS/TS languages. As a consequence, the values of that map can no longer beundefined(asjsiidoes not currently support nullable elements in collections).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license