import { Emitter, Engine, Surreal, type EngineEvents } from 'surrealdb.js';
import { surrealdbWasmEngines } from 'surrealdb.wasm';
const db = new Surreal({
engines: surrealdbWasmEngines({
strict: false,
capabilities: {
guest_access: true,
functions: true,
network_targets: true,
},
}),
});
gives a type error:
Type '{ mem: new (emitter: Emitter<EngineEvents>) => { ready: Promise<void> | undefined; reader?: Promise<void> | undefined; status: ConnectionStatus; ... 8 more ...; readonly connected: boolean; }; indxdb: new (emitter: Emitter<...>) => { ...; }; }' is not assignable to type 'Engines'.
Property 'mem' is incompatible with index signature.
Type 'new (emitter: Emitter<EngineEvents>) => { ready: Promise<void> | undefined; reader?: Promise<void> | undefined; status: ConnectionStatus; ... 8 more ...; readonly connected: boolean; }' is not assignable to type 'new (emitter: Emitter<EngineEvents>) => Engine'.
Construct signature return types '{ ready: Promise<void> | undefined; reader?: Promise<void> | undefined; status: ConnectionStatus; connection: { url?: URL | undefined; namespace?: string | undefined; database?: string | undefined; token?: string | undefined; }; ... 7 more ...; readonly connected: boolean; }' and 'Engine' are incompatible.
The types of 'rpc' are incompatible between these types.
Type '<Method extends string, Params extends unknown[], Result extends unknown>(request: RpcRequest<Method, Params>) => Promise<RpcResponse<Result>>' is not assignable to type '<Method extends string, Params extends unknown[] | undefined, Result extends unknown>(request: RpcRequest<Method, Params>) => Promise<RpcResponse<Result>>'.
Types of parameters 'request' and 'request' are incompatible.
Type 'RpcRequest<Method, Params>' is not assignable to type 'RpcRequest<Method, unknown[]>'.
Type 'Params' is not assignable to type 'unknown[]'.
Type 'unknown[] | undefined' is not assignable to type 'unknown[]'.
Type 'undefined' is not assignable to type 'unknown[]'.ts(2322)
Describe the bug
This:
gives a type error:
because type
Engine
has a methodwhich is
for both
mem
andindxdb
Steps to reproduce
Expected behaviour
Should not error out. Currently, I use the following fix:
SurrealDB version
surrealdb.js: 1.0.0-beta.9, surrealdb.wasm: 1.0.0-beta.12
Contact Details
dmitrii.a.baranov@gmail.com
Is there an existing issue for this?
Code of Conduct