InstantSplit/TROUBLESHOOTING.md
2025-06-21 23:30:33 +03:00

4.8 KiB

InstantSplit Troubleshooting Guide

Common Issues and Solutions

Updated Store Error Fixes

We've fixed several TypeScript errors in the following files:

  1. src/lib/utils/currencyHelper.js

    • Fixed type handling for parameters to accept both string and number types
    • Added proper type annotations in JSDoc comments
  2. src/lib/stores/contactsStore.js

    • Fixed StrKey import from @stellar/stellar-sdk
    • Fixed state structure to maintain proper contacts array
    • Fixed circular reference in the lookup method
    • Ensured consistent state updates that maintain the required structure

1. Missing Export: contactsStore

Error:

✘ [ERROR] No matching export in "src/lib/stores/contactsStore.js" for import "contactsStore"

Solution: Make sure the contactsStore.js file properly exports the contactsStore variable:

// At the end of the file
export const contactsStore = createContactsStore();

2. DashboardLayout Import Path

Error:

Failed to resolve import "../dashboard/components/DashboardLayout.svelte" from "src/routes/split/+layout.svelte"

Solution: Use the absolute path from the routes directory:

import DashboardLayout from '../../routes/dashboard/components/DashboardLayout.svelte';

3. A11y: Form Label Accessibility Issues

Error:

A11y: A form label must be associated with a control.

Solution: Make sure all form labels have a corresponding "for" attribute that matches the ID of the input element:

<label for="split-method-selector">How do you want to split this?</label>
<input id="split-method-selector" ... />

4. NPM Vulnerabilities

Error:

10 vulnerabilities (3 low, 6 moderate, 1 critical)

Solution: Run the vulnerability fix script:

chmod +x fix-vulnerabilities.sh
./fix-vulnerabilities.sh

For more severe issues that require breaking changes:

npm audit fix --force

5. Outdated Browserslist Database

Error:

Browserslist: browsers data (caniuse-lite) is 8 months old

Solution: Update the browserslist database:

npx update-browserslist-db@latest

Additional Issues

Node.js Version Compatibility

If you encounter errors related to Node.js compatibility, ensure you're using Node.js v16 or higher:

nvm install 16
nvm use 16
npm install --legacy-peer-deps

Missing Dependencies

If you encounter errors about missing dependencies:

npm install --legacy-peer-deps uuid date-fns qrcode

TypeScript/Type Checking Issues

If you encounter TypeScript errors but want to proceed with development:

  1. Temporarily disable strict type checking in jsconfig.json:
"strict": false,
"noImplicitAny": false
  1. Or add proper type annotations to the problematic files.

TypeScript and Node.js Integration Issues

Node.js Type Errors

If you encounter TypeScript errors related to Node.js types:

Cannot find name 'require'. Do you need to install type definitions for node?
Cannot find name 'Buffer'. Do you need to install type definitions for node?

Run the provided installation script:

chmod +x install-node-types.sh
./install-node-types.sh

Browser-specific Property Errors

For errors like:

Property 'QRCode' does not exist on type 'Window & typeof globalThis'

These have been fixed by safely accessing properties through bracket notation:

// Instead of window.QRCode
const qrConstructor = window['QRCode'];

Environment Detection

The application now properly detects the environment and uses appropriate methods:

  • In the browser: Uses btoa() and the browser's QRCode library if available
  • In Node.js: Avoids direct use of Node.js APIs to prevent TypeScript errors

This makes the code compatible with both browser and server-side rendering environments.

TypeScript Store Methods Issues

Error: Property 'methodName' does not exist on type 'Writable'

When using custom Svelte stores with methods in TypeScript components, you may encounter errors like:

Property 'addParticipant' does not exist on type 'Writable<ExpenseStore>'

This happens because TypeScript doesn't recognize the custom methods added to the store.

Solution:

  1. We've created type definitions in .d.ts files for our stores:

    • expenseStore.d.ts
    • Type interfaces like ExpenseStoreInterface
  2. In your components, use type assertion:

    import type { ExpenseStoreInterface } from '$lib/stores/expenseStore';
    const typedExpenseStore = expenseStore as ExpenseStoreInterface;
    
  3. Then use the typed store to call methods:

    typedExpenseStore.addParticipant();
    

This allows TypeScript to recognize the store methods while maintaining full functionality.