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.
This commit is contained in:
@@ -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<string>} 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':
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
})
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user