Use strict type checking

This commit is contained in:
Hornwitser committed 2023-08-12 02:31:17 +02:00
1 parent 2ca8e69025
commit a66e930997
36 files changed
+714 -676

No files matched your search

+3 -3
View File
@@ -10,7 +10,7 @@ import type JSZip from "jszip";
* @returns name of the root folder.
*/
export function findRoot(zip: JSZip) {
let root = null;
let root: undefined | string;
zip.forEach((relativePath, file) => {
let index = relativePath.indexOf("/");
if (index === -1) {
@@ -18,14 +18,14 @@ export function findRoot(zip: JSZip) {
}
let pathRoot = relativePath.slice(0, index);
if (root === null) {
if (root === undefined) {
root = pathRoot;
} else if (root !== pathRoot) {
throw new Error("Zip contains multiple root folders");
}
});
if (root === null) {
if (root === undefined) {
throw new Error("Empty zip file");
}