Usage
On this page, you can find information on how you can import and use the library in your project.
Accessing types
Section titled “Accessing types”Import from obsidian
Section titled “Import from obsidian”If you want to access types from the obsidian module, the import syntax is unchanged:
import { App } from 'obsidian';
function printInternalPlugins(app: App): void { console.log(app.internalPlugins);}Import from @obsidian-typings/obsidian-public-latest
Section titled “Import from @obsidian-typings/obsidian-public-latest”Additional interfaces added by this package (which are not documented anywhere in the official API) can be imported using:
import { InternalPlugins } from '@obsidian-typings/obsidian-public-latest';
const internalPlugins: InternalPlugins = this.app.internalPlugins;Extend with your own typings
Section titled “Extend with your own typings”If you need to extend the typings provided by this package with your own types,
add the following to any .d.ts file in your project:
// This is a very essential line.// If you don't have any other top-level `import/export` statements,// the typings listed below will work not as expected.export {};declare module '@obsidian-typings/obsidian-public-latest' { interface PluginsPluginsRecord { myPlugin: MyPlugin; }}The package ships a CommonJS copy and an ES-module copy of its declarations, and the augmentation has to target the copy your project loaded. A module augmentation does not load the file it targets, so an augmentation aimed at the other copy compiles without an error and changes nothing.
Using implementations
Section titled “Using implementations”Via /implementations
Section titled “Via /implementations”Additional helper functions/types/… added by this package, can be added by importing from the /implementations subpath:
import { InternalPluginName } from '@obsidian-typings/obsidian-public-latest/implementations';
this.app.internalPlugins.getEnabledPluginById(InternalPluginName.FileExplorer);(The list of all available implementations can be found in the implementations folder.)