cdk-from-cfn icon indicating copy to clipboard operation
cdk-from-cfn copied to clipboard

wrong output - boolean properties

Open TenPotatoes opened this issue 2 years ago • 3 comments

props.myProperty! === 'true';

should be

props.myProperty! === true;

TenPotatoes avatar Nov 21 '23 17:11 TenPotatoes

There is not enough information here to solve this issue. Please provide further context where this is showing up.

TheRealAmazonKendra avatar Feb 22 '24 00:02 TheRealAmazonKendra

Oh, issue is not what I thought. It is actually a string property that contains "true" or "false", and it getting output halfway as a boolean and halfway as a string. It should pick one type or the other.

Input:

"Parameters": {
      "MyProperty": {
         "AllowedValues": [
               "true",
               "false"
         ],
         "Default": "true",
         "Type": "String"
      },
Conditions:
  MyCondition:
    Fn::Equals: [ {Ref: MyProperty}, "true"]

Output:

 export interface NoctStackProps extends cdk.StackProps {
   /**
    * @default 'true'
    */
   readonly myProperty?: boolean;
myProperty: props.myProperty ?? true
const myCondition = props.myProperty! === 'true';

TenPotatoes avatar Feb 22 '24 14:02 TenPotatoes

Thanks for the clarification!

TheRealAmazonKendra avatar Feb 26 '24 23:02 TheRealAmazonKendra