Skip to content

Commit a47663d

Browse files
authored
Merge pull request #98 from bocan:just-a-friday
Improve type safety and update dependencies
2 parents e9db9d6 + 5e7d49e commit a47663d

16 files changed

Lines changed: 339 additions & 94 deletions

File tree

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"react": "^19.2.4",
2121
"react-dom": "^19.2.4",
2222
"react-markdown": "^10.1.0",
23-
"react-syntax-highlighter": "^16.1.0",
23+
"react-syntax-highlighter": "^16.1.1",
2424
"rehype-autolink-headings": "^7.1.0",
2525
"rehype-slug": "^6.0.0",
2626
"remark-gfm": "^4.0.0",

client/src/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ function App() {
271271
if (!selectedFolder) {
272272
setSelectedFolder(tree.path);
273273
}
274-
} catch (error: any) {
274+
} catch (error: unknown) {
275275
console.error("Failed to load folder tree:", error);
276276
const message =
277-
error.response?.status === 401
277+
(error as { response?: { status?: number } })?.response?.status === 401
278278
? "Session expired. Please log in again."
279279
: "Failed to load folders. Please try refreshing the page.";
280280
setError(message);
@@ -302,10 +302,10 @@ function App() {
302302
if (readme) {
303303
setSelectedPage(readme.path);
304304
}
305-
} catch (error: any) {
305+
} catch (error: unknown) {
306306
console.error("Failed to check for README.md:", error);
307307
const message =
308-
error.response?.status === 401
308+
(error as { response?: { status?: number } })?.response?.status === 401
309309
? "Session expired. Please log in again."
310310
: `Failed to load pages from folder: ${path}`;
311311
setError(message);

client/src/components/Attachments.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const Attachments: React.FC<AttachmentsProps> = ({
3535
setError(null);
3636
try {
3737
const data = await api.getAttachments(folderPath);
38-
setAttachments(data);
38+
setAttachments(data as Attachment[]);
3939
} catch (err) {
4040
console.error("Failed to load attachments:", err);
4141
setError("Failed to load attachments");

client/src/components/Editor.tsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,15 @@ export const Editor: React.FC<EditorProps> = ({ pagePath, onClose }) => {
146146

147147
// Speech recognition functions
148148
const startListening = () => {
149+
interface WindowWithSpeech extends Window {
150+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
151+
SpeechRecognition?: { new(): any };
152+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
153+
webkitSpeechRecognition?: { new(): any };
154+
}
149155
const SpeechRecognition =
150-
(window as any).SpeechRecognition ||
151-
(window as any).webkitSpeechRecognition;
156+
(window as unknown as WindowWithSpeech).SpeechRecognition ||
157+
(window as unknown as WindowWithSpeech).webkitSpeechRecognition;
152158
if (!SpeechRecognition) {
153159
alert(
154160
"Speech recognition is not supported in this browser. Try Chrome or Edge.",
@@ -163,10 +169,18 @@ export const Editor: React.FC<EditorProps> = ({ pagePath, onClose }) => {
163169

164170
let finalTranscript = "";
165171

166-
recognition.onresult = (event: any) => {
167-
for (let i = event.resultIndex; i < event.results.length; i++) {
168-
const transcript = event.results[i][0].transcript;
169-
if (event.results[i].isFinal) {
172+
recognition.onresult = (event: unknown) => {
173+
const typedEvent = event as {
174+
resultIndex: number;
175+
results: { isFinal: boolean; [index: number]: { transcript: string } }[];
176+
};
177+
for (
178+
let i = typedEvent.resultIndex;
179+
i < typedEvent.results.length;
180+
i++
181+
) {
182+
const transcript = typedEvent.results[i][0].transcript;
183+
if (typedEvent.results[i].isFinal) {
170184
finalTranscript += transcript + " ";
171185
}
172186
}
@@ -197,9 +211,10 @@ export const Editor: React.FC<EditorProps> = ({ pagePath, onClose }) => {
197211
}
198212
};
199213

200-
recognition.onerror = (event: any) => {
201-
console.error("Speech recognition error:", event.error);
202-
if (event.error === "not-allowed") {
214+
recognition.onerror = (event: unknown) => {
215+
const typedEvent = event as { error?: string };
216+
console.error("Speech recognition error:", typedEvent.error);
217+
if (typedEvent.error === "not-allowed") {
203218
alert(
204219
"Microphone access denied. Please allow microphone access and try again.",
205220
);
@@ -240,7 +255,6 @@ export const Editor: React.FC<EditorProps> = ({ pagePath, onClose }) => {
240255
textarea.focus();
241256

242257
// execCommand preserves native undo stack
243-
// eslint-disable-next-line @typescript-eslint/no-deprecated
244258
const success = document.execCommand("insertText", false, text);
245259

246260
if (!success) {

client/src/components/Login.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export const Login: React.FC<LoginProps> = ({ onLoginSuccess }) => {
2525
try {
2626
await api.login(password);
2727
onLoginSuccess();
28-
} catch (err: any) {
28+
} catch (err: unknown) {
2929
console.error("Login failed:", err);
30-
setError(err.response?.data?.error || "Invalid password");
30+
setError(
31+
(err as { response?: { data?: { error?: string } } })?.response?.data?.error || "Invalid password"
32+
);
3133
} finally {
3234
setIsLoading(false);
3335
}

client/src/components/PageList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ export const PageList: React.FC<PageListProps> = ({
339339
onSelectPage(result.newPath);
340340
}
341341
setMovingPage(null);
342-
} catch (err: any) {
342+
} catch (err: unknown) {
343343
console.error("Failed to move page:", err);
344344
setError(
345-
err.response?.data?.error || "Failed to move page. Please try again.",
345+
(err as { response?: { data?: { error?: string } } })?.response?.data?.error || "Failed to move page. Please try again.",
346346
);
347347
setMovingPage(null);
348348
} finally {

client/src/components/Preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ ${htmlContent}
14501450
const blob =
14511451
docxBlob instanceof Blob
14521452
? docxBlob
1453-
: new Blob([new Uint8Array(docxBlob as any)], {
1453+
: new Blob([new Uint8Array((docxBlob as unknown) as ArrayBuffer)], {
14541454
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
14551455
});
14561456

client/src/services/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export const api = {
149149
});
150150
},
151151

152-
getAttachments: async (folderPath: string): Promise<any[]> => {
152+
getAttachments: async (folderPath: string): Promise<unknown[]> => {
153153
const response = await axios.get(`${API_BASE}/attachments`, {
154154
params: { folder: folderPath },
155155
});

0 commit comments

Comments
 (0)