Skip to content

Getting Started

Obsidian Typings is a TypeScript library that provides type definitions for private parts of the Obsidian API. This project is not officially affiliated with Obsidian.

Prerequisites

You will need to have a plugin template set up with a package manager and TypeScript. If you don’t have one yet, follow the “Build a plugin” guide in the official Obsidian docs to create one.

Installation

  1. Installation
    Obsidian Typings is a NPM package that you can install using your favorite package manager:

    Terminal window
    npm i -D obsidian-typings
  2. Add obsidian-typings to types in tsconfig.json (recommended)
    Register the types from obsidian-typings to your project with the tsconfig.json file.

    tsconfig.json
    {
    "compilerOptions": {
    "...": "...",
    "types": [
    "obsidian-typings"
    ]
    }
    }
  3. Explicit type importing
    If you prefer not to add obsidian-typings to your types, you can also add import 'obsidian-typings'; to any project file.

  4. Using obsidian-typings/implementations
    Depending on how your project is set up, import { X } from 'obsidian-typings/implementations'; may not work straight out of the box, e.g., if you have "moduleResolution": "node" or "node10" in your tsconfig.json.

    To solve this, you can add the following to your tsconfig.json:

    tsconfig.json
    {
    "compilerOptions": {
    "...": "...",
    "paths": {
    "obsidian-typings/implementations": [
    "./node_modules/obsidian-typings/dist/implementations.d.ts",
    "./node_modules/obsidian-typings/dist/implementations.cjs"
    ]
    }
    }
    }

That’s it! Now the type definitions should be accessible in your project.