{"record":{"id":"a3f99552c6c77f23","repo":"slint-ui/slint","slug":"create-typescript-generated-directory","errorCode":null,"errorMessage":"create typescript/generated directory","messagePattern":"create typescript/generated directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/node/build.rs","lineNumber":196,"sourceCode":"            name = entry.name\n        ));\n    }\n    for s in &structs {\n        write_jsdoc(&mut ts, \"    \", &s.docs);\n        ts.push_str(&format!(\"    export type {name} = {{\\n\", name = s.name));\n        for (field, rust_ty, field_docs, _) in &s.fields {\n            write_jsdoc(&mut ts, \"        \", field_docs);\n            ts.push_str(&format!(\n                \"        {field}: {ts_ty};\\n\",\n                ts_ty = map_field_type(rust_ty, &in_language),\n            ));\n        }\n        ts.push_str(\"    };\\n\");\n    }\n    ts.push_str(\"}\\n\");\n\n    let out_dir = PathBuf::from(env!(\"CARGO_MANIFEST_DIR\")).join(\"typescript\").join(\"generated\");\n    std::fs::create_dir_all(&out_dir).expect(\"create typescript/generated directory\");\n    let out_path = out_dir.join(\"language.ts\");\n    // Only write if the content actually changed, so we don't invalidate downstream builds.\n    let need_write =\n        std::fs::read_to_string(&out_path).map(|existing| existing != ts).unwrap_or(true);\n    if need_write {\n        std::fs::write(&out_path, ts).expect(\"write typescript/generated/language.ts\");\n    }\n}\n\n/// Map a Rust field type (as stringified by the macro) to the TS type used in the generated\n/// language module. Fails the build with a clear message when a new struct adds an unmapped\n/// type — better than silently emitting `unknown`.\nfn map_field_type(rust_ty: &str, in_language: &HashSet<&'static str>) -> String {\n    let t = rust_ty.trim();\n    match t {\n        \"bool\" => \"boolean\".to_string(),\n        \"i32\" | \"f32\" | \"f64\" | \"Coord\" => \"number\".to_string(),\n        \"SharedString\" => \"string\".to_string(),","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/api/node/build.rs#L178-L214","documentation":"Error \"create typescript/generated directory\" thrown in slint-ui/slint.","triggerScenarios":"Thrown at api/node/build.rs:196 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the build script has write permission to create the typescript/generated directory.","Clean stale build artifacts and rebuild."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}