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
-
Installation
Obsidian Typings is a NPM package that you can install using your favorite package manager:Terminal window npm i -D obsidian-typingsTerminal window yarn add -D obsidian-typingsTerminal window pnpm add -D obsidian-typingsTerminal window bun add -d obsidian-typings -
Add
obsidian-typings
totypes
intsconfig.json
(recommended)
Register the types fromobsidian-typings
to your project with thetsconfig.json
file.tsconfig.json {"compilerOptions": {"...": "...","types": ["obsidian-typings"]}} -
Explicit type importing
If you prefer not to addobsidian-typings
to yourtypes
, you can also addimport 'obsidian-typings';
to any project file. -
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 yourtsconfig.json
.
To solve this, you can add the following to yourtsconfig.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.