TypeScript support
The JavaScript SDK also has built-in support for TypeScript. TypeScript is a typed superset of JavaScript that brings stricter typing to JavaScript (a normally loosely typed language).
When using exported functions from the JavaScript/TypeScript SDK, compatible editors will warn about:
- Unexpected, missing or invalid props being passed to functions as inputs.
- Input/output types being different than specified.
- And more…
These warns will also be shown in your terminal when running tsc there.
Types (TBD)
Section titled “Types (TBD)”The SDK has the following developer-facing types:
NeuroClient
Section titled “NeuroClient”The NeuroClient class has a TypeScript declaration of the following:
Properties
Section titled “Properties”ws?:string- The WebSocket connection.game:string- The game name.url:string- The WebSocket server URL (should start withws://)actionHandlers:((actionData: { id: string; name: string; params: any; }) => void)[]- An array of action handlers.
Methods
Section titled “Methods”constructor- NeuroClient constructor. Params:url: string, game: string, onConnected: () => voidsendContext:void- Context send function. Params:messageText: string, silent?: booleanregisterActions:void- Registers an action for Neuro to use. Params:actions:ActionDetails[]
Action packets
Section titled “Action packets”When using actions/register the action details follow the below interface:
interface ActionDetails { name: string; description: string; schema?: any;}Which is then used in this packet:
interface ActionsRegister { command: "actions/register"; game: string; data: { actions: ActionDetails[]; };}