Typescript Support
At the moment typescript linting tools does not like working with nucleoid. The way I understand this is that when I register a class I get static helper methods on the class in runtime but these do not exist in the code itself, nor their type declarations.
class User {
constructor(public name: string) {
this.name = name;
}
}
nucleoid.register(User);
app.get("/user", () => User.filter(() => /* */));
So something like this will throw an error like Property 'filter' does not exist on type 'typeof User'.
Are you planning to add typescript support?
Definitely, I am still vetting couple options, but the best way that I can come with extending the class like this
import nucleoid, { Prototype } from "nucleoidjs";
const app = nucleoid();
class User extends Prototype {
name: string;
constructor(name: string) {
super();
this.name = name;
}
}
app.post("/users", () => User.filter((u) => u.name === "Daphne"));
The way I understand this is that when I register a class I get static helper methods on the class in runtime but these do not exist in the code itself, nor their type declarations.
That is right, the runtime rerenders JavaScript and creates graph (all of them happens at the runtime tho). It provides some shortcuts like turning class into array in order to query like in database table. Since all of them happening at the runtime, it is quite conflicts with TypeScript, which is compile time.
I think an extendible prototype solution would be the cleanest. I would be easy to read and understand, while not clashing with ide's