Skip to content

Commit

Permalink
Typing fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mike12345567 committed Jan 15, 2025
1 parent ff78610 commit 80a67dc
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
import { fade } from "svelte/transition"
import { UserScriptError } from "@budibase/string-templates"
export let expressionResult: string | undefined = undefined
export let expressionResult: string | { result: string } | undefined =
undefined
export let expressionError: string | undefined = undefined
export let evaluating = false
export let expression: string | null = null
$: error = expressionError != null
$: empty = expression == null || expression?.trim() === ""
$: success = !error && !empty
$: highlightedResult = highlight(expressionResult)
$: highlightedResult = highlight(
expressionResult && typeof expressionResult === "object"
? expressionResult.result
: expressionResult
)
const formatError = (err: any) => {
if (err.code === UserScriptError.code) {
Expand All @@ -22,7 +27,7 @@
return err.toString()
}
const highlight = (json: string | null) => {
const highlight = (json?: string | null) => {
if (json == null) {
return ""
}
Expand All @@ -47,7 +52,10 @@
}
const copy = () => {
let clipboardVal = expressionResult.result
let clipboardVal =
expressionResult && typeof expressionResult === "object"
? expressionResult.result
: expressionResult
if (typeof clipboardVal === "object") {
clipboardVal = JSON.stringify(clipboardVal, null, 2)
}
Expand Down

0 comments on commit 80a67dc

Please sign in to comment.