{"record":{"id":"1345a389eaf19580","repo":"unoplatform/uno","slug":"gettsfieldtype-the-type-type-is-not-supported","errorCode":null,"errorMessage":"GetTSFieldType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})","messagePattern":"GetTSFieldType: The type (.+?) is not supported \\(SpecialType: (.+?), original type: (.+?)\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs","lineNumber":589,"sourceCode":"\t\t\t\ttype.SpecialType == SpecialType.System_Int32 ||\n\t\t\t\ttype.SpecialType == SpecialType.System_UInt32 ||\n\t\t\t\ttype.SpecialType == SpecialType.System_Single ||\n\t\t\t\ttype.SpecialType == SpecialType.System_Double ||\n\t\t\t\ttype.SpecialType == SpecialType.System_Byte ||\n\t\t\t\ttype.SpecialType == SpecialType.System_Int16 ||\n\t\t\t\ttype.SpecialType == SpecialType.System_IntPtr ||\n\t\t\t\ttype.SpecialType == SpecialType.System_UIntPtr\n\t\t\t)\n\t\t\t{\n\t\t\t\treturn \"number\";\n\t\t\t}\n\t\t\telse if (type.SpecialType == SpecialType.System_Boolean)\n\t\t\t{\n\t\t\t\treturn \"boolean\";\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new NotSupportedException($\"GetTSFieldType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})\");\n\t\t\t}\n\t\t}\n\n\t}\n}\n","sourceCodeStart":571,"sourceCodeEnd":595,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs#L571-L595","documentation":"GetTSFieldType emits lowercase TS types (string/number/boolean) for struct fields in the EM bindings. It throws NotSupportedException for any type outside its allow-list (string, numeric primitives, IntPtr/UIntPtr, bool, arrays), including the SpecialType and OriginalDefinition in the message for diagnosis.","triggerScenarios":"A struct field exposed for EM bindings has a type outside the supported set: enum, custom value type, decimal, DateTime, Guid, Nullable<T>, etc.","commonSituations":"Adding a field of an unsupported type to an EM-bound struct; switching a field from int to an enum or decimal.","solutions":["Change the offending field (named via its SpecialType/OriginalDefinition) to a supported primitive or an array of one.","Serialize complex types to a supported primitive before exposing them.","Remove the struct from TS binding generation if the type cannot be represented."],"exampleFix":"// before\npublic struct MyInteropData { public MyEnum State; }\n// after\npublic struct MyInteropData { public int State; }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static bool IsSupportedEmFieldType(Type t)\n{\n    var set = new HashSet<Type>\n    {\n        typeof(string), typeof(int), typeof(uint), typeof(float), typeof(double),\n        typeof(byte), typeof(short), typeof(IntPtr), typeof(UIntPtr), typeof(bool)\n    };\n    return set.Contains(t) || (t.IsArray && IsSupportedEmFieldType(t.GetElementType()));\n}","tryCatchPattern":null,"preventionTips":["Keep interop struct fields to the supported primitive set.","Add a build-time test enumerating struct fields against the allow-list."],"tags":["wasm","typescript","source-generator","emscripten","bindings","type-mapping"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}