Describe the bug
https://github.com/surrealdb/surrealdb.js/blob/main/packages/sdk/src/types/live.ts#L19
LiveSubscription<T> is generic, but LiveMessage is not — value is hardcoded as Record<string, unknown>, so the type parameter T passed to db.live<T>() never reaches the subscriber callback. This forces consumers to cast r.value even though the type is known at the call site.
Steps to reproduce
const l = await db.live<Booking & { object: Object }>(new Table('booking'));
let unsub: () => void;
export const CalendarStore = signalStore(
{ providedIn: 'root' },
withEntities<Booking & { object: Object }>(),
withHooks(s => ({
onInit: async () => {
const data = await db
.select<Booking & { object: Object }>(new Table('booking'))
.fetch('object');
patchState(s, setAllEntities(data, { selectId: e => e.id.toString() }));
unsub = l.subscribe(async r => {
if (r.action === 'DELETE') {
patchState(s, removeEntity(r.recordId.toString()));
} else if (r.action === 'CREATE' || r.action == 'UPDATE') {
patchState(
s,
upsertEntity(r.value, { selectId: e => e.id.toString() }),
);
}
});
},
onDestroy: unsub,
})),
);
Expected behaviour
LiveMessage<T> with value: T
Actual: LiveMessage with value: Record<string, unknown>
SurrealDB version
3.2.0-dev
JavaScript SDK version
2.0.8
Contact Details
No response
Is there an existing issue for this?
Code of Conduct (repository /surrealdb.js)
Describe the bug
https://github.com/surrealdb/surrealdb.js/blob/main/packages/sdk/src/types/live.ts#L19
LiveSubscription<T>is generic, but LiveMessage is not — value is hardcoded as Record<string, unknown>, so the type parameterTpassed todb.live<T>()never reaches the subscriber callback. This forces consumers to castr.valueeven though the type is known at the call site.Steps to reproduce
Expected behaviour
LiveMessage<T>withvalue: TActual:
LiveMessagewithvalue: Record<string, unknown>SurrealDB version
3.2.0-dev
JavaScript SDK version
2.0.8
Contact Details
No response
Is there an existing issue for this?
Code of Conduct (repository /surrealdb.js)