No type info on model query find* response
Closed this issue · 3 comments
vasyas commented
Hi!
I've followed the steps in README.md but got an issue with the type of model query response.
Having the table types:
interface Users {
id: Generated<number>;
name: string;
email: string;
}
interface DB {
users: Users;
};
and the model defined:
export default class User extends db.model('users', 'id') {
static findByEmail(email: string) {
return this.findOne('email', email);
}
}
My query doesn't have return type info, which is breaking type-safety in queries:
import User from "./User"
async function demo() {
const user = await User.findByEmail("aa")
console.log(user.aaa) // should fail here, b/c User doesn't have `aaa` field?
}
Is this expected to be working?
vasyas commented
More info for it.
- It is reproducible only for find* methods
- It is reproducable only latest kysely release, 0.23.5.
seeden commented
I will check it with last version but I am working on something else these days.
seeden commented
Fixed in latest version