diff --git a/src/scripting/Elsa.Scripting.JavaScript/Services/JavaScriptExpressionEvaluator.cs b/src/scripting/Elsa.Scripting.JavaScript/Services/JavaScriptExpressionEvaluator.cs index 85482b5d0f..b1faa5faca 100644 --- a/src/scripting/Elsa.Scripting.JavaScript/Services/JavaScriptExpressionEvaluator.cs +++ b/src/scripting/Elsa.Scripting.JavaScript/Services/JavaScriptExpressionEvaluator.cs @@ -76,13 +76,15 @@ private object ConvertValue(JsValue value, Type targetType) if (value.IsNull()) return default; - if (targetType == typeof(bool) && value.IsBoolean()) + var targetIsObject = targetType == typeof(object); + + if (value.IsBoolean()) return value.AsBoolean(); - if (targetType == typeof(DateTime) && value.IsDate()) + if ((targetIsObject || targetType == typeof(DateTime)) && value.IsDate()) return value.AsDate().ToDateTime(); - if (targetType.IsNumeric() && value.IsNumber()) + if ((targetIsObject || targetType.IsNumeric()) && value.IsNumber()) return Convert.ChangeType(value.AsNumber(), targetType); if (targetType == typeof(string))