Problem
I’m working on a plugin for Obsdian and couldn’t figure out why a particular setting was getting mangled. Turns out, you have to delete the data.json
file if you update your settings type.
The plugin is for self destructing notes, and right now it has two settings. They used to look like this:
type Interval = 'daily' | 'weekly'
interface SelfDestructPluginSettings {
deletionInterval: Interval;
checkInterval: number;
}
I learned that Obsidian uses moment.js for intervals, and that it has a built in duration type. I wanted to switch my settings to look like this:
interface SelfDestructPluginSettings {
deletionInterval: moment.Duration;
checkInterval: moment.Duration;
}
Making that change blew up a bunch of things, and it turns out that it’s because Obsidian stores plugin data in a data.json
file in your plugin’s directory. For the pre-moment
types, the settings look like this:
{
"deletionInterval": "weekly",
"checkInterval": 1000
}
moment.js
stores durations in ISO-8601 format, so when loading the old settings, nothing would parse.
Solution
Removing the data.json
file and letting Obsidian recreate it worked.