fix few as any

This commit is contained in:
Olivier Gagnon 2022-07-20 02:36:21 -04:00
parent 49f6fda1e4
commit 28b9c821d2
5 changed files with 42 additions and 64 deletions

@ -1661,15 +1661,15 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
(_hostname: unknown = workerScript.hostname): IServerDef => {
const hostname = ctx.helper.string("hostname", _hostname);
const server = safeGetServer(hostname, ctx);
const copy = Object.assign({}, server) as any;
const copy = Object.assign({}, server) as Server;
// These fields should be hidden.
copy.contracts = undefined;
copy.messages = undefined;
copy.runningScripts = undefined;
copy.scripts = undefined;
copy.textFiles = undefined;
copy.programs = undefined;
copy.serversOnNetwork = undefined;
copy.contracts = [];
copy.messages = [];
copy.runningScripts = [];
copy.scripts = [];
copy.textFiles = [];
copy.programs = [];
copy.serversOnNetwork = [];
if (!copy.baseDifficulty) copy.baseDifficulty = 0;
if (!copy.hackDifficulty) copy.hackDifficulty = 0;
if (!copy.minDifficulty) copy.minDifficulty = 0;

@ -402,7 +402,7 @@ function evaluateVersionCompatibility(ver: string | number): void {
}
}
if (ver < 15) {
(Settings as any).EditorTheme = { ...defaultMonacoTheme };
Settings.EditorTheme = { ...defaultMonacoTheme };
}
//Fix contract names
if (ver < 16) {
@ -605,12 +605,7 @@ function createBetaUpdateText(): void {
function download(filename: string, content: string): void {
const file = new Blob([content], { type: "text/plain" });
const navigator = window.navigator as any;
if (navigator.msSaveOrOpenBlob) {
// IE10+
navigator.msSaveOrOpenBlob(file, filename);
} else {
// Others
const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
@ -622,7 +617,6 @@ function download(filename: string, content: string): void {
window.URL.revokeObjectURL(url);
}, 0);
}
}
Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject;

@ -67,12 +67,6 @@ export class Script {
download(): void {
const filename = this.filename;
const file = new Blob([this.code], { type: "text/plain" });
const navigator = window.navigator as any;
if (navigator.msSaveOrOpenBlob) {
// IE10+
navigator.msSaveOrOpenBlob(file, filename);
} else {
// Others
const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
@ -84,7 +78,6 @@ export class Script {
window.URL.revokeObjectURL(url);
}, 0);
}
}
/**
* Marks this script as having been updated. It will be recompiled next time something tries

@ -47,15 +47,7 @@ export class TextFile {
* Serves the file to the user as a downloadable resource through the browser.
*/
download(): void {
const filename: string = this.fn;
const file: Blob = new Blob([this.text], { type: "text/plain" });
/* tslint:disable-next-line:strict-boolean-expressions */
const navigator = window.navigator as any;
if (navigator.msSaveOrOpenBlob) {
// IE10+
navigator.msSaveOrOpenBlob(file, filename);
} else {
// Others
const a: HTMLAnchorElement = document.createElement("a");
const url: string = URL.createObjectURL(file);
a.href = url;
@ -67,7 +59,6 @@ export class TextFile {
window.URL.revokeObjectURL(url);
}, 0);
}
}
/**
* Retrieve the content of the file.

@ -140,13 +140,13 @@ export function StyleEditorModal(props: IProps): React.ReactElement {
<FontFamilyField
value={customStyle.fontFamily}
refreshId={refreshId}
onChange={(value, error) => update({ ...customStyle, fontFamily: value as any }, error)}
onChange={(value, error) => update({ ...customStyle, fontFamily: value ?? "" }, error)}
/>
<br />
<LineHeightField
value={customStyle.lineHeight}
refreshId={refreshId}
onChange={(value, error) => update({ ...customStyle, lineHeight: value as any }, error)}
onChange={(value, error) => update({ ...customStyle, lineHeight: Number(value) ?? 0 }, error)}
/>
<br />
<ButtonGroup sx={{ my: 1 }}>