slint-ui/slint · error
write typescript/generated/language.ts
Error message
write typescript/generated/language.ts
What it means
Error "write typescript/generated/language.ts" thrown in slint-ui/slint.
Source
Thrown at api/node/build.rs:202
for (field, rust_ty, field_docs, _) in &s.fields {
write_jsdoc(&mut ts, " ", field_docs);
ts.push_str(&format!(
" {field}: {ts_ty};\n",
ts_ty = map_field_type(rust_ty, &in_language),
));
}
ts.push_str(" };\n");
}
ts.push_str("}\n");
let out_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("typescript").join("generated");
std::fs::create_dir_all(&out_dir).expect("create typescript/generated directory");
let out_path = out_dir.join("language.ts");
// Only write if the content actually changed, so we don't invalidate downstream builds.
let need_write =
std::fs::read_to_string(&out_path).map(|existing| existing != ts).unwrap_or(true);
if need_write {
std::fs::write(&out_path, ts).expect("write typescript/generated/language.ts");
}
}
/// Map a Rust field type (as stringified by the macro) to the TS type used in the generated
/// language module. Fails the build with a clear message when a new struct adds an unmapped
/// type — better than silently emitting `unknown`.
fn map_field_type(rust_ty: &str, in_language: &HashSet<&'static str>) -> String {
let t = rust_ty.trim();
match t {
"bool" => "boolean".to_string(),
"i32" | "f32" | "f64" | "Coord" => "number".to_string(),
"SharedString" => "string".to_string(),
// Types exposed by the binding outside the `language` namespace.
"DataTransfer" => "DataTransfer".to_string(),
"LogicalPosition" => "{ x: number; y: number }".to_string(),
ident if in_language.contains(ident) => ident.to_string(),
other => panic!(
"Unmapped struct field type `{other}` in for_each_builtin_structs!. \View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Ensure the build script can write typescript/generated/language.ts.
- Check disk space and file permissions.
When it happens
Trigger: Thrown at api/node/build.rs:202 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/c95725afb10637af.
Report an issue: GitHub.