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 => { (_hostname: unknown = workerScript.hostname): IServerDef => {
const hostname = ctx.helper.string("hostname", _hostname); const hostname = ctx.helper.string("hostname", _hostname);
const server = safeGetServer(hostname, ctx); const server = safeGetServer(hostname, ctx);
const copy = Object.assign({}, server) as any; const copy = Object.assign({}, server) as Server;
// These fields should be hidden. // These fields should be hidden.
copy.contracts = undefined; copy.contracts = [];
copy.messages = undefined; copy.messages = [];
copy.runningScripts = undefined; copy.runningScripts = [];
copy.scripts = undefined; copy.scripts = [];
copy.textFiles = undefined; copy.textFiles = [];
copy.programs = undefined; copy.programs = [];
copy.serversOnNetwork = undefined; copy.serversOnNetwork = [];
if (!copy.baseDifficulty) copy.baseDifficulty = 0; if (!copy.baseDifficulty) copy.baseDifficulty = 0;
if (!copy.hackDifficulty) copy.hackDifficulty = 0; if (!copy.hackDifficulty) copy.hackDifficulty = 0;
if (!copy.minDifficulty) copy.minDifficulty = 0; if (!copy.minDifficulty) copy.minDifficulty = 0;

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

@ -67,23 +67,16 @@ export class Script {
download(): void { download(): void {
const filename = this.filename; const filename = this.filename;
const file = new Blob([this.code], { type: "text/plain" }); const file = new Blob([this.code], { type: "text/plain" });
const navigator = window.navigator as any; const a = document.createElement("a"),
if (navigator.msSaveOrOpenBlob) { url = URL.createObjectURL(file);
// IE10+ a.href = url;
navigator.msSaveOrOpenBlob(file, filename); a.download = filename;
} else { document.body.appendChild(a);
// Others a.click();
const a = document.createElement("a"), setTimeout(function () {
url = URL.createObjectURL(file); document.body.removeChild(a);
a.href = url; window.URL.revokeObjectURL(url);
a.download = filename; }, 0);
document.body.appendChild(a);
a.click();
setTimeout(function () {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
} }
/** /**

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

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