From 09996516dee63be8de4189c9ab1001db1967ed55 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:26:36 +0100 Subject: [PATCH] add @types/wicg-file-system-access to fix build errors - https://stackoverflow.com/a/71343465/9439899 - https://github.com/WICG/file-system-access --- package-lock.json | 8 ++++++++ package.json | 1 + src/components/ModalExport.tsx | 10 ++++------ src/components/ModalOpen.tsx | 7 +++---- tsconfig.json | 6 +++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 85f6f768..b68c2bd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,6 +94,7 @@ "@types/react-icon-base": "^2.1.6", "@types/string-hash": "^1.1.3", "@types/uuid": "^9.0.8", + "@types/wicg-file-system-access": "^2023.10.5", "@vitejs/plugin-react": "^4.2.1", "cors": "^2.8.5", "cypress": "^13.13.0", @@ -2395,6 +2396,13 @@ "integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==", "dev": true }, + "node_modules/@types/wicg-file-system-access": { + "version": "2023.10.5", + "resolved": "https://registry.npmjs.org/@types/wicg-file-system-access/-/wicg-file-system-access-2023.10.5.tgz", + "integrity": "sha512-e9kZO9kCdLqT2h9Tw38oGv9UNzBBWaR1MzuAavxPcsV/7FJ3tWbU6RI3uB+yKIDPGLkGVbplS52ub0AcRLvrhA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/yauzl": { "version": "2.10.3", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", diff --git a/package.json b/package.json index fd307127..592f3cc7 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "@types/react-icon-base": "^2.1.6", "@types/string-hash": "^1.1.3", "@types/uuid": "^9.0.8", + "@types/wicg-file-system-access": "^2023.10.5", "@vitejs/plugin-react": "^4.2.1", "cors": "^2.8.5", "cypress": "^13.13.0", diff --git a/src/components/ModalExport.tsx b/src/components/ModalExport.tsx index c72ad239..7864563a 100644 --- a/src/components/ModalExport.tsx +++ b/src/components/ModalExport.tsx @@ -113,16 +113,14 @@ class ModalExportInternal extends React.Component { } async createFileHandle() : Promise { - const pickerOpts = { + const pickerOpts: SaveFilePickerOptions = { types: [ { - description: "Style JSON", - accept: {"application/json": [".json"]}, - suggestedName: this.exportName(), + description: "json", + accept: { "application/json": [".json"] }, }, ], - excludeAcceptAllOption: true, - multiple: false, + suggestedName: this.exportName(), }; const fileHandle = await window.showSaveFilePicker(pickerOpts) as FileSystemFileHandle; diff --git a/src/components/ModalOpen.tsx b/src/components/ModalOpen.tsx index 7007adcd..2761d14e 100644 --- a/src/components/ModalOpen.tsx +++ b/src/components/ModalOpen.tsx @@ -138,14 +138,13 @@ class ModalOpenInternal extends React.Component { this.clearError(); - const pickerOpts = { + const pickerOpts: OpenFilePickerOptions = { types: [ { - description: "Style JSON", - accept: {"application/json": [".json"]}, + description: "json", + accept: { "application/json": [".json"] }, }, ], - excludeAcceptAllOption: true, multiple: false, }; diff --git a/tsconfig.json b/tsconfig.json index 24f33888..46f4ef8f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "target": "ES2020", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], - "types": ["geojson"], + "types": ["geojson", "@types/wicg-file-system-access"], "module": "ESNext", "skipLibCheck": true, @@ -27,7 +27,7 @@ "ts-node": { "compilerOptions": { "module": "ESNext", - "moduleResolution": "Node" + "moduleResolution": "Node", } } -} \ No newline at end of file +}