这是我的window.ts
import Vue from 'vue'
interface BrowserWindow extends Window {
app: Vue
}
const browserWindow = window as BrowserWindow
export default browserWindow
我在编译时不断收到此错误
TS2352: Conversion of type 'Window & typeof globalThis' to type 'BrowserWindow' may
be a mistake because neither type sufficiently overlaps with the other. If this was intentional,
convert the expression to 'unknown' first.
Property 'app' is missing in type 'Window & typeof globalThis' but required in type 'BrowserWindow'.
答案 0 :(得分:1)
如错误消息所述,将windows
强制转换为unknown
,然后强制转换为BrowserWindow
:
const browserWindow = window as unknown as BrowserWindow