mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 23:05:51 +01:00
refactor(react/widgets): typings for dynamic require + solve type errors
This commit is contained in:
@@ -311,7 +311,13 @@ function copySelectionToClipboard() {
|
||||
}
|
||||
}
|
||||
|
||||
export function dynamicRequire(moduleName: string) {
|
||||
const dynamicRequireMappings = {
|
||||
"@electron/remote": import("@electron/remote"),
|
||||
"electron": import("electron"),
|
||||
"child_process": import("child_process")
|
||||
};
|
||||
|
||||
export function dynamicRequire<T extends keyof typeof dynamicRequireMappings>(moduleName: T): Awaited<typeof dynamicRequireMappings[T]>{
|
||||
if (typeof __non_webpack_require__ !== "undefined") {
|
||||
return __non_webpack_require__(moduleName);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user