Coder Social home page Coder Social logo

trilium-types's Introduction

trilium-types

A TypeScript @types package for Trilium Notes.

Installation

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

Usage

Please note: These types were made for the latest version of Trilium (v0.61) which adds the attachments feature. If you're developing for the stable release (v0.60) you can still use these types, just avoid or ignore anything related to attachments.

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.

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!

trilium-types's People

Contributors

rauenzi avatar

Stargazers

 avatar Mic avatar Kaiden Howard avatar itsallpretend avatar Chris Rutherford avatar Justyn Shull avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.