mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
REFACTOR: Move Result to the public API (#2398)
* REFACTOR: Move Result to the public API This refactors Result<T> to be part of the public NetscriptDefinitions. It is not used by anything in this PR, but it is planned to be used in the autoinfil APIs, or lacking that, future APIs, so this should not be exposing anything prematurely. * Add @public as api-extractor suggested and generate docs * Use import type --------- Co-authored-by: CatLover <152669316+catloversg@users.noreply.github.com>
This commit is contained in:
12
markdown/bitburner.failureresult.md
Normal file
12
markdown/bitburner.failureresult.md
Normal file
@@ -0,0 +1,12 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [bitburner](./bitburner.md) > [FailureResult](./bitburner.failureresult.md)
|
||||
|
||||
## FailureResult type
|
||||
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
type FailureResult = { success: false; message: string };
|
||||
```
|
||||
@@ -1803,6 +1803,16 @@ Warning: Spoiler ahead. This enum contains names of \*\*all\*\* factions. If you
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
|
||||
[FailureResult](./bitburner.failureresult.md)
|
||||
|
||||
|
||||
</td><td>
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
|
||||
@@ -2029,6 +2039,16 @@ A stand-in for the real React.ReactNode. A [ReactElement](./bitburner.reacteleme
|
||||
Use React.createElement to make the ReactElement type, see [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation.
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
|
||||
[Result](./bitburner.result.md)
|
||||
|
||||
|
||||
</td><td>
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
|
||||
@@ -2171,6 +2191,16 @@ These special Bladeburner action types are only for Sleeve
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
|
||||
[SuccessResult](./bitburner.successresult.md)
|
||||
|
||||
|
||||
</td><td>
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
|
||||
|
||||
14
markdown/bitburner.result.md
Normal file
14
markdown/bitburner.result.md
Normal file
@@ -0,0 +1,14 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [bitburner](./bitburner.md) > [Result](./bitburner.result.md)
|
||||
|
||||
## Result type
|
||||
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
type Result<T extends object = object> = SuccessResult<T> | FailureResult;
|
||||
```
|
||||
**References:** [SuccessResult](./bitburner.successresult.md)<!-- -->, [FailureResult](./bitburner.failureresult.md)
|
||||
|
||||
12
markdown/bitburner.successresult.md
Normal file
12
markdown/bitburner.successresult.md
Normal file
@@ -0,0 +1,12 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [bitburner](./bitburner.md) > [SuccessResult](./bitburner.successresult.md)
|
||||
|
||||
## SuccessResult type
|
||||
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
type SuccessResult<T extends object> = { success: true; message?: string } & T;
|
||||
```
|
||||
@@ -4,7 +4,7 @@ import { CodingContractTypes } from "./ContractTypes";
|
||||
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
|
||||
import { ContractFilePath, resolveContractFilePath } from "../Paths/ContractFilePath";
|
||||
import { assertObject } from "../utils/TypeAssertion";
|
||||
import { Result } from "../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
import { CodingContractEventEmitter } from "./CodingContractEventEmitter";
|
||||
|
||||
// Numeric enum
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Player } from "@player";
|
||||
import { CorpResearchName, CorpSmartSupplyOption } from "@nsdefs";
|
||||
import type { CorpResearchName, CorpSmartSupplyOption, Result } from "@nsdefs";
|
||||
|
||||
import { MaterialInfo } from "./MaterialInfo";
|
||||
import { Corporation } from "./Corporation";
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
canCreateCorporation,
|
||||
convertCreatingCorporationCheckResultToMessage,
|
||||
} from "./helpers";
|
||||
import { PositiveInteger, Result } from "../types";
|
||||
import type { PositiveInteger } from "../types";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import { throwIfReachable } from "../utils/helpers/throwIfReachable";
|
||||
import { formatMoney, formatNumber } from "../ui/formatNumber";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PromisePair } from "../Types/Promises";
|
||||
import { Player } from "@player";
|
||||
import { CorpStateName, InvestmentOffer } from "@nsdefs";
|
||||
import type { CorpStateName, InvestmentOffer, Result } from "@nsdefs";
|
||||
import { CorpUnlockName, CorpUpgradeName, LiteratureName } from "@enums";
|
||||
import { CorporationState } from "./CorporationState";
|
||||
import { CorpUnlocks } from "./data/CorporationUnlocks";
|
||||
@@ -17,7 +17,7 @@ import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
|
||||
import { JSONMap, JSONSet } from "../Types/Jsonable";
|
||||
import { formatMoney } from "../ui/formatNumber";
|
||||
import { isPositiveInteger, type Result } from "../types";
|
||||
import { isPositiveInteger } from "../types";
|
||||
import { createEnumKeyedRecord, getRecordValues } from "../Types/Record";
|
||||
import { getKeyList } from "../utils/helpers/getKeyList";
|
||||
import { assertObject } from "../utils/TypeAssertion";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Reviver } from "../utils/GenericReviver";
|
||||
import { BaseGift } from "./BaseGift";
|
||||
|
||||
import { StaneksGift } from "./StaneksGift";
|
||||
import { Result } from "../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
import { isStanekGiftImplemented } from "../utils/ErrorHelper";
|
||||
|
||||
export let staneksGift = new StaneksGift();
|
||||
|
||||
@@ -458,6 +458,7 @@ import nsDoc_bitburner_factionworktask_factionworktype_md from "../../markdown/b
|
||||
import nsDoc_bitburner_factionworktask_md from "../../markdown/bitburner.factionworktask.md?raw";
|
||||
import nsDoc_bitburner_factionworktask_type_md from "../../markdown/bitburner.factionworktask.type.md?raw";
|
||||
import nsDoc_bitburner_factionworktype_md from "../../markdown/bitburner.factionworktype.md?raw";
|
||||
import nsDoc_bitburner_failureresult_md from "../../markdown/bitburner.failureresult.md?raw";
|
||||
import nsDoc_bitburner_filemetadata_atime_md from "../../markdown/bitburner.filemetadata.atime.md?raw";
|
||||
import nsDoc_bitburner_filemetadata_btime_md from "../../markdown/bitburner.filemetadata.btime.md?raw";
|
||||
import nsDoc_bitburner_filemetadata_md from "../../markdown/bitburner.filemetadata.md?raw";
|
||||
@@ -1151,6 +1152,7 @@ import nsDoc_bitburner_resetinfo_lastnodereset_md from "../../markdown/bitburner
|
||||
import nsDoc_bitburner_resetinfo_md from "../../markdown/bitburner.resetinfo.md?raw";
|
||||
import nsDoc_bitburner_resetinfo_ownedaugs_md from "../../markdown/bitburner.resetinfo.ownedaugs.md?raw";
|
||||
import nsDoc_bitburner_resetinfo_ownedsf_md from "../../markdown/bitburner.resetinfo.ownedsf.md?raw";
|
||||
import nsDoc_bitburner_result_md from "../../markdown/bitburner.result.md?raw";
|
||||
import nsDoc_bitburner_runningscript_args_md from "../../markdown/bitburner.runningscript.args.md?raw";
|
||||
import nsDoc_bitburner_runningscript_dynamicramusage_md from "../../markdown/bitburner.runningscript.dynamicramusage.md?raw";
|
||||
import nsDoc_bitburner_runningscript_filename_md from "../../markdown/bitburner.runningscript.filename.md?raw";
|
||||
@@ -1388,6 +1390,7 @@ import nsDoc_bitburner_studytask_classtype_md from "../../markdown/bitburner.stu
|
||||
import nsDoc_bitburner_studytask_location_md from "../../markdown/bitburner.studytask.location.md?raw";
|
||||
import nsDoc_bitburner_studytask_md from "../../markdown/bitburner.studytask.md?raw";
|
||||
import nsDoc_bitburner_studytask_type_md from "../../markdown/bitburner.studytask.type.md?raw";
|
||||
import nsDoc_bitburner_successresult_md from "../../markdown/bitburner.successresult.md?raw";
|
||||
import nsDoc_bitburner_tailproperties_fontsize_md from "../../markdown/bitburner.tailproperties.fontsize.md?raw";
|
||||
import nsDoc_bitburner_tailproperties_height_md from "../../markdown/bitburner.tailproperties.height.md?raw";
|
||||
import nsDoc_bitburner_tailproperties_md from "../../markdown/bitburner.tailproperties.md?raw";
|
||||
@@ -1968,6 +1971,7 @@ AllPages["nsDoc/bitburner.factionworktask.factionworktype.md"] = nsDoc_bitburner
|
||||
AllPages["nsDoc/bitburner.factionworktask.md"] = nsDoc_bitburner_factionworktask_md;
|
||||
AllPages["nsDoc/bitburner.factionworktask.type.md"] = nsDoc_bitburner_factionworktask_type_md;
|
||||
AllPages["nsDoc/bitburner.factionworktype.md"] = nsDoc_bitburner_factionworktype_md;
|
||||
AllPages["nsDoc/bitburner.failureresult.md"] = nsDoc_bitburner_failureresult_md;
|
||||
AllPages["nsDoc/bitburner.filemetadata.atime.md"] = nsDoc_bitburner_filemetadata_atime_md;
|
||||
AllPages["nsDoc/bitburner.filemetadata.btime.md"] = nsDoc_bitburner_filemetadata_btime_md;
|
||||
AllPages["nsDoc/bitburner.filemetadata.md"] = nsDoc_bitburner_filemetadata_md;
|
||||
@@ -2661,6 +2665,7 @@ AllPages["nsDoc/bitburner.resetinfo.lastnodereset.md"] = nsDoc_bitburner_resetin
|
||||
AllPages["nsDoc/bitburner.resetinfo.md"] = nsDoc_bitburner_resetinfo_md;
|
||||
AllPages["nsDoc/bitburner.resetinfo.ownedaugs.md"] = nsDoc_bitburner_resetinfo_ownedaugs_md;
|
||||
AllPages["nsDoc/bitburner.resetinfo.ownedsf.md"] = nsDoc_bitburner_resetinfo_ownedsf_md;
|
||||
AllPages["nsDoc/bitburner.result.md"] = nsDoc_bitburner_result_md;
|
||||
AllPages["nsDoc/bitburner.runningscript.args.md"] = nsDoc_bitburner_runningscript_args_md;
|
||||
AllPages["nsDoc/bitburner.runningscript.dynamicramusage.md"] = nsDoc_bitburner_runningscript_dynamicramusage_md;
|
||||
AllPages["nsDoc/bitburner.runningscript.filename.md"] = nsDoc_bitburner_runningscript_filename_md;
|
||||
@@ -2898,6 +2903,7 @@ AllPages["nsDoc/bitburner.studytask.classtype.md"] = nsDoc_bitburner_studytask_c
|
||||
AllPages["nsDoc/bitburner.studytask.location.md"] = nsDoc_bitburner_studytask_location_md;
|
||||
AllPages["nsDoc/bitburner.studytask.md"] = nsDoc_bitburner_studytask_md;
|
||||
AllPages["nsDoc/bitburner.studytask.type.md"] = nsDoc_bitburner_studytask_type_md;
|
||||
AllPages["nsDoc/bitburner.successresult.md"] = nsDoc_bitburner_successresult_md;
|
||||
AllPages["nsDoc/bitburner.tailproperties.fontsize.md"] = nsDoc_bitburner_tailproperties_fontsize_md;
|
||||
AllPages["nsDoc/bitburner.tailproperties.height.md"] = nsDoc_bitburner_tailproperties_height_md;
|
||||
AllPages["nsDoc/bitburner.tailproperties.md"] = nsDoc_bitburner_tailproperties_md;
|
||||
|
||||
@@ -20,7 +20,7 @@ import { SFC32RNG } from "../Casino/RNG";
|
||||
import { isFactionWork } from "../Work/FactionWork";
|
||||
import { getAugCost } from "../Augmentation/AugmentationHelpers";
|
||||
import { getRecordKeys } from "../Types/Record";
|
||||
import type { Result } from "../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
|
||||
export function inviteToFaction(faction: Faction): void {
|
||||
if (faction.alreadyInvited || faction.isMember) return;
|
||||
|
||||
@@ -25,7 +25,7 @@ import { Companies } from "../Company/Companies";
|
||||
import { isMember } from "../utils/EnumHelper";
|
||||
import { canAccessBitNodeFeature } from "../BitNode/BitNodeUtils";
|
||||
import { checkServerOwnership, ServerOwnershipType } from "../Server/ServerHelpers";
|
||||
import { Result } from "../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
||||
import { HashUpgradeEnum } from "./Enums";
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { HashUpgrades } from "./HashUpgrades";
|
||||
import { HashUpgrade } from "./HashUpgrade";
|
||||
|
||||
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
|
||||
import { Result } from "../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
import { HashUpgradeEnum } from "./Enums";
|
||||
|
||||
export class HashManager {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper";
|
||||
import { Infiltration as NetscriptInfiltation, InfiltrationLocation } from "@nsdefs";
|
||||
import type { Infiltration as NetscriptInfiltation, InfiltrationLocation } from "@nsdefs";
|
||||
import { FactionName, LocationName } from "@enums";
|
||||
import { Location } from "../Locations/Location";
|
||||
import { Locations } from "../Locations/Locations";
|
||||
|
||||
@@ -25,7 +25,7 @@ import { roundToTwo } from "./utils/helpers/roundToTwo";
|
||||
|
||||
import { parseCommand } from "./Terminal/Parser";
|
||||
import { Terminal } from "./Terminal";
|
||||
import { ScriptArg } from "@nsdefs";
|
||||
import type { ScriptArg, Result } from "@nsdefs";
|
||||
import { CompleteRunOptions, getRunningScriptsByArgs } from "./Netscript/NetscriptHelpers";
|
||||
import { handleUnknownError } from "./utils/ErrorHandler";
|
||||
import { isLegacyScript, resolveScriptFilePath, ScriptFilePath } from "./Paths/ScriptFilePath";
|
||||
@@ -33,7 +33,6 @@ import { Player } from "@player";
|
||||
import { UIEventEmitter, UIEventType } from "./ui/UIEventEmitter";
|
||||
import { getErrorMessageWithStackAndCause } from "./utils/ErrorHelper";
|
||||
import { exceptionAlert } from "./utils/helpers/exceptionAlert";
|
||||
import { Result } from "./types";
|
||||
|
||||
export const NetscriptPorts = new Map<PortNumber, Port>();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Gang } from "../../Gang/Gang";
|
||||
import { GangConstants } from "../../Gang/data/Constants";
|
||||
import { isFactionWork } from "../../Work/FactionWork";
|
||||
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
|
||||
import { Result } from "../../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
|
||||
export function canAccessGang(this: PlayerObject): Result {
|
||||
if (this.bitNodeOptions.disableGang) {
|
||||
|
||||
@@ -54,7 +54,7 @@ import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
|
||||
import { AlertEvents } from "../../ui/React/AlertManager";
|
||||
import { Augmentations } from "../../Augmentation/Augmentations";
|
||||
import { PlayerEventType, PlayerEvents } from "./PlayerEvents";
|
||||
import { Result } from "../../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
import type { AchievementId } from "../../Achievements/Types";
|
||||
import { Infiltration } from "../../Infiltration/Infiltration";
|
||||
|
||||
|
||||
7
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
7
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@@ -3,6 +3,13 @@
|
||||
*/
|
||||
type _ValueOf<T> = T[keyof T];
|
||||
|
||||
/** @public */
|
||||
type SuccessResult<T extends object> = { success: true; message?: string } & T;
|
||||
/** @public */
|
||||
type FailureResult = { success: false; message: string };
|
||||
/** @public */
|
||||
type Result<T extends object = object> = SuccessResult<T> | FailureResult;
|
||||
|
||||
/** All netscript definitions */
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ import { defaultStyles } from "../Themes/Styles";
|
||||
import { CursorStyle, CursorBlinking, WordWrapOptions, StickyScroll } from "../ScriptEditor/ui/Options";
|
||||
import { defaultMonacoTheme } from "../ScriptEditor/ui/themes";
|
||||
import { assertObject } from "../utils/TypeAssertion";
|
||||
import { Result } from "../types";
|
||||
import type { Result } from "@nsdefs";
|
||||
import {
|
||||
assertAndSanitizeEditorTheme,
|
||||
assertAndSanitizeKeyBindings,
|
||||
|
||||
@@ -31,10 +31,6 @@ export interface IReturnStatus {
|
||||
msg?: string;
|
||||
}
|
||||
|
||||
type SuccessResult<T extends object> = { success: true; message?: string } & T;
|
||||
type FailureResult = { success: false; message: string };
|
||||
export type Result<T extends object = object> = SuccessResult<T> | FailureResult;
|
||||
|
||||
/** Defines the minimum and maximum values for a range.
|
||||
* It is up to the consumer if these values are inclusive or exclusive.
|
||||
* It is up to the implementor to ensure max > min. */
|
||||
|
||||
Reference in New Issue
Block a user