tridactyl/src/background/editor.ts
Oliver Blanthorn 5092be9e36
Remove .ts from imports
Webpack supports it but TypeScript does not
2021-05-01 12:57:38 +02:00

19 lines
619 B
TypeScript

import { messageActiveTab } from "@src/lib/messaging"
import * as _EditorCmds from "@src/lib/editor"
type cmdsType = typeof _EditorCmds
type ArgumentsType<T> = T extends (elem, ...args: infer U) => any ? U : never
export const EditorCmds = new Proxy(_EditorCmds as any, {
get(target, property) {
if (target[property]) {
return (...args) =>
messageActiveTab("editorfn_content", property as string, args)
}
return target[property]
},
}) as {
[k in keyof cmdsType]: (
...args: ArgumentsType<cmdsType[k]>
) => Promise<ReturnType<cmdsType[k]>>
}