Small TS improvement - make sure result/error is typed correctly.

This commit is contained in:
mike12345567 2025-01-15 15:18:11 +00:00
parent 7db70a602d
commit ef3ac8883e
2 changed files with 7 additions and 7 deletions

View File

@ -31,7 +31,7 @@
import { capitalise } from "@/helpers" import { capitalise } from "@/helpers"
import { Utils, JsonFormatter } from "@budibase/frontend-core" import { Utils, JsonFormatter } from "@budibase/frontend-core"
import { licensing } from "@/stores/portal" import { licensing } from "@/stores/portal"
import { BindingMode, EditorMode, SidePanel } from "@budibase/types" import { BindingMode, SidePanel } from "@budibase/types"
import type { import type {
EnrichedBinding, EnrichedBinding,
BindingCompletion, BindingCompletion,
@ -64,8 +64,8 @@
let getCaretPosition: CaretPositionFn | undefined let getCaretPosition: CaretPositionFn | undefined
let insertAtPos: InsertAtPositionFn | undefined let insertAtPos: InsertAtPositionFn | undefined
let targetMode: BindingMode | null = null let targetMode: BindingMode | null = null
let expressionResult: string | undefined | null let expressionResult: string | undefined
let expressionError: string | undefined | null let expressionError: string | undefined
let evaluating = false let evaluating = false
$: useSnippets = allowSnippets && !$licensing.isFreePlan $: useSnippets = allowSnippets && !$licensing.isFreePlan
@ -155,7 +155,7 @@
const debouncedEval = Utils.debounce( const debouncedEval = Utils.debounce(
(expression: string | null, context: any, snippets: Snippet[]) => { (expression: string | null, context: any, snippets: Snippet[]) => {
try { try {
expressionError = null expressionError = undefined
expressionResult = processStringSync( expressionResult = processStringSync(
expression || "", expression || "",
{ {
@ -167,7 +167,7 @@
} }
) )
} catch (err: any) { } catch (err: any) {
expressionResult = null expressionResult = undefined
expressionError = err expressionError = err
} }
evaluating = false evaluating = false

View File

@ -5,8 +5,8 @@
import { fade } from "svelte/transition" import { fade } from "svelte/transition"
import { UserScriptError } from "@budibase/string-templates" import { UserScriptError } from "@budibase/string-templates"
export let expressionResult export let expressionResult: string | undefined = undefined
export let expressionError export let expressionError: string | undefined = undefined
export let evaluating = false export let evaluating = false
export let expression: string | null = null export let expression: string | null = null