You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pnpm create tauri-app@latest
✔ Project name · tauri-app
✔ Identifier · com.tauri-app.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
✔ Choose your package manager · pnpm
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · TypeScript
2. Add specta:
[package]
name = "tauri-app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary# to make the lib name unique and wouldn't conflict with the bin name.# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "tauri_app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
+ specta = { version = "2.0.0-rc" }+ tauri-specta = { version = "2.0.0-rc", features = ["derive", "typescript"] }+ specta-typescript = { version = "0.0.7" }
3. Modify lib.rs to:
use serde::{Deserialize,Serialize};use specta::Type;use tauri::Wry;// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/#[tauri::command]#[specta::specta]fngreet(name:&str) -> String{format!("Hello, {}! You've been greeted from Rust!", name)}#[derive(Default,Debug,Clone,PartialEq,Serialize,Deserialize,Type)]pubstructTestStruct{pubfield:String,}#[tauri::command]#[specta::specta]fntest() -> TestStruct{TestStruct{field:"Hello, World!".to_string(),}}#[cfg_attr(mobile, tauri::mobile_entry_point)]pubfnrun(){let builder = tauri_specta::Builder::<Wry>::new().commands(tauri_specta::collect_commands![greet]).events(tauri_specta::collect_events![]);#[cfg(debug_assertions)]
builder
.export(
specta_typescript::Typescript::default().bigint(specta_typescript::BigIntExportBehavior::Number).formatter(specta_typescript::formatter::prettier).header("// @ts-nocheck"),"../src/bindings.ts",).expect("Failed to export typescript bindings");
tauri::Builder::default().plugin(tauri_plugin_opener::init()).invoke_handler(builder.invoke_handler()).run(tauri::generate_context!()).expect("error while running tauri application");}
4. You will see the error message:
error[E0433]: failed to resolve: use of undeclared crate or module `specta_util`
--> src\lib.rs:12:68
|
12 | #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Type)]
| ^^^^ use of undeclared crate or module `specta_util`
I noticed that the dependencies in Tauri v2.2.0 include specta-util, but Tauri v2.1.1 does not have specta-util.
Additionally, I have a Tauri v2.1.1 project that can use specta without any issues.
The text was updated successfully, but these errors were encountered:
Reproduce (step by step):
1. Create a new Tauri project:
2. Add specta:
3. Modify
lib.rs
to:4. You will see the error message:
I noticed that the dependencies in
Tauri v2.2.0
includespecta-util
, butTauri v2.1.1
does not havespecta-util
.Additionally, I have a
Tauri v2.1.1
project that can use specta without any issues.The text was updated successfully, but these errors were encountered: