mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 19:14:32 +02:00
TYPESAFETY: Strict internal typing for AugmentationName (#608)
This commit is contained in:
@@ -28,13 +28,17 @@ class EnumHelper<EnumObj extends object, EnumMember extends Member<EnumObj> & st
|
||||
if (this.isMember(toValidate)) return toValidate;
|
||||
// assertString is just called so if the user didn't even pass in a string, they get a different error message
|
||||
assertString(ctx, argName, toValidate);
|
||||
// Don't display all possibilities for large enums
|
||||
let allowableValues = `Allowable values: ${this.valueArray.map((val) => `"${val}"`).join(", ")}`;
|
||||
if (this.valueArray.length > 10) {
|
||||
console.warn(
|
||||
`Provided value ${toValidate} was not a valid option for enum type ${this.name}.\n${allowableValues}`,
|
||||
);
|
||||
allowableValues = `See the developer console for allowable values.`;
|
||||
}
|
||||
throw helpers.makeRuntimeErrorMsg(
|
||||
ctx,
|
||||
`Argument ${argName} should be a ${
|
||||
this.name
|
||||
} enum member.\nProvided value: "${toValidate}".\nAllowable values: ${this.valueArray
|
||||
.map((val) => `"${val}"`)
|
||||
.join(", ")}`,
|
||||
`Argument ${argName} should be a ${this.name} enum member.\nProvided value: "${toValidate}".\n${allowableValues}`,
|
||||
);
|
||||
}
|
||||
/** Provides case insensitivty and ignores spaces and dashes, and can always match the input */
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { AugmentationName } from "@enums";
|
||||
import { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation";
|
||||
import { Player } from "@player";
|
||||
import { Script } from "../Script/Script";
|
||||
import { GetAllServers } from "../Server/AllServers";
|
||||
import { resolveTextFilePath } from "../Paths/TextFilePath";
|
||||
import { resolveScriptFilePath } from "../Paths/ScriptFilePath";
|
||||
@@ -137,7 +136,7 @@ export function v1APIBreak(): void {
|
||||
console.error(`Unexpected error resolving backup path for ${script.filename}`);
|
||||
continue;
|
||||
}
|
||||
server.scripts.set(filename, new Script(filename, script.code, script.server));
|
||||
server.writeToScriptFile(filename, script.code);
|
||||
script.code = convert(script.code);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user