mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
refactor: enable full TypeScript strict mode
Switch from incremental strict flags to strict: true. Fix property initializers with definite assignment assertions and inline defaults, and annotate all catch clauses with unknown type. Change-Id: I805047eebea7dc5414ff7001aca96eac5a099d02
This commit is contained in:
parent
a49e5cd2ec
commit
58ab0fa77f
7 changed files with 57 additions and 64 deletions
68
main.js
68
main.js
File diff suppressed because one or more lines are too long
18
main.ts
18
main.ts
|
|
@ -90,13 +90,13 @@ function cancellationNoticeKey(settings: PluginSettings | null, job: GenerationJ
|
|||
/* ---------- Plugin ---------- */
|
||||
|
||||
class ParallelReaderPlugin extends Plugin {
|
||||
settings: PluginSettings;
|
||||
cache: Record<string, CacheEntry>;
|
||||
jobs: GenerationJobManager;
|
||||
_scrollDispose: (() => void) | null;
|
||||
_settingsSaveTimer: ReturnType<typeof setTimeout> | null;
|
||||
_cacheSaveTimer: ReturnType<typeof setTimeout> | null;
|
||||
_cacheDirty: boolean;
|
||||
settings!: PluginSettings;
|
||||
cache!: Record<string, CacheEntry>;
|
||||
jobs!: GenerationJobManager;
|
||||
_scrollDispose: (() => void) | null = null;
|
||||
_settingsSaveTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
_cacheSaveTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
_cacheDirty = false;
|
||||
|
||||
t(key: string, vars?: Record<string, string | number>) {
|
||||
return translate(this.settings || DEFAULT_SETTINGS, key, vars);
|
||||
|
|
@ -296,8 +296,8 @@ class ParallelReaderPlugin extends Plugin {
|
|||
const parsed = JSON.parse(raw);
|
||||
if (parsed && typeof parsed === 'object' && parsed.entries && typeof parsed.entries === 'object')
|
||||
return parsed.entries;
|
||||
} catch (e) {
|
||||
const message = String(e?.message || e || '');
|
||||
} catch (e: unknown) {
|
||||
const message = String((e as Error)?.message || e || '');
|
||||
if (!/not found|does not exist|ENOENT/i.test(message))
|
||||
console.warn('[parallel-reader] failed to read cache.json', e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ export function runCli(
|
|||
.join(':'),
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
return reject(new Error(`Failed to start ${cmd}: ${e.message}`));
|
||||
} catch (e: unknown) {
|
||||
return reject(new Error(`Failed to start ${cmd}: ${(e as Error).message}`));
|
||||
}
|
||||
|
||||
let stdout = '';
|
||||
|
|
|
|||
|
|
@ -315,8 +315,8 @@ export class ParallelReaderSettingTab extends PluginSettingTab {
|
|||
try {
|
||||
const result = await testBackend(this.plugin.settings);
|
||||
new Notice(`✓ ${result.slice(0, 180)}`, 8000);
|
||||
} catch (e) {
|
||||
new Notice(tr('backendTestFailed', { error: e.message }), 10000);
|
||||
} catch (e: unknown) {
|
||||
new Notice(tr('backendTestFailed', { error: (e as Error).message }), 10000);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ export function addIconButton(parent: HTMLElement, icon: string, title: string,
|
|||
e.stopPropagation();
|
||||
try {
|
||||
await onClick();
|
||||
} catch (err) {
|
||||
} catch (err: unknown) {
|
||||
console.error(err);
|
||||
new Notice(`${title} failed: ` + (err.message || err));
|
||||
new Notice(`${title} failed: ` + ((err as Error).message || err));
|
||||
}
|
||||
});
|
||||
return button;
|
||||
|
|
@ -44,9 +44,9 @@ export function addTextButton(
|
|||
e.stopPropagation();
|
||||
try {
|
||||
await onClick();
|
||||
} catch (err) {
|
||||
} catch (err: unknown) {
|
||||
console.error(err);
|
||||
new Notice(`${label} failed: ` + (err.message || err));
|
||||
new Notice(`${label} failed: ` + ((err as Error).message || err));
|
||||
}
|
||||
});
|
||||
return button;
|
||||
|
|
@ -56,7 +56,7 @@ export async function copyToClipboard(text: string, successMsg: string) {
|
|||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
new Notice(successMsg);
|
||||
} catch (e) {
|
||||
new Notice('Copy failed: ' + (e.message || e));
|
||||
} catch (e: unknown) {
|
||||
new Notice('Copy failed: ' + ((e as Error).message || e));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ export class ParallelReaderView extends ItemView {
|
|||
sourceFile: TFile | null;
|
||||
cards: HTMLElement[];
|
||||
activeIdx: number;
|
||||
stale: boolean;
|
||||
loadingMessage: string;
|
||||
errorMessage: string;
|
||||
stale = false;
|
||||
loadingMessage = '';
|
||||
errorMessage = '';
|
||||
|
||||
constructor(leaf: WorkspaceLeaf, plugin: PluginHost) {
|
||||
super(leaf);
|
||||
|
|
@ -28,8 +28,6 @@ export class ParallelReaderView extends ItemView {
|
|||
this.sourceFile = null;
|
||||
this.cards = [];
|
||||
this.activeIdx = -1;
|
||||
this.loadingMessage = '';
|
||||
this.errorMessage = '';
|
||||
}
|
||||
|
||||
getViewType() {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,7 @@
|
|||
"moduleResolution": "Node",
|
||||
"lib": ["ES2022", "DOM"],
|
||||
"types": ["node"],
|
||||
"strict": false,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictBindCallApply": true,
|
||||
"noImplicitThis": true,
|
||||
"strict": true,
|
||||
"noImplicitReturns": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue