Home

Awesome

trilium-types

A TypeScript @types package for Trilium Notes.

Installation

npm install @types/trilium@npm:trilium-types

Usage

This package keeps up with the latest version of Trilium available, there is not existing table or mapping showing old version of this package that correspond to old version of Trilium.

TypeScript

The Trilium frontend api will automatically be available in all files since working with the frontend is the most common use-case. You can easily override this with the backend api if needed:

import {BackendAPI} from "trilium/backend";

declare const api: BackendAPI;

Otherwise, all the types should be available under trilium/frontend, trilium/backend, and trilium/common.

JavaScript

Similarly to in TypeScript, your IDE (like VSCode) should automatically pick up api as the frontend. You can override this using JSDoc syntax. First, make sure your IDE and/or linter are setup to allow an api global, then you can do.

/**
 * @type {import("trilium/backend").BackendAPI}
 */
const api = api;

For other types, you can follow the same methodology and use the JSDoc syntax with import.

Why?

Because it's nice to have autocompletion and type recognition whether you're using JS or TS.

Why not DefinitelyTyped?

I chose not to try to push this to DefinitelyTyped because I'm still an amateur when it comes to TypeScript and writing custom type definitions. They tend to have a quality requirement that I don't think I would meet.

Links

Check out my other Trilium-based projects:

Want more? Be sure to check out the Awesome Trilium list!