npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

obsidian-typings

v1.1.1

Published

Extended type definitions for the Obsidian API (https://obsidian.md)

Downloads

423

Readme

Obsidian Extended Typings




This repository contains TypeScript typings for undocumented Obsidian API functions and variables and additional descriptions, essentially extending the official Obsidian API.

Be aware that the typings currently only cover a subset of all methods: most of the App interface and its sub-interfaces are covered, but typings for views like Graph, Canvas, ... are still missing -- contributions for these would be very welcome!

Installation

There are three options for installing this package:

  1. Explicit type importing Each typing has to be imported explicitly from obsidian-typings instead of obsidian, e.g. import {App, MarkdownView} from "obsidian-typings". Install via: npm install --save-dev obsidian-typings

  2. Automatic type extending (recommended) The typings are automatically added to the existing obsidian module, so you can use them without any changes to your code. Install via: npm install --save-dev @types/obsidian-typings@npm:obsidian-typings.

  3. Add extended typings as submodule Your IDE will likely pick up the typings automatically when the project is added as a submodule for your plugin, this also makes it simpler to test and submit features to the repository. Install via: git submodule add https://github.com/Fevol/obsidian-typings.git typings (or any other folder)

[!WARNING] If your IDE or TS compiler is not able to pick up the types from obsidian-typings but they were installed properly, you will need to adapt your tsconfig.json as follows:

{
    "compilerOptions": {
        ...
        "types": [
            "obsidian-typings"
        ]
    }
}

(Add "obsidian-typings" to the types array for compilerOptions)

Disclaimer

[!WARNING] Make sure to read below section in detail before using these typings.

Please be aware that there is a good reason why (some of) the functions and types defined here are not included with the official API definitions:

  • The methods are not fully defined, and will be changed or removed in the near-future
  • There is a high risk of the code behaving unexpectedly if used improperly
  • The function was never meant to be used

Please use the functions and variables provided with caution. Be prepared to update your code if the API changes, and only use the functions if you are confident that you understand what they will do. Reference the official API first to see if your problem may be solved with a documented function, or search in the #plugin-dev channel of the Obsidian Discord server. Some functions will also contain @remark TSDoc tags that provide alternatives or better solutions.

Methods marked @internal are especially risky to use: these are either not fully typed yet, or are solely intended to be used internally by the Obsidian app.

Furthermore, there is a very high chance that there are mistakes in the typings, despite best efforts. All types had to be deduced from either context, manually running the function, or from the minified app code. You should verify that the code behaves as expected, both with regard to the expected (input/output)types, as well as what the function description promises.

With these scary disclaimers out of the way, hopefully these typings will help you in removing 90% of the @ts-ignores you have in your codebase, or discover solutions that didn't seem possible before.

[!NOTE] TL;DR: Use at your own risk, verify that the code behaves as expected, and be prepared to update your code if the API changes.

@internal methods are especially risky to use.

@remark tags give some warnings about the inputs/outputs of the function, or provide better alternatives.

@tutorial gives additional information on how to use the function in your plugin.

Contributing

Feel free to start typing any part of the Obsidian API that is not yet typed, or fixing/adding additional descriptions to existing typings. If you are unsure about anything, don't hesitate to open an issue.

A brief tutorial is available on how you can get started with adding new typings, or fixing existing ones, see: CONTRIBUTING.md.