fix: resolve TypeScript build errors introduced in c13e48a
Fixes 23 TypeScript errors in 8 files by properly handling type assertions
and template variable types:
**DataAdapter Casting Issues (8 fixes):**
- Use double assertion `as unknown as { basePath: string }` instead of
direct casting to avoid TypeScript's type overlap validation
- Files: BinaryLocator, ExportOrchestrator, PathResolver, PluginLifecycle, TemplateManager
**Template Variables Type Issues (15 fixes):**
- Add `undefined` to Record<string, string|number|boolean> union type
- Convert template variable values to appropriate types before passing to UI methods:
- String() for dropdown setValue() methods
- Number() for slider setValue() methods
- Update interface definitions in modalTypes.ts and ModalState.ts
The double assertion pattern is required because basePath exists at runtime
in Obsidian's FileSystemAdapter but isn't in the TypeScript definitions.
Adding undefined to template variables properly handles uninitialized values.
All changes maintain full functionality while ensuring type safety.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
10 files changed
+22
-22
No files matched your search
@@ -132,7 +132,7 @@ export class ExportOrchestrator {
|
||||
* Export a file with specific configuration
|
||||
*/
|
||||
async exportFileWithConfig(file: TFile, config: ExportConfig): Promise<void> {
|
||||
const vaultPath = (this.plugin.app.vault.adapter as { basePath: string }).basePath;
|
||||
const vaultPath = (this.plugin.app.vault.adapter as unknown as { basePath: string }).basePath;
|
||||
const pluginDir = path.join(vaultPath, this.plugin.manifest.dir!);
|
||||
|
||||
// Create controller for this export (allows cancellation)
|
||||
|
||||
@@ -57,7 +57,7 @@ export class PathResolver {
|
||||
throw new Error(`Invalid output folder path: ${outputFolder}. Path contains invalid characters or traversal attempts.`);
|
||||
}
|
||||
|
||||
const vaultPath = (this.plugin.app.vault.adapter as { basePath: string }).basePath;
|
||||
const vaultPath = (this.plugin.app.vault.adapter as unknown as { basePath: string }).basePath;
|
||||
const outputDir = path.join(vaultPath, outputFolder);
|
||||
|
||||
// Create output directory if it doesn't exist
|
||||
|
||||
@@ -22,7 +22,7 @@ export class PluginLifecycle {
|
||||
await this.plugin.loadSettings();
|
||||
|
||||
// Initialize embedded template manager
|
||||
const vaultPath = (this.plugin.app.vault.adapter as { basePath: string }).basePath;
|
||||
const vaultPath = (this.plugin.app.vault.adapter as unknown as { basePath: string }).basePath;
|
||||
const pluginDir = path.join(vaultPath, this.plugin.manifest.dir!);
|
||||
this.plugin.embeddedTemplateManager = new EmbeddedTemplateManager(pluginDir);
|
||||
|
||||
@@ -66,7 +66,7 @@ export class PluginLifecycle {
|
||||
|
||||
// Clean up temp directories on plugin unload
|
||||
try {
|
||||
const vaultPath = (this.plugin.app.vault.adapter as { basePath: string }).basePath;
|
||||
const vaultPath = (this.plugin.app.vault.adapter as unknown as { basePath: string }).basePath;
|
||||
const cleanupManager = TempDirectoryManager.create(vaultPath, this.plugin.app.vault.configDir);
|
||||
cleanupManager.cleanupAllTempDirs();
|
||||
} catch (error) {
|
||||
@@ -79,7 +79,7 @@ export class PluginLifecycle {
|
||||
*/
|
||||
private cleanupStartupTempDirectories(): void {
|
||||
try {
|
||||
const vaultPath = (this.plugin.app.vault.adapter as { basePath: string }).basePath;
|
||||
const vaultPath = (this.plugin.app.vault.adapter as unknown as { basePath: string }).basePath;
|
||||
const cleanupManager = TempDirectoryManager.create(vaultPath, this.plugin.app.vault.configDir);
|
||||
const _result = cleanupManager.cleanupAllTempDirs();
|
||||
|
||||
|
||||
Reference in new issue
Block a user