【发布时间】:2023-01-26 03:43:12
【问题描述】:
import { app } from "electron"
app.foo = "bar" // Property 'foo' does not exist on type 'App'.ts(2339)
如果我使用//@ts-ignore,以上工作。
【问题讨论】:
标签: typescript electron
import { app } from "electron"
app.foo = "bar" // Property 'foo' does not exist on type 'App'.ts(2339)
如果我使用//@ts-ignore,以上工作。
【问题讨论】:
标签: typescript electron
您可以在私有名称下导入 app,然后在内部将其类型转换为您喜欢的任何名称。
import { app as _app } from "electron"
interface MyCustomProperties {
foo: string;
}
const app = _app as (typeof _app & MyCustomProperties);
app.foo = "bar";
【讨论】:
.d.ts 文件来实现吗?