Improve TypeScript types and error handling

- Created proper TypeScript types for Office API operations
- Replaced 'any' casts with appropriate types
- Added type-safe utility functions in office-types.ts
- Improved error handling with proper unknown type
- Added helper functions for PowerPoint shape operations
- Created proper TypeScript interface for webpack HMR

These changes improve code quality, maintainability, and help catch potential bugs at compile time rather than runtime.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
schihei committed 2025-03-15 00:02:35 +01:00
1 parent 07b0232726
commit 50966867b2
4 files changed
+79 -13

No files matched your search

+3 -2
View File
@@ -2,6 +2,7 @@ import * as React from "react";
import { Button, ButtonProps } from "@fluentui/react-components";
import { useStatusContext } from "./App";
import { useCommonStyles } from "./commonStyles";
import { getErrorMessage } from "../types/office-types";
export interface ActionButtonProps {
icon: ButtonProps["icon"];
@@ -37,8 +38,8 @@ export const ActionButton: React.FC<ActionButtonProps> = ({
setIsProcessing(true);
try {
await onClick();
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
} catch (error: unknown) {
const errorMessage = getErrorMessage(error);
setStatusMessage(`Error: ${errorMessage}`);
setStatusType("error");
console.error(`Error in ${title} action:`, error);