cloudformation-cli-typescript-plugin icon indicating copy to clipboard operation
cloudformation-cli-typescript-plugin copied to clipboard

package class-transformer introduces breaking changes to the model.ts generated file

Open HeatherFlux opened this issue 10 months ago • 4 comments

Currently the package "class-transformer": "^0.3.1" is using a carat ^ for its version. On a install and build of the cfn cli it pulls version 0.3.2 from the registry. Version 0.3.2 has changed its interface for the @transform decorator from

@Transform((value: any, obj: any) => {})

to

@Transform((params: TransformFnParams) => {}

When doing the npm install with 0.3.2 you will get the following message

npm WARN deprecated [email protected]: This release contains a breaking change from 0.3.1 but otherwise functions properly. Please read the changelog on Github to learn more.

For any developer using this with a local class-transformer at 0.3.1 you would see no error in the generated model.ts file and no error in the cloudwatch logs since the logger proxy isn't instantiated until after the plainToClass function is called in the code. This function errors at the model.ts file and returns no transformed object. When manually updating the model.ts file to use the new interface the class-transformer functions correctly and no longer strips the fields and locking class-transformer to 0.3.2

Proposed Fix:

The cfn generate command should be updated to use the new class-transformer interfaces or the class-transformer package should be locked at 0.3.1 and a new patch should go out.

Further Investigation

Further investigation should be put into the current tsconfig using the node14 settings as well given node14 is no longer supported in aws lambdas.

HeatherFlux avatar Apr 08 '24 15:04 HeatherFlux