From 65d8976a7a48ae4d7e0f4f8795948949f8397dba Mon Sep 17 00:00:00 2001 From: nikolawork <193513616+nikolawork@users.noreply.github.com> Date: Tue, 18 Aug 2026 09:16:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#75156=20[toastr]?= =?UTF-8?q?=20Model=20toastr=20as=20a=20UMD=20export=20instead=20of=20an?= =?UTF-8?q?=20ambient=20global=20by=20@nikolawork?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/toastr/index.d.ts | 8 ++++---- types/toastr/toastr-global-module-tests.ts | 10 ++++++++++ types/toastr/toastr-tests.ts | 4 ++++ types/toastr/tsconfig.json | 3 ++- 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 types/toastr/toastr-global-module-tests.ts diff --git a/types/toastr/index.d.ts b/types/toastr/index.d.ts index f3e069bb2305ab..1e598539dbc78e 100644 --- a/types/toastr/index.d.ts +++ b/types/toastr/index.d.ts @@ -355,7 +355,7 @@ interface Toastr { subscribe: (callback: (response: ToastrResponse) => void) => void; } -declare var toastr: Toastr; -declare module "toastr" { - export = toastr; -} +declare const toastr: Toastr; + +export = toastr; +export as namespace toastr; diff --git a/types/toastr/toastr-global-module-tests.ts b/types/toastr/toastr-global-module-tests.ts new file mode 100644 index 00000000000000..1000bb664a5640 --- /dev/null +++ b/types/toastr/toastr-global-module-tests.ts @@ -0,0 +1,10 @@ +// This file has no imports, so use a dummy export to mark this file as a module. +export {}; + +// @ts-expect-error - UMD global usage should be prohibited inside modules +toastr.success("Module files should import toastr explicitly."); + +// Explicit global access remains available for script-tag consumers. +const globalToast: JQuery = globalThis.toastr.success("The UMD value is available on the global object."); +globalThis.toastr.options.closeButton = true; +globalThis.toastr.clear(globalToast); diff --git a/types/toastr/toastr-tests.ts b/types/toastr/toastr-tests.ts index d60490d97677b9..1038abd1a6a596 100644 --- a/types/toastr/toastr-tests.ts +++ b/types/toastr/toastr-tests.ts @@ -1,3 +1,7 @@ +import toastr = require("toastr"); + +type ToastrOptions = typeof toastr.options; + declare let displayMethodStr: "success" | "info" | "warning" | "error"; declare let undefinedVal: undefined; declare let booleanVal: boolean; diff --git a/types/toastr/tsconfig.json b/types/toastr/tsconfig.json index 6312e5a61cd42f..431989aa24e078 100644 --- a/types/toastr/tsconfig.json +++ b/types/toastr/tsconfig.json @@ -15,6 +15,7 @@ }, "files": [ "index.d.ts", - "toastr-tests.ts" + "toastr-tests.ts", + "toastr-global-module-tests.ts" ] }