mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 01:32:55 +02:00
typefix netscriptFunctions (see desc)
* Types for InternalFunction and ExternalFunction have been modified to actually typecheck ns functions against docs. * Internal functions are required to use unknown for any params on the inner function. * Return types for internal function inner-function must match the respective external function. * Added new typecheck assertion function for asserting dynamic object types, to allow unknownifying params that were previously hardcoded objec structures. * Because type assertion for parameter types and return types is enforced by InternalAPI, removed all duplicate type declarations on NetscriptFunction params and returns.
This commit is contained in:
@@ -2,7 +2,7 @@ import { Player } from "../Player";
|
||||
import { Exploit } from "../Exploits/Exploit";
|
||||
import * as bcrypt from "bcryptjs";
|
||||
import { Apr1Events as devMenu } from "../ui/Apr1";
|
||||
import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper";
|
||||
import { InternalAPI } from "../Netscript/APIWrapper";
|
||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||
import { Terminal } from "../Terminal";
|
||||
|
||||
@@ -32,7 +32,7 @@ export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
|
||||
exploit: () => () => {
|
||||
Player.giveExploit(Exploit.UndocumentedFunctionCall);
|
||||
},
|
||||
bypass: (ctx: NetscriptContext) => (doc: unknown) => {
|
||||
bypass: (ctx) => (doc) => {
|
||||
// reset both fields first
|
||||
type temporary = { completely_unused_field: unknown };
|
||||
const d = doc as temporary;
|
||||
@@ -47,7 +47,7 @@ export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
|
||||
d.completely_unused_field = undefined;
|
||||
real_document.completely_unused_field = undefined;
|
||||
},
|
||||
alterReality: () => (): void => {
|
||||
alterReality: () => () => {
|
||||
// We need to trick webpack into not optimizing a variable that is guaranteed to be false (and doesn't use prototypes)
|
||||
let x = false;
|
||||
const recur = function (depth: number): void {
|
||||
@@ -62,7 +62,7 @@ export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
|
||||
Player.giveExploit(Exploit.RealityAlteration);
|
||||
}
|
||||
},
|
||||
rainbow: (ctx: NetscriptContext) => (guess: unknown) => {
|
||||
rainbow: (ctx) => (guess) => {
|
||||
function tryGuess(): boolean {
|
||||
// eslint-disable-next-line no-sync
|
||||
const verified = bcrypt.compareSync(
|
||||
|
||||
Reference in New Issue
Block a user