Skip to main content

TypescriptFunction

Attribute Macro TypescriptFunction 

Source
#[TypescriptFunction]
Expand description

为 Rust 函数生成 TypeScript 函数类型定义

§示例

use typescript_macros::TypescriptFunction;

#[TypescriptFunction]
fn add(a: u32, b: u32) -> u32 {
    a + b
}

这将生成对应的 TypeScript 函数类型定义:

type AddFunction = (a: number, b: number) => number;