Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(script_deployer): basic typecheck
Elian Doran5e9c51459612
diff --git a/apps/script-deployer/scripts/import-xopp-to-canvas.jsx b/apps/script-deployer/scripts/import-xopp-to-canvas.jsxindex 7ea268433d..55ad6503bc 100644--- a/apps/script-deployer/scripts/import-xopp-to-canvas.jsx+++ b/apps/script-deployer/scripts/import-xopp-to-canvas.jsx@@ -24,8 +24,6 @@ const XOPP_COLORS = {white: "#ffffff",};-// Hi there.-function convertColor(color) {if (!color) return "#000000";const lower = color.toLowerCase();diff --git a/apps/script-deployer/src/trilium-env.d.ts b/apps/script-deployer/src/trilium-env.d.tsnew file mode 100644index 0000000000..01d0b97391--- /dev/null+++ b/apps/script-deployer/src/trilium-env.d.ts@@ -0,0 +1,45 @@+/**+ * Ambient type declarations for the virtual modules available inside+ * Trilium user scripts (`trilium:preact` and `trilium:api`).+ *+ * These modules don't exist on disk — the server rewrites imports at+ * runtime — but providing declarations here gives us editor+ * intellisense and `tsc` checking for scripts in the `scripts/` dir.+ */++declare module "trilium:preact" {+ export {+ Component,+ Fragment,+ createContext,+ createElement,+ createRef,+ h,+ render,+ } from "preact";++ export {+ useCallback,+ useContext,+ useEffect,+ useLayoutEffect,+ useMemo,+ useReducer,+ useRef,+ useState,+ } from "preact/hooks";+}++declare module "trilium:api" {+ /** Run a function on the backend. The first arg is serialised. */+ export function runOnBackend<T>(fn: (...args: any[]) => T, params?: any[]): Promise<T>;++ /** Show a toast message. */+ export function showMessage(message: string, timeout?: number): void;++ /** Show an error toast. */+ export function showError(message: string, timeout?: number): void;++ /** Navigate to a note by its ID. */+ export function activateNote(noteId: string): Promise<void>;+}diff --git a/apps/script-deployer/tsconfig.json b/apps/script-deployer/tsconfig.jsonindex d362ecef09..ba7c541bde 100644--- a/apps/script-deployer/tsconfig.json+++ b/apps/script-deployer/tsconfig.json@@ -1,9 +1,11 @@{"extends": "../../tsconfig.base.json","compilerOptions": {- "composite": false,- "emitDeclarationOnly": false,- "noEmit": true+ "noEmit": true,+ "allowJs": true,+ "checkJs": true,+ "jsx": "react-jsx",+ "jsxImportSource": "preact"},- "include": ["src"]+ "include": ["src", "scripts"]}diff --git a/tsconfig.json b/tsconfig.jsonindex 9fc01bb4d7..24b4bbc51c 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -71,6 +71,9 @@},{"path": "./scripts"+ },+ {+ "path": "./apps/script-deployer"}]}