From 7d0d996b94030e0b95beeb72f531d39cd3622c8d Mon Sep 17 00:00:00 2001 From: Mathias Stang Date: Fri, 22 May 2026 10:24:46 +0200 Subject: [PATCH] Add TrustContext type to TypeScript definitions Replaces the `any` type in the `trust` option callback with a proper discriminated union `TrustContext` type covering all supported commands (`\class`, `\id`, `\style`, `\data`, `\includegraphics`). --- temml.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/temml.d.ts b/temml.d.ts index 7ed1f01..09ee2bb 100644 --- a/temml.d.ts +++ b/temml.d.ts @@ -1,3 +1,10 @@ +export type TrustContext = + | { command: "\\class"; class: string } + | { command: "\\id"; id: string } + | { command: "\\style"; style: string } + | { command: "\\data"; attributes: Record } + | { command: "\\includegraphics"; url: string; protocol?: string }; + export interface Options { displayMode?: boolean; annotate?: boolean; @@ -9,7 +16,7 @@ export interface Options { xml?: boolean; colorIsTextColor?: boolean; strict?: boolean; - trust?: boolean | ((context: any) => boolean); + trust?: boolean | ((context: TrustContext) => boolean); maxSize?: [number, number]; maxExpand?: number; }