About
tauri-named-invoke
is a small utility that generates a typescript declaration file for the invoke
function from functions found in code by Tauri commands.
Thanks to this, there is no mistaking the name of the command.
Example
main.rs:
// or
use command;
build.rs:
The file will be generated at the following path:
project root
├── ui
│ └── invoke.d.ts
├── src
│ └── main.rs
└── Cargo.toml
The generated file will contain:
import * as tauri from '@tauri-apps/api/tauri';
declare module '@tauri-apps/api' {
type Commands =
'get_weather'
| 'get_config';
function invoke<T>(cmd: Commands, args?: InvokeArgs): Promise<T>;
}