mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-20 14:43:48 +01:00
Change Signature of InternalFunction
Mark properties of Wrapped NetscriptAPI as readonly
This commit is contained in:
parent
b2e7817a0b
commit
f53c90b21c
@ -10,9 +10,7 @@ type ExternalAPI = {
|
||||
[string: string]: ExternalAPI | ExternalFunction;
|
||||
};
|
||||
|
||||
type InternalFunction<F extends (...args: unknown[]) => unknown> = (
|
||||
ctx: NetscriptContext,
|
||||
) => (...args: unknown[]) => ReturnType<F>;
|
||||
type InternalFunction<F extends (...args: unknown[]) => unknown> = (ctx: NetscriptContext) => F;
|
||||
export type InternalAPI<API> = {
|
||||
[Property in keyof API]: API[Property] extends ExternalFunction
|
||||
? InternalFunction<API[Property]>
|
||||
@ -23,7 +21,7 @@ export type InternalAPI<API> = {
|
||||
|
||||
type WrappedNetscriptFunction = (...args: unknown[]) => unknown;
|
||||
type WrappedNetscriptAPI = {
|
||||
[string: string]: WrappedNetscriptAPI | WrappedNetscriptFunction;
|
||||
readonly [string: string]: WrappedNetscriptAPI | WrappedNetscriptFunction;
|
||||
};
|
||||
|
||||
export type NetscriptContext = {
|
||||
@ -47,7 +45,6 @@ type NetscriptHelpers = {
|
||||
};
|
||||
|
||||
type WrappedNetscriptHelpers = {
|
||||
updateDynamicRam: (ramCost: number) => void;
|
||||
makeRuntimeErrorMsg: (msg: string) => string;
|
||||
string: (argName: string, v: unknown) => string;
|
||||
number: (argName: string, v: unknown) => number;
|
||||
@ -80,7 +77,6 @@ function wrapFunction(
|
||||
workerScript,
|
||||
function: functionName,
|
||||
helper: {
|
||||
updateDynamicRam: (ramCost: number) => helpers.updateDynamicRam(functionName, ramCost),
|
||||
makeRuntimeErrorMsg: (msg: string) => helpers.makeRuntimeErrorMsg(functionPath, msg),
|
||||
string: (argName: string, v: unknown) => helpers.string(functionPath, argName, v),
|
||||
number: (argName: string, v: unknown) => helpers.number(functionPath, argName, v),
|
||||
|
Loading…
Reference in New Issue
Block a user