You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't have enough SDK capabilities and I wrote a universal repository that I use for the entire project.
Here is its MAXimally simplified version with one method with vanilla SDK:
The typing error will be resolved (I'm not sure, because this is a stripped-down version of the code, but it should). But the price of this is the loss of Code Intelligence:
To solve this problem for myself, I use this crutch solution:
import type { PreparedQuery } from "surrealdb";
import { Surreal } from "surrealdb";
export class FixedSurreal extends Surreal {
async query<T>(query: string | PreparedQuery, bindings?: Record<string, unknown>) {
const result = await super.query(query, bindings) as unknown as T[];
return result[0];
}
//...
}
I use result[0] because all my queries are always a single transaction.
But it would be better if I didn't have to use this solution at all and everything worked correctly.
Describe the bug
The issue revolves around the use of Record<string, unknown> in the generic signatures:
Steps to reproduce
I don't have enough SDK capabilities and I wrote a universal repository that I use for the entire project.
Here is its MAXimally simplified version with one method with vanilla SDK:
But you can add extends to BaseRecord:
The typing error will be resolved (I'm not sure, because this is a stripped-down version of the code, but it should). But the price of this is the loss of Code Intelligence:
You can read more here TypeScript/issue
This code:
Expected behaviour
To solve this problem for myself, I use this crutch solution:
I use result[0] because all my queries are always a single transaction.
But it would be better if I didn't have to use this solution at all and everything worked correctly.
SurrealDB version
Surreal 1.0.0
SurrealDB.js version
0.11.0
Contact Details
vlad.logvin84@gmail.com
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: