Skip to content

Commit d7b4376

Browse files
committed
Enable strict mode in TypeScript configuration
1 parent d045df1 commit d7b4376

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

sidebars.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ const typedocItems: SidebarItems = JSON.parse(
2424
);
2525

2626
function findSidebarCategory(items: SidebarItems, label: string): SidebarCategory {
27-
return items.find((item): item is SidebarCategory =>
27+
const category = items.find((item): item is SidebarCategory =>
2828
typeof item === 'object' &&
2929
item.type === 'category' &&
3030
item.label === label
3131
);
32+
if (!category) {
33+
throw new Error(`Cannot find sidebar category "${label}"`);
34+
}
35+
return category;
3236
}
3337

3438
const sidebars: SidebarsConfig = {

src/examples/ExampleCommon.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import { HashMap } from '@reactodia/hashmap';
33
import * as Reactodia from '@reactodia/workspace';
4-
import { saveAs } from 'file-saver';
54

65
export function ExampleToolbarMenu() {
76
const {model, editor, overlay} = Reactodia.useWorkspace();
@@ -56,8 +55,16 @@ export function ExampleToolbarMenu() {
5655
const diagramLayout = model.exportLayout();
5756
const layoutString = JSON.stringify(diagramLayout);
5857
const blob = new Blob([layoutString], {type: 'application/json'});
58+
const blobUrl = URL.createObjectURL(blob);
5959
const timestamp = new Date().toISOString().replaceAll(/[Z\s:-]/g, '');
60-
saveAs(blob, `reactodia-diagram-${timestamp}.json`);
60+
try {
61+
const downloadLink = document.createElement('a');
62+
downloadLink.href = blobUrl;
63+
downloadLink.download = `reactodia-diagram-${timestamp}.json`;
64+
downloadLink.click();
65+
} finally {
66+
URL.revokeObjectURL(blobUrl);
67+
}
6168
}}>
6269
Save diagram to file
6370
</Reactodia.ToolbarActionSave>

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"compilerOptions": {
55
"target": "ES2022",
66
"lib": ["DOM", "ES2022"],
7-
"baseUrl": "."
7+
"baseUrl": ".",
8+
"strict": true
89
},
910
"exclude": [
1011
"./reactodia-workspace"

0 commit comments

Comments
 (0)