diff --git a/index.ts b/index.ts index dba5362..a5f7c6d 100644 --- a/index.ts +++ b/index.ts @@ -246,13 +246,13 @@ class OptionsSync { await saveFile(text, extension.name + ' options.json'); }; - private _log(method: 'log' | 'info', ...args: any[]): void { + private _log(method: 'log' | 'info', ...args: unknown[]): void { console[method](...args); } private async _getAll(): Promise { const result = await this.storage.get(this.storageName); - return this._decode(result[this.storageName]); + return this._decode(result[this.storageName] as UserOptions); } private async _setAll(newOptions: UserOptions): Promise { @@ -352,13 +352,13 @@ class OptionsSync { return serialize(form, {include}); } - private readonly _handleStorageChangeOnForm = (changes: Record, areaName: string): void => { + private readonly _handleStorageChangeOnForm = (changes: Record, areaName: string): void => { if ( areaName === this.storageType - && changes[this.storageName] + && this.storageName in changes && (!document.hasFocus() || !this._form!.contains(document.activeElement)) // Avoid applying changes while the user is editing a field ) { - this._updateForm(this._form!, this._decode(changes[this.storageName].newValue)); + this._updateForm(this._form!, this._decode(changes[this.storageName]!.newValue as string)); } }; } diff --git a/package.json b/package.json index 630e93c..0c18702 100644 --- a/package.json +++ b/package.json @@ -49,24 +49,24 @@ }, "dependencies": { "dom-form-serializer": "^2.0.0", - "lz-string": "^1.4.4", + "lz-string": "^1.5.0", "throttle-debounce": "^5.0.0", - "webext-detect-page": "^4.0.1", - "webext-events": "^1.1.0", - "webext-polyfill-kinda": "^1.0.0" + "webext-detect-page": "^4.1.1", + "webext-events": "^2.0.0", + "webext-polyfill-kinda": "^1.0.2" }, "devDependencies": { - "@sindresorhus/tsconfig": "^3.0.1", - "@types/chrome": "0.0.210", + "@sindresorhus/tsconfig": "^4.0.0", + "@types/chrome": "0.0.246", "@types/lz-string": "^1.3.34", "@types/throttle-debounce": "^5.0.0", - "@types/wicg-file-system-access": "^2020.9.5", - "ava": "^5.1.1", + "@types/wicg-file-system-access": "^2020.9.6", + "ava": "^5.3.1", "npm-run-all": "^4.1.5", - "sinon": "^15.0.1", + "sinon": "^16.0.0", "sinon-chrome": "^3.0.1", - "type-fest": "^3.5.3", - "typescript": "^4.9.4", - "xo": "^0.53.1" + "type-fest": "^4.3.1", + "typescript": "^5.2.2", + "xo": "^0.56.0" } } diff --git a/test/index.js b/test/index.js index a5d09fd..d852289 100644 --- a/test/index.js +++ b/test/index.js @@ -168,7 +168,7 @@ test.serial('migrations alter the stored options', async t => { savedOptions.size += 10; }, savedOptions => { - if (typeof savedOptions.size !== 'undefined') { + if (savedOptions.size !== undefined) { savedOptions.minSize = savedOptions.size; delete savedOptions.size; }