{"record":{"id":"f71a96d56452b92a","repo":"gleam-lang/gleam","slug":"name-is-not-a-built-in-type","errorCode":null,"errorMessage":"{name} is not a built-in type.","messagePattern":"(.+?) is not a built-in type\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-core/src/javascript/typescript.rs","lineNumber":1181,"sourceCode":"                    )\n                ]\n            }\n            \"Result\" => {\n                self.tracker.prelude_used = true;\n                docvec![\n                    arena,\n                    UNDERSCORE_DOT_RESULT_DOCUMENT,\n                    wrap_generic_arguments(\n                        arena,\n                        arguments\n                            .iter()\n                            .map(|x| self.do_print(arena, x, generic_printing))\n                    )\n                ]\n            }\n            // Getting here should mean we either forgot a built-in type or there is a\n            // compiler error\n            name => panic!(\"{name} is not a built-in type.\"),\n        }\n    }\n\n    /// Prints a \"named\" programmer-defined Gleam type into the TypeScript\n    /// equivalent.\n    ///\n    fn print_type_app(\n        &mut self,\n        arena: &'doc DocumentArena<'a, 'doc>,\n        name: &str,\n        arguments: &[Arc<Type>],\n        module: &str,\n        generic_printing: GenericPrinting<'_>,\n    ) -> Document<'a, 'doc> {\n        let name = eco_format!(\"{}$\", ts_safe_type_name(name.to_string()));\n        let name = match module == self.module.name {\n            true => name.to_doc(arena),\n            false => {","sourceCodeStart":1163,"sourceCodeEnd":1199,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-core/src/javascript/typescript.rs#L1163-L1199","documentation":"The TypeScript prelude printer (`print_prelude_type`) maps built-in Gleam types (String, Int, Float, Bool, List, Result, BitArray, UtfCodepoint, etc.) to their TypeScript prelude equivalents. Any other type name reaching it is a compiler error, so it panics with the offending name.","triggerScenarios":"A type whose name is not a recognized built-in is printed as a prelude type — typically when a new built-in type is added to the core language but not registered in `typescript.rs`, or when internals pass a non-builtin type to prelude printing.","commonSituations":"Gleam compiler development adding language built-ins; tooling invoking the TypeScript printer with custom/core types it wasn't designed for.","solutions":["Check the panic message for the type name and add a matching arm in `print_prelude_type` (compiler development).","Ensure programmer-defined types go through the named-type printing path, not the prelude path.","If triggered by ordinary user code, file a Gleam compiler bug with the reported type name."],"exampleFix":"// before (in print_prelude_type)\nname => panic!(\"{name} is not a built-in type.\")\n// after (during development of a new builtin)\n\"MyNewType\" => Ok(\"MyNewType\".to_string()),\nname => panic!(\"{name} is not a built-in type.\")","handlingStrategy":"validation","validationCode":"// route only built-ins through prelude printing\nconst BUILTINS: &[&str] = &[\"Int\",\"Float\",\"String\",\"Bool\",\"List\",\"Result\",\"BitArray\",\"UtfCodepoint\"];\nif !BUILTINS.contains(&name.as_str()) {\n    return print_named_type(name); // named path instead of prelude\n}","typeGuard":"fn is_builtin_type(name: &str) -> bool {\n    matches!(name, \"Int\" | \"Float\" | \"String\" | \"Bool\" | \"List\" | \"Result\" | \"BitArray\" | \"UtfCodepoint\")\n}","tryCatchPattern":"match std::panic::catch_unwind(|| print_prelude_type(t)) {\n    Ok(s) => s,\n    Err(_) => fallback_to_named_type_printing(t),\n}","preventionTips":["Ensure user-defined types use the named-type printing path.","When adding a language built-in, update print_prelude_type in typescript.rs in the same change.","Capture the type name from the panic message to speed up bug reports."],"tags":["compiler","panic","typescript","prelude"],"backgroundTag":"internal-invariant-violation","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}