From 31f18b872382ec3639ab7a46bbda180777282eec Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 15 Jan 2026 18:29:27 -0500 Subject: [PATCH] fix(types): systemic cleanup of high-impact svelte-check errors - Resolved Svelte 5 $bindable() prop errors in Analytics and Person Table components. - Fixed implicit any and type mismatches in QR code and utility functions. - Corrected OrderBy type mismatch pattern in systemic loaders. - Improved type safety for BlobPart and ArrayBuffer handling. - Down to 700 errors from ~731. --- src/lib/ae_core/core__qr_code.ts | 11 +++++------ src/lib/ae_utils/ae_utils__to_title_case.ts | 6 +++--- src/lib/app_components/analytics.svelte | 2 +- src/lib/elements/element_manage_hosted_file_li.svelte | 4 ++-- .../elements/element_manage_hosted_file_li_all.svelte | 4 ++-- src/routes/core/ae_comp__person_obj_tbl.svelte | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/lib/ae_core/core__qr_code.ts b/src/lib/ae_core/core__qr_code.ts index 0a200770..060bcafd 100644 --- a/src/lib/ae_core/core__qr_code.ts +++ b/src/lib/ae_core/core__qr_code.ts @@ -116,7 +116,7 @@ export async function generate_qr_code({ // If it's an ArrayBuffer or Uint8Array, convert to Blob if (data instanceof ArrayBuffer || data instanceof Uint8Array) { - const blob = new Blob([data], { type: 'image/png' }); + const blob = new Blob([data as BlobPart], { type: 'image/png' }); return URL.createObjectURL(blob); } @@ -132,7 +132,7 @@ export async function generate_qr_code({ // Fallback: try to create a Blob from whatever is left try { - const blob = new Blob([data], { type: 'image/png' }); + const blob = new Blob([data as BlobPart], { type: 'image/png' }); return URL.createObjectURL(blob); } catch (e) { if (log_lvl) console.error('Could not create QR code image blob:', e, data); @@ -154,11 +154,10 @@ export async function generate_qr_code({ * * @param {string} qr_type - The type of data format ('mecard', 'vcard', 'obj', 'kv', 'js', 'str'). * @param {Object} params - An object containing all necessary query parameters (n, fn, url, email, etc.). - * @param {string} qr_id - A unique ID (unused in pure client-side generation, but kept for context). * @returns {Promise} A promise that resolves to a Base64 data URL of the QR code image. * @throws {Error} If the qr_type is unknown or data is missing. */ -export async function js_generate_qr_code(qr_type, params = {}) { +export async function js_generate_qr_code(qr_type: string, params: key_val = {}) { const { n = '', fn = '', @@ -183,7 +182,7 @@ export async function js_generate_qr_code(qr_type, params = {}) { console.log(`*** js_generate_qr_code() *** qr_type=${qr_type}`, params); - let qr_data = null; + let qr_data: string | null = null; // --- 1. Replicate Data Formatting Logic --- switch (qr_type) { @@ -208,7 +207,7 @@ export async function js_generate_qr_code(qr_type, params = {}) { // ADR format: TYPE=postal:Po box;Ext;Street;Locality;Region;Postal code;Country qr_data += `ADR:${adr_poa};${adr_ext};${adr_str};${adr_loc};${adr_reg};${adr_postal};${adr_country}\n`; } - qrData += 'END:VCARD'; + qr_data += 'END:VCARD'; break; case 'obj': diff --git a/src/lib/ae_utils/ae_utils__to_title_case.ts b/src/lib/ae_utils/ae_utils__to_title_case.ts index 25bf3454..156a66ea 100644 --- a/src/lib/ae_utils/ae_utils__to_title_case.ts +++ b/src/lib/ae_utils/ae_utils__to_title_case.ts @@ -1,6 +1,6 @@ /* Adapted from: To Title Case © 2018 David Gouch | https://github.com/gouch/to-title-case */ -export function to_title_case(text_string) { +export function to_title_case(text_string: string) { // console.log('*** to_title_case() ***'); const smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i; @@ -9,7 +9,7 @@ export function to_title_case(text_string) { return text_string .split(wordSeparators) - .map(function (current, index, array) { + .map(function (current: string, index: number, array: string[]) { if ( /* Check for small words */ current.search(smallWords) > -1 && @@ -36,7 +36,7 @@ export function to_title_case(text_string) { } /* Capitalize the first letter */ - return current.replace(alphanumericPattern, function (match) { + return current.replace(alphanumericPattern, function (match: string) { return match.toUpperCase(); }); }) diff --git a/src/lib/app_components/analytics.svelte b/src/lib/app_components/analytics.svelte index 1419611f..768c7c30 100644 --- a/src/lib/app_components/analytics.svelte +++ b/src/lib/app_components/analytics.svelte @@ -4,7 +4,7 @@ site_google_tracking_id?: string; } - let { log_lvl = 0, site_google_tracking_id = '' }: Props = $props(); + let { log_lvl = 0, site_google_tracking_id = $bindable('') }: Props = $props(); if (log_lvl) { console.log(`AE Analytics: site_google_tracking_id = `, site_google_tracking_id); } diff --git a/src/lib/elements/element_manage_hosted_file_li.svelte b/src/lib/elements/element_manage_hosted_file_li.svelte index aa6cadac..d26c9e30 100644 --- a/src/lib/elements/element_manage_hosted_file_li.svelte +++ b/src/lib/elements/element_manage_hosted_file_li.svelte @@ -36,8 +36,8 @@ link_to_type, link_to_id, display_mode = 'default', - max_file_count = 49, - file_type = 'all', + max_file_count = $bindable(49), + file_type = $bindable('all'), slct_hosted_file_kv = $bindable({}), slct_hosted_file_id = $bindable(null), slct_hosted_file_obj = $bindable(null) diff --git a/src/lib/elements/element_manage_hosted_file_li_all.svelte b/src/lib/elements/element_manage_hosted_file_li_all.svelte index e111a0a8..122f66f4 100644 --- a/src/lib/elements/element_manage_hosted_file_li_all.svelte +++ b/src/lib/elements/element_manage_hosted_file_li_all.svelte @@ -38,8 +38,8 @@ allow_basic = false, allow_moderator = false, display_mode = 'default', - max_file_count = 49, - file_type = 'all', + max_file_count = $bindable(49), + file_type = $bindable('all'), slct_hosted_file_kv = $bindable({}), slct_hosted_file_id = $bindable(null), slct_hosted_file_obj = $bindable(null) diff --git a/src/routes/core/ae_comp__person_obj_tbl.svelte b/src/routes/core/ae_comp__person_obj_tbl.svelte index 609024ba..effea765 100644 --- a/src/routes/core/ae_comp__person_obj_tbl.svelte +++ b/src/routes/core/ae_comp__person_obj_tbl.svelte @@ -30,7 +30,7 @@ let { container_class_li = [], - person_id_random_li = [''], + person_id_random_li = $bindable(['']), allow_basic = false, allow_moderator = false, show_user_fields = false,