fix: enable strict mode and fix TypeScript errors

Update tsconfig.json for TypeScript 5.9+ compatibility:
- Remove deprecated baseUrl, use moduleResolution "bundler"
- Enable strict mode to match IDE settings
- Scope include to src/**/*.ts

Fix strict mode violations across codebase.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@gapmiss 2026-06-06 14:31:46 -05:00
parent dcde16861f
commit a03e81ed06
7 changed files with 26 additions and 23 deletions

View file

@ -4,8 +4,7 @@ import {
MarkdownPostProcessorContext,
Editor,
MarkdownView,
Notice,
Menu
Notice
} from 'obsidian';
import {
InlineCalloutsSettings,
@ -33,7 +32,7 @@ interface ContextData {
export default class InlineCalloutsPlugin extends Plugin {
settings: InlineCalloutsSettings;
settings!: InlineCalloutsSettings;
public postprocessor: MarkdownPostProcessor = (el: HTMLElement, _ctx: MarkdownPostProcessorContext) => {
const blockToReplace = el.querySelectorAll('code')
@ -82,14 +81,17 @@ export default class InlineCalloutsPlugin extends Plugin {
id: "modify",
name: "Modify inline callout",
icon: "form-input",
editorCheckCallback: (checking, editor, view: MarkdownView) => {
editorCheckCallback: (checking, editor, ctx) => {
if (!this.settings.enableEditing) {
return false;
}
const res = this.checkContextType(editor, view);
if (!(ctx instanceof MarkdownView)) {
return false;
}
const res = this.checkContextType(editor, ctx);
if (res) {
if (!checking) {
this.modifyInlineCallout(editor, view);
this.modifyInlineCallout(editor, ctx);
}
return true;
}
@ -108,21 +110,22 @@ export default class InlineCalloutsPlugin extends Plugin {
});
this.registerEvent(
this.app.workspace.on("editor-menu", (menu: Menu, editor: Editor, view: MarkdownView) => {
this.app.workspace.on("editor-menu", (menu, editor, info) => {
if (this.settings.enableEditing) {
const res = this.checkContextType(editor, view);
if (!(info instanceof MarkdownView)) {
return;
}
const res = this.checkContextType(editor, info);
if (res) {
menu.addItem(item => {
item
.setTitle('Modify inline callout')
.setIcon('form-input')
.onClick(async () => {
this.modifyInlineCallout(editor, view);
.onClick(() => {
this.modifyInlineCallout(editor, info);
});
})
return true;
});
}
return false;
}
})
);

View file

@ -17,10 +17,10 @@ interface ContextData {
export class ModifyInlineCalloutModal extends Modal {
public calloutIcon: string;
public calloutIcon: string = 'info';
public calloutColor: string | undefined;
public calloutLabel: string | undefined;
previewEl: HTMLDivElement;
previewEl!: HTMLDivElement;
activeDoc: Document = window.activeDocument ?? window.document;
constructor(

View file

@ -13,7 +13,7 @@ export class NewInlineCalloutModal extends Modal {
public calloutIcon: string = 'lucide-info';
public calloutColor: string | undefined;
public calloutLabel: string | undefined;
previewEl: HTMLDivElement;
previewEl!: HTMLDivElement;
activeDoc: Document = window.activeDocument ?? window.document;
constructor(

View file

@ -9,7 +9,7 @@ import type InlineCalloutsPlugin from "../main";
export class SearchInlineCalloutsModal extends Modal {
public calloutIcon: string;
public calloutIcon: string = '';
constructor(
private plugin: InlineCalloutsPlugin,

View file

@ -3,7 +3,7 @@ import {
PluginSettingTab,
Setting
} from 'obsidian';
import InlineCalloutsPlugin from 'src/main';
import InlineCalloutsPlugin from '../main';
export interface InlineCalloutsSettings {
enableSuggester: boolean;

View file

@ -14,6 +14,7 @@ export class InputIconSuggest extends AbstractInputSuggest<string> {
) {
super(app, inputEl);
this.textInputEl = inputEl;
}
getSuggestions(inputStr: string): string[] {

View file

@ -1,17 +1,16 @@
{
"compilerOptions": {
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",
"target": "ES6",
"allowJs": true,
"noImplicitAny": true,
"moduleResolution": "node",
"strict": true,
"moduleResolution": "bundler",
"importHelpers": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"strictNullChecks": true,
"lib": [
"DOM",
"ES5",
@ -20,6 +19,6 @@
]
},
"include": [
"**/*.ts"
"src/**/*.ts"
]
}