From e02892ea747ebaea097690778342e61b2120cff2 Mon Sep 17 00:00:00 2001 From: Maroxy Date: Tue, 21 Dec 2021 20:41:26 +0100 Subject: [PATCH] Fix TS Errors --- src/ts/Archive.ts | 8 +++----- src/ts/Configs.ts | 8 ++------ src/ts/Constants.ts | 3 ++- src/ts/Downloader.ts | 6 +++--- src/ts/Runners.ts | 4 ++-- src/ts/neutralino/Window.ts | 4 ++-- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/ts/Archive.ts b/src/ts/Archive.ts index 3790679..417bb06 100644 --- a/src/ts/Archive.ts +++ b/src/ts/Archive.ts @@ -5,6 +5,9 @@ import type { ArchiveInfo } from './types/Archive'; +declare const Neutralino; +declare const NL_CWD; + class Stream { /** @@ -60,10 +63,8 @@ class Stream let remainedFiles = this.archive.files; - // @ts-expect-error const baseDir = unpackDir ?? NL_CWD; - // @ts-expect-error Neutralino.os.execCommand(command, { background: true }); @@ -74,7 +75,6 @@ class Stream remainedFiles.forEach((file) => { if (file.path != '#unpacked#') { - // @ts-expect-error Neutralino.filesystem.getStats(`${baseDir}/${file.path}`) .then(() => { this.unpacked += file.size.uncompressed; @@ -198,7 +198,6 @@ export default class Archive switch (archive.type) { case 'tar': - // @ts-expect-error const tarOutput = await Neutralino.os.execCommand(`tar -tvf "${path}"`); for (const match of tarOutput.stdOut.matchAll(/^[dwxr\-]+ [\w/]+[ ]+(\d+) [0-9\-]+ [0-9\:]+ (.+)/gm)) @@ -221,7 +220,6 @@ export default class Archive break; case 'zip': - // @ts-expect-error const zipOutput = await Neutralino.os.execCommand(`unzip -v "${path}"`); for (const match of zipOutput.stdOut.matchAll(/^(\d+) [a-zA-Z\:]+[ ]+(\d+)[ ]+[0-9\-]+% [0-9\-]+ [0-9\:]+ [a-f0-9]{8} (.+)/gm)) diff --git a/src/ts/Configs.ts b/src/ts/Configs.ts index 39bb82a..65f7417 100644 --- a/src/ts/Configs.ts +++ b/src/ts/Configs.ts @@ -1,4 +1,6 @@ import Constants from './Constants'; +declare const Neutralino; +declare const NL_CWD; // Ok yea, null and object aren't scalars // but I don't care @@ -15,7 +17,6 @@ export default class Configs public static get(name: string = ''): Promise { return new Promise(async (resolve) => { - // @ts-expect-error Neutralino.filesystem.readFile(await Constants.paths.config).then((config) => { config = JSON.parse(config); @@ -48,17 +49,14 @@ export default class Configs }; return new Promise(async (resolve) => { - // @ts-expect-error Neutralino.filesystem.readFile(await Constants.paths.config).then(async (config) => { config = JSON.stringify(getUpdatedArray(name.split('.'), JSON.parse(config), value), null, 4); - // @ts-expect-error Neutralino.filesystem.writeFile(await Constants.paths.config, config) .then(() => resolve()); }).catch(async () => { let config = JSON.stringify(getUpdatedArray(name.split('.'), {}, value), null, 4); - // @ts-expect-error Neutralino.filesystem.writeFile(await Constants.paths.config, config) .then(() => resolve()); }); @@ -98,12 +96,10 @@ export default class Configs current = JSON.stringify(updateDefaults(current, configs), null, 4); - // @ts-expect-error Neutralino.filesystem.writeFile(await Constants.paths.config, current) .then(() => resolve()); }; - // @ts-expect-error Neutralino.filesystem.readFile(await Constants.paths.config) .then((config) => setDefaults(JSON.parse(config))) .catch(() => setDefaults({})); diff --git a/src/ts/Constants.ts b/src/ts/Constants.ts index c803bc1..961e4fa 100644 --- a/src/ts/Constants.ts +++ b/src/ts/Constants.ts @@ -1,3 +1,5 @@ +declare const Neutralino; + class Paths { /** @@ -26,7 +28,6 @@ class Paths */ public static get launcher(): Promise { - // @ts-expect-error return new Promise(async (resolve) => resolve(`${await Neutralino.os.getPath('data')}/anime-game-launcher`)); } diff --git a/src/ts/Downloader.ts b/src/ts/Downloader.ts index 10f36de..a82584d 100644 --- a/src/ts/Downloader.ts +++ b/src/ts/Downloader.ts @@ -1,3 +1,6 @@ +declare const Neutralino; +declare const NL_CWD; + class Stream { /** @@ -25,13 +28,11 @@ class Stream if (this.onStart) this.onStart(); - // @ts-expect-error Neutralino.os.execCommand(`curl -s -L -N -o "${output}" "${uri}"`, { background: true }); const updateProgress = () => { - // @ts-expect-error Neutralino.filesystem.getStats(output).then((stats) => { if (this.onProgress) this.onProgress(stats.size, this.total, this.previous - stats.size); @@ -107,7 +108,6 @@ export default class Downloader public static async download(uri: string, output: string|null = null): Promise { return new Promise(async (resolve) => { - // @ts-expect-error let statsRaw = await Neutralino.os.execCommand(`curl -s -I -L "${uri}"`); if (statsRaw.stdOut == '') diff --git a/src/ts/Runners.ts b/src/ts/Runners.ts index 88b0b22..3e6a8c1 100644 --- a/src/ts/Runners.ts +++ b/src/ts/Runners.ts @@ -3,6 +3,8 @@ import { RunnerFamily } from './types/Runners'; +declare const Neutralino; + import Constants from './Constants'; import Downloader from './Downloader'; import Archive from './Archive'; @@ -175,10 +177,8 @@ class Runners { return new Promise((resolve) => { Constants.paths.runners.then(async (runnersDir: string) => { - // @ts-expect-error let list: RunnerFamily[] = JSON.parse(await Neutralino.filesystem.readFile(`${Constants.paths.app}/public/runners.json`)); - // @ts-expect-error const installed: { entry: string, type: string }[] = await Neutralino.filesystem.readDirectory(runnersDir); let runners: RunnerFamily[] = []; diff --git a/src/ts/neutralino/Window.ts b/src/ts/neutralino/Window.ts index b34467e..764f309 100644 --- a/src/ts/neutralino/Window.ts +++ b/src/ts/neutralino/Window.ts @@ -22,18 +22,18 @@ type WindowOptions = WindowSize & { processArgs?: string; }; +declare const Neutralino; + class Window { public static get current(): any { - // @ts-expect-error return Neutralino.window; } public static async open(name: string, options: WindowOptions = {}): Promise { return new Promise(async (resolve) => { - // @ts-expect-error const status = Neutralino.window.create(`/${name}.html`, { width: 600, height: 400,