Module near_syn::ts

source · []
Expand description

Functions to transpile Rust to TypeScript.

Functions

Exports the methods object required by near-api-js to be able to find contract methods.

Translates doc attributes into TypeScript docs. The indent argument is used as a prefix for each line emitted.

Translates an enum to a TypeScript enum or type according to the Rust definition. The Rust enum must derive Serialize from serde in order to be translated.

Emits additional extensions for the main type implemented by the contract. This is used when the contract implements one or more traits. The name and interfaces fields must be set in order to emit these additional extensions.

Translates an impl section to a TypeScript interface.

Translates a collection of Rust items to TypeScript. It currently translates type, struct, enum and impl items to TypeScript. It traverses recursively mod definitions with braced content. The inner mod’ items are flatten into a single TypeScript module. If an item in items is not one of the mentioned above, it is ignored.

Exports common NEAR Rust SDK types based on https://docs.rs/near-sdk/4.0.0-pre.4/near_sdk/. Moreover, it adds a header indicating the time and binary that generated these bindings.

Returns the TypeScript representation of output’s type given the Rust ret_type. The resulting TypeScript return type is a valid output type expected by the NEAR RPC. Thus, the following conversion are applied:

Returns the signature of the given Rust method. The resulting TypeScript binding is a valid method definition expected by the NEAR RPC. Thus, the following conversion are applied:

Generates the corresponding TypeScript bindings for the given struct. Doc-comments embedded in the Rust source file are included in the bindings. The struct must derive Serialize from serde in order to generate its corresponding TypeScript bindings.

Return the TypeScript equivalent type of the Rust type represented by ty.

Translates a type alias to another type alias in TypeScript.