diff --git a/src/ts/Configs.ts b/src/ts/Configs.ts index 51f84f1..c9db29b 100644 --- a/src/ts/Configs.ts +++ b/src/ts/Configs.ts @@ -42,8 +42,8 @@ export default class Configs public static set(name: string, value: scalar|scalar[]): Promise { const getUpdatedArray = (path: string[], array: scalar|scalar[], value: scalar|scalar[]): scalar|scalar[] => { - array[path[0]] = path.length > 1 ? - getUpdatedArray(path.slice(1), array[path[0]] ?? {}, value) : value; + array![path[0]] = path.length > 1 ? + getUpdatedArray(path.slice(1), array![path[0]] ?? {}, value) : value; return array; }; @@ -74,14 +74,14 @@ export default class Configs return new Promise(async (resolve) => { const setDefaults = async (current: scalar) => { const updateDefaults = (current: scalar, defaults: scalar) => { - Object.keys(defaults).forEach((key) => { + Object.keys(defaults!).forEach((key) => { // If the field exists in defaults and doesn't exist in current - if (current[key] === undefined) - current[key] = defaults[key]; + if (current![key] === undefined) + current![key] = defaults![key]; // If both of default and current are objects - else if (typeof current[key] == 'object' && typeof defaults[key] == 'object') - current[key] = updateDefaults(current[key], defaults[key]); + else if (typeof current![key] == 'object' && typeof defaults![key] == 'object') + current![key] = updateDefaults(current![key], defaults![key]); }); return current; diff --git a/src/ts/Game.ts b/src/ts/Game.ts index e41f2e0..9bfb27c 100644 --- a/src/ts/Game.ts +++ b/src/ts/Game.ts @@ -6,6 +6,7 @@ import type { } from './types/GameData'; import constants from './Constants'; +import fetch from './core/Fetch'; declare const Neutralino; @@ -48,7 +49,7 @@ export default class Game if (response.ok) { - const json: ServerResponse = await response.json(); + const json: ServerResponse = await (response as any).json(); if (json.message == 'OK') resolve(json.data); diff --git a/src/ts/Voice.ts b/src/ts/Voice.ts index 84e30eb..d830579 100644 --- a/src/ts/Voice.ts +++ b/src/ts/Voice.ts @@ -74,7 +74,7 @@ export default class Voice { return new Promise((resolve, reject) => { Game.getDiff(version) - .then((data) => resolve(data.voice_packs ?? null)) + .then((data) => resolve(data!.voice_packs ?? null)) .catch((error) => reject(error)); }); } diff --git a/src/ts/core/Archive.ts b/src/ts/core/Archive.ts index 4e0d131..19481c1 100644 --- a/src/ts/core/Archive.ts +++ b/src/ts/core/Archive.ts @@ -19,7 +19,7 @@ class Stream protected unpackDir: string|null; protected unpacked: number = 0; - protected archive: ArchiveInfo; + protected archive?: ArchiveInfo; protected onStart?: () => void; protected onProgress?: (current: number, total: number, difference: number) => void; @@ -59,7 +59,7 @@ class Stream const command = { tar: `tar -xvf "${path}"${unpackDir ? ` -C "${unpackDir}"` : ''}`, zip: `unzip -o "${path}"${unpackDir ? ` -d "${unpackDir}"` : ''}` - }[this.archive.type]; + }[this.archive.type!]; let remainedFiles = this.archive.files; @@ -77,8 +77,8 @@ class Stream { Neutralino.filesystem.getStats(`${baseDir}/${file.path}`) .then(() => { - this.unpacked += file.size.uncompressed; - difference += file.size.uncompressed; + this.unpacked += file.size.uncompressed!; + difference += file.size.uncompressed!; file.path = '#unpacked#'; }) @@ -89,9 +89,9 @@ class Stream remainedFiles = remainedFiles.filter((file) => file.path != '#unpacked#'); if (this.onProgress) - this.onProgress(this.unpacked, this.archive.size.uncompressed, difference); + this.onProgress(this.unpacked, this.archive!.size.uncompressed!, difference); - if (this.unpacked >= this.archive.size.uncompressed) + if (this.unpacked >= this.archive!.size.uncompressed!) { this.finished = true; @@ -204,7 +204,7 @@ export default class Archive { let fileSize = parseInt(match[1]); - archive.size.uncompressed += fileSize; + archive.size.uncompressed! += fileSize; archive.files.push({ path: match[2], @@ -227,8 +227,8 @@ export default class Archive let uncompressedSize = parseInt(match[1]), compressedSize = parseInt(match[2]); - archive.size.compressed += compressedSize; - archive.size.uncompressed += uncompressedSize; + archive.size.compressed! += compressedSize; + archive.size.uncompressed! += uncompressedSize; archive.files.push({ path: match[3], diff --git a/src/ts/core/DXVK.ts b/src/ts/core/DXVK.ts index c2c23aa..6053e3c 100644 --- a/src/ts/core/DXVK.ts +++ b/src/ts/core/DXVK.ts @@ -59,7 +59,7 @@ export default class DXVK // then we should find this DXVK version and call this method for it if (typeof dxvk == 'string') { - let foundDXVK = null; + let foundDXVK; (await this.get()).forEach((currDxvk) => { if (currDxvk.version == dxvk) diff --git a/src/ts/core/Downloader.ts b/src/ts/core/Downloader.ts index 6b70eed..d62c6ee 100644 --- a/src/ts/core/Downloader.ts +++ b/src/ts/core/Downloader.ts @@ -110,14 +110,14 @@ export default class Downloader { return new Promise(async (resolve) => { fetch(uri).then((response) => { - resolve(new Stream(uri, output ?? this.fileFromUri(uri), response.length)); + resolve(new Stream(uri, output ?? this.fileFromUri(uri), response.length!)); }); }); } public static fileFromUri(uri: string): string { - const file = uri.split('/').pop().split('#')[0].split('?')[0]; + const file = uri.split('/').pop()!.split('#')[0].split('?')[0]; if (file === '') return 'index.html'; @@ -125,7 +125,7 @@ export default class Downloader else if (`https://${file}` != uri && `http://${file}` != uri) return file; - else 'index.html'; + else return 'index.html'; } } diff --git a/src/ts/core/Fetch.ts b/src/ts/core/Fetch.ts index 52b6e65..dd5c1bb 100644 --- a/src/ts/core/Fetch.ts +++ b/src/ts/core/Fetch.ts @@ -29,7 +29,7 @@ class Response this.length = length; // https://developer.mozilla.org/en-US/docs/Web/API/Response/ok - this.ok = status >= 200 && status <= 299; + this.ok = status! >= 200 && status! <= 299; } /** diff --git a/src/ts/core/Runners.ts b/src/ts/core/Runners.ts index 12c8300..ab6d4a9 100644 --- a/src/ts/core/Runners.ts +++ b/src/ts/core/Runners.ts @@ -71,7 +71,7 @@ class Runners // then we should find this runner and call this method for it if (typeof runner == 'string') { - let foundRunner = null; + let foundRunner; (await this.get()).forEach((family) => { family.runners.forEach((familyRunner) => { diff --git a/src/ts/types/Archive.d.ts b/src/ts/types/Archive.d.ts index b0bd31f..414f045 100644 --- a/src/ts/types/Archive.d.ts +++ b/src/ts/types/Archive.d.ts @@ -1,10 +1,11 @@ type ArchiveType = | 'tar' - | 'zip'; + | 'zip' + | null; type Size = { - compressed?: number; - uncompressed?: number; + compressed?: number | null; + uncompressed?: number | null; }; type File = {