-
Notifications
You must be signed in to change notification settings - Fork 4k
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
chore(cdk-lib): migrate to jsii@5.0 / jsii-rosetta@5.0 #24425
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 theresolve
handler.catch
bindings areunknown
by default, explicitly typed asany
in places where this was assumed, and removed the binding entirely in the few places where it was not used.abstract async
is no longer valid, removed theasync
keyword (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.keys
returns onlystring
, but it could containSymbol
objects 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
overrides
keywords 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.
@@ -178,15 +178,15 @@ abstract class SecurityGroupBase extends Resource implements ISecurityGroup { | |||
peer: IPeer, | |||
connection: Port, | |||
fromTo: 'from' | 'to', | |||
remoteRule?: boolean): [SecurityGroupBase, string] { | |||
remoteRule?: boolean): RuleScope { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Outdated
Show resolved
Hide resolved
640ff29
to
eed8bd4
Compare
f8351c2
to
b279f89
Compare
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -248,7 +248,7 @@ export interface IHttpRouteAuthorizer { | |||
bind(options: HttpRouteAuthorizerBindOptions): HttpRouteAuthorizerConfig; | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.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, butjsii@v1
was incorrectly allowing this to be represented as theJSON
primitive type. This made the API unusable in non-JS languages. The type of themetadata
property ofaws-cdk-lib.aws_s3_deployment.BucketDeploymentProps
was changed from an index-only struct to an inline map, becausejsii@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 beundefined
(asjsii
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