From 7d6377fa14777ee58babbf59ce2ba659e85e850f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 15 Mar 2024 13:01:33 +0100 Subject: [PATCH] Fix types --- packages/string-templates/src/handlebars-helpers.d.ts | 1 - packages/string-templates/src/helpers/external.ts | 1 + packages/string-templates/src/helpers/javascript.ts | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 packages/string-templates/src/handlebars-helpers.d.ts diff --git a/packages/string-templates/src/handlebars-helpers.d.ts b/packages/string-templates/src/handlebars-helpers.d.ts deleted file mode 100644 index 90f8b6cb16..0000000000 --- a/packages/string-templates/src/handlebars-helpers.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "@budibase/handlebars-helpers" diff --git a/packages/string-templates/src/helpers/external.ts b/packages/string-templates/src/helpers/external.ts index ca0d0a9c6d..3a95406549 100644 --- a/packages/string-templates/src/helpers/external.ts +++ b/packages/string-templates/src/helpers/external.ts @@ -1,3 +1,4 @@ +// @ts-ignore we don't have types for it import helpers from "@budibase/handlebars-helpers" import { date, duration } from "./date" diff --git a/packages/string-templates/src/helpers/javascript.ts b/packages/string-templates/src/helpers/javascript.ts index 21a556a3bc..7078cbb6c7 100644 --- a/packages/string-templates/src/helpers/javascript.ts +++ b/packages/string-templates/src/helpers/javascript.ts @@ -1,11 +1,11 @@ -import { atob, isBackendService, isJSAllowed } from "../utilities" +import { atob, isJSAllowed } from "../utilities" import cloneDeep from "lodash/fp/cloneDeep" import { LITERAL_MARKER } from "../helpers/constants" import { getJsHelperList } from "./list" // The method of executing JS scripts depends on the bundle being built. // This setter is used in the entrypoint (either index.js or index.mjs). -let runJS: (js: string, context: any) => any +let runJS: ((js: string, context: any) => any) | undefined = undefined export const setJSRunner = (runner: typeof runJS) => (runJS = runner) export const removeJSRunner = () => { @@ -44,7 +44,7 @@ const getContextValue = (path: string, context: any) => { // Evaluates JS code against a certain context export function processJS(handlebars: string, context: any) { - if (!isJSAllowed() || (isBackendService() && !runJS)) { + if (!isJSAllowed() || !runJS) { throw new Error("JS disabled in environment.") } try {