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:
omuretsu
2022-10-12 08:49:27 -04:00
parent 41b6f0b87b
commit 7a384d53f4
20 changed files with 2845 additions and 3271 deletions

View File

@@ -961,7 +961,7 @@ export interface NetscriptPort {
*
* @returns The data popped off the queue if it was full.
*/
write(value: string | number): null | string | number;
write(value: string | number): PortData | null;
/**
* Attempt to write data to the port.
@@ -981,7 +981,7 @@ export interface NetscriptPort {
* If the port is empty, then the string “NULL PORT DATA” will be returned.
* @returns the data read.
*/
read(): string | number;
read(): PortData;
/**
* Retrieve the first element from the port without removing it.
@@ -993,7 +993,7 @@ export interface NetscriptPort {
* the port is empty, the string “NULL PORT DATA” will be returned.
* @returns the data read
*/
peek(): string | number;
peek(): PortData;
/**
* Check if the port is full.