cdk-from-cfn
cdk-from-cfn copied to clipboard
Minor improvement - remove many non-null assertions
It's not good to use the non-null assertion operator if we can avoid it, and we can fix the way defaults are applied to props to make this not needed.
We can change the following output
public constructor(scope: cdk.App, id: string, props: NoctStackProps) {
super(scope, id, props);
// Applying default props
props = {
...props,
myProperty: props.myProperty ?? '',
To the below output
public constructor(scope: cdk.App, id: string, originalProps: NoctStackProps) {
super(scope, id, originalProps);
// Applying default props
const props = {
...originalProps,
myProperty: originalProps.myProperty ?? '',
And now props has non nullable types and does not need non-null assertions everywhere.