mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 16:52: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:
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
Infiltration as IInfiltration,
|
||||
InfiltrationLocation,
|
||||
PossibleInfiltrationLocation,
|
||||
} from "../ScriptEditor/NetscriptDefinitions";
|
||||
import { Infiltration as IInfiltration, InfiltrationLocation } from "../ScriptEditor/NetscriptDefinitions";
|
||||
import { Location } from "../Locations/Location";
|
||||
import { Locations } from "../Locations/Locations";
|
||||
import { calculateDifficulty, calculateReward } from "../Infiltration/formulas/game";
|
||||
@@ -44,17 +40,15 @@ export function NetscriptInfiltration(): InternalAPI<IInfiltration> {
|
||||
};
|
||||
};
|
||||
return {
|
||||
getPossibleLocations: () => (): PossibleInfiltrationLocation[] => {
|
||||
getPossibleLocations: () => () => {
|
||||
return getLocationsWithInfiltrations.map((l) => ({
|
||||
city: l.city ?? "",
|
||||
name: String(l.name),
|
||||
}));
|
||||
},
|
||||
getInfiltration:
|
||||
(ctx: NetscriptContext) =>
|
||||
(_location: unknown): InfiltrationLocation => {
|
||||
const location = helpers.string(ctx, "location", _location);
|
||||
return calculateInfiltrationData(ctx, location);
|
||||
},
|
||||
getInfiltration: (ctx) => (_location) => {
|
||||
const location = helpers.string(ctx, "location", _location);
|
||||
return calculateInfiltrationData(ctx, location);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user