我正在使用
electron-store
进行演示电子项目。在我的 main.ts
过程中,我尝试初始化存储并检索一个简单的设置对象。看起来像这样:
// main.ts
import Store, { Schema } from 'electron-store';
type settingsType = {
settings: {
environment: 'development' | 'test' | 'prod',
refreshInterval: number,
}
}
const schema: Schema<settingsType> = {
settings: {
type: 'object',
properties: {
environment: {
type: 'string',
enum: ['development', 'test', 'prod'],
default: 'development',
},
refreshInterval: {
type: 'number',
minimum: 10000, // ten seconds
maximum: 600000, // ten min
default: 60000, // one min
}
},
default: {},
required: ['environment', 'refreshInterval'],
}
}
const store = new Store<settingsType>({schema});
// ERROR: TS2339: Property 'get' does not exist on type 'ElectronStore<settingsType>'.
let settingsStore: settingsType = store.get('settings');
我认为我正在按预期定义所有内容,但我仍然从
TS
调用中收到 store.get
错误。我错过了什么?