Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions types/toastr/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 10 additions & 0 deletions types/toastr/toastr-global-module-tests.ts
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 4 additions & 0 deletions types/toastr/toastr-tests.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion types/toastr/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"files": [
"index.d.ts",
"toastr-tests.ts"
"toastr-tests.ts",
"toastr-global-module-tests.ts"
]
}