mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +09:00
Use strict type checking
This commit is contained in:
1 parent
2ca8e69025
commit
a66e930997
36 files changed
+714
-676
No files matched your search
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user