So, I did it, trdb the json file database can now be used with pure js types. The trdb library is implemented using typescript. As before, the lib can be used with javascript. But how, it is possible to provide a type to a collection and in vsCode or other editors and IDEs with typescript support we can now have nice autocompletion hints.

With Typescript, it was already possible to pass a type to the collection method, but now this is also possible in pure JS. I did that with a second optional argument. Look at the following example

And here is how I did it, before function signature for creating a collection looked like this:

Now, it has changed to this:

And this is all that has changed for version 0.0.5. only the function declaration has changed. Using typescript it is still better to use the collection method traditionally like: const userCollection = db.collection<IUser>('user');. However in javascript you can provide types, and even constructed types like shown above. The module, otherwise did not change in this version. The example

I think this is a great example, how javascript developers actually can greatly profit from typescript, without actually using it.

back to developer log