Closed flochaz closed 2 years ago
In our current tsconfig.json
we are using ES2020
as target (example here) but according to the TS documentation (link) the mapping for node12.x
should be ES2019
:
{
"compilerOptions": {
"lib": ["ES2019"],
"module": "commonjs",
"target": "ES2019"
}
}
Maybe this is the issue?
But then I don't fully understand why the integration tests we are running don't break.
Note on this. Target2019 doesn't support ?.
argument. So code like this:
//in target 2020
subsegment?.close();
will be:
//in target 2019
subsegment === null || subsegment === void 0 ? void 0 : subsegment.close();
This is fine functionally. But it reduces our unit test branch coverage and breaks our commit/push hooks.
The options to fix this are:
as
to cast to a type that is not optional!
to tell typescript that there is always a value (but we'll need to ignore with // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
)?.
is used in many places. I'll be using different options based on situation.
Ref: https://linguinecode.com/post/how-to-solve-typescript-possibly-undefined-value
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Bug description
Node12 with standard bundling of lambda does not work and throw
Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '.'
Expected Behavior
Installing and bundling my lambda with powertools "normally" should work on node12 runtime.
Current Behavior
Given a function bundled as a zip including
@aws-lambda-powertools/*
modules innode_modules
and importing the lib in theindex.js
such as:When triggered, it will throw the following exception if runtime is Node12.x:
Possible Solution
Steps to Reproduce
Check https://github.com/awslabs/aws-lambda-powertools-typescript/runs/6521588868?check_suite_focus=true
or
An easyway to reproduce is to test the lambda layer
You will get the following failure
Environment
Related issues, RFCs
detected while testing layer: #884