Skip to content

v5.0.0

Choose a tag to compare

@DimaZhukovsky DimaZhukovsky released this 12 Sep 13:29
· 62 commits to master since this release

Breaking Change: TypeScript Types Now Separated by Case Style

What changed: snake_case and camelCase types are no longer merged. You must now choose one style per client instance.

Affected: TypeScript users only. JavaScript users are unaffected.

Migration Guide

Default usage (snake_case)

// Before
const account = await swell.account.get();
account.first_name; // worked
account.firstName;  // also worked

// After: 
const account = await swell.account.get();
account.first_name; // works
account.firstName;  // TypeScript error

CamelCase usage

// Before
swell.init('store', 'key', { useCamelCase: true });
const account = await swell.account.get();
account.first_name; // worked (incorrectly)

   // After - Option 1: Type assertion
import swell from 'swell-js';
import type { SwellClient } from 'swell-js';
const camelSwell = swell as SwellClient<'camel'>;
camelSwell.init('store', 'key', { useCamelCase: true });

// After - Option 2: Create typed instance
import swell from 'swell-js';
const camelSwell = swell.create('store', 'key', { useCamelCase: true });

Why: Improved type safety. TypeScript now correctly enforces the case style you're actually using.

Keep using v4 until ready to migrate.