From 6add1109d110b4c5067827980a9c34279927af10 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Mon, 22 Jan 2024 16:29:23 +0100 Subject: [PATCH] chore: fix ts issues --- packages/@cdktf/hcl2cdk/lib/generation.ts | 4 ++-- packages/@cdktf/hcl2cdk/lib/partialCode.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/@cdktf/hcl2cdk/lib/generation.ts b/packages/@cdktf/hcl2cdk/lib/generation.ts index c7cab26846..64f09e9740 100644 --- a/packages/@cdktf/hcl2cdk/lib/generation.ts +++ b/packages/@cdktf/hcl2cdk/lib/generation.ts @@ -107,7 +107,7 @@ export const valueToTs = async ( } // For iterators and dynamic blocks we put the correct TS expression in the config ahead of time - if (t.isExpression(item)) { + if (t.isNode(item) && t.isExpression(item)) { return item; } @@ -198,7 +198,7 @@ export const valueToTs = async ( const shouldBeArray = typeof value === "object" && !Array.isArray(value) && - !t.isExpression(value) && + !(t.isNode(value) && t.isExpression(value)) && !isSingleItemBlock && // Map type attributes must not be wrapped in arrays !isMapAttribute(itemAttributeType) && diff --git a/packages/@cdktf/hcl2cdk/lib/partialCode.ts b/packages/@cdktf/hcl2cdk/lib/partialCode.ts index b44652b8bf..ae67ebe7c9 100644 --- a/packages/@cdktf/hcl2cdk/lib/partialCode.ts +++ b/packages/@cdktf/hcl2cdk/lib/partialCode.ts @@ -53,7 +53,8 @@ export function fillWithConfigAccessors( const value = mutated[key]; const isNotDirectlyAccessible = value === undefined; const isReplacedByAst = - t.isExpression(mutated) || t.isExpression(value as any); + (t.isNode(mutated) && t.isExpression(mutated)) || + t.isExpression(value as any); const isEmptyArray = Array.isArray(value) && value.length === 0; // If this was already replaced by an AST node, we don't need to do anything