Skip to content

Convert backend to TypeScript #4937

@eliandoran

Description

@eliandoran

Discussed in https://github.com/orgs/TriliumNext/discussions/4

Originally posted by eliandoran February 14, 2024
This is a bit of a reply to some of the replies in #4646 regarding type management, but it's actually something I've thought for some time now.

I don't think rewriting the server to Rust is currently a good candidate due to the sheer difficulty of implementing such a change. Nevertheless, we can consider for the future an approach I saw in NextCloud: rewrite in Rust (or other high-performance language) only the most performance-sensitive stuff. In our case it would be most likely the search and tree functionality.

To me, adding types to Trilium is almost mandatory. And the sole reason to that is that types makes it easier to navigate through a repository where you don't know everything about it. I've worked with JavaScript projects before and as soon as the application grows in complexity to anymore more than trivial, it becomes hard to navigate through it once you start forgetting all the details about the implementation.

When it comes to adding types, there are really only two possibilities that would make sense: JSDoc and TypeScript. For me, I'm not very fond of JSDoc since I found it to be a bit unwieldy compared to TypeScript. Also important is that TypeScript introduces some safety features that are really helpful: for example checks for nullish values, and of course any type inconsistencies.

Feel free to pitch in if you have any ideas or if you agree or disagree to this.

cc. @rom1dep @rauenzi @meichthys

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions