Browse Source

types: simplify VMScript via Partial and indexed access

tophf 3 days ago
parent
commit
d45f1dbddb
2 changed files with 7 additions and 4 deletions
  1. 6 3
      src/background/utils/db.js
  2. 1 1
      src/options/views/edit/index.vue

+ 6 - 3
src/background/utils/db.js

@@ -565,7 +565,10 @@ const getUUID = crypto.randomUUID ? crypto.randomUUID.bind(crypto) : () => {
   return '01-2-3-4-567'.replace(/\d/g, i => (rnd[i] + 0x1_0000).toString(16).slice(-4));
 };
 
-/** @return {Promise<void>} */
+/**
+ * @param {number} id
+ * @param {DeepPartial<VMScript>} data
+ */
 export async function updateScriptInfo(id, data) {
   const script = scriptMap[id];
   for (const key in data) { // shallow merge
@@ -578,8 +581,8 @@ export async function updateScriptInfo(id, data) {
 }
 
 /**
- * @param {string | {code:string, custom:VMScript.Custom}} src
- * @return {{ meta: VMScript.Meta, errors: string[] }}
+ * @param {string | {code:string, custom:VMScript['custom']}} src
+ * @return {{ meta: VMScript['meta'], errors: string[] }}
  */
 function parseMetaWithErrors(src) {
   const isObj = isObject(src);

+ 1 - 1
src/options/views/edit/index.vue

@@ -140,7 +140,7 @@ const toEnum = val => val || null; // `null` removes the prop from script object
 const K_PREV_PANEL = 'Alt-PageUp';
 const K_NEXT_PANEL = 'Alt-PageDown';
 const compareString = (a, b) => (a < b ? -1 : a > b);
-/** @param {VMScript.Config} config */
+/** @param {VMScript['config']} config */
 const collectShouldUpdate = ({ shouldUpdate, _editable }) => (
   +shouldUpdate && (shouldUpdate + _editable)
 );