{"record":{"id":"0e699aa501ea36af","repo":"unoplatform/uno","slug":"gettstype-the-type-type-is-not-supported-speci","errorCode":null,"errorMessage":"GetTSType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})","messagePattern":"GetTSType: 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":551,"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($\"GetTSType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})\");\n\t\t\t}\n\t\t}\n\n\t\tprivate static string GetTSFieldType(ITypeSymbol type)\n\t\t{\n\t\t\tif (type == null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentNullException(nameof(type));\n\t\t\t}\n\n\t\t\tif (type is IArrayTypeSymbol array)\n\t\t\t{\n\t\t\t\treturn $\"Array<{GetTSFieldType(array.ElementType)}>\";\n\t\t\t}\n\t\t\telse if (type.SpecialType == SpecialType.System_String)\n\t\t\t{\n\t\t\t\treturn \"string\";\n\t\t\t}","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs#L533-L569","documentation":"GetTSType maps a fixed allow-list of .NET special types (string, the numeric primitives, IntPtr/UIntPtr, bool, and arrays thereof) to TypeScript type names for the WASM EM bindings. Any field whose type is not in that allow-list — enums, custom structs, decimal, DateTime, Guid, nullable<T>, etc. — falls through to this NotSupportedException, reporting the SpecialType and OriginalDefinition to aid diagnosis.","triggerScenarios":"A struct field exposed for EM bindings has a type outside the supported set, e.g. an enum, a nested custom value type, decimal, DateTime, Guid, or Nullable<T>.","commonSituations":"Adding a new field of an unsupported type (an enum or a nested struct) to a struct that the TSBindingsGenerator processes; upgrading a field from int to decimal.","solutions":["Read the reported SpecialType/OriginalDefinition and change the offending field to a supported primitive (int, double, bool, string, byte, etc.) or an array of one.","If the complex type is required, serialize it to a supported primitive (e.g. a JSON string) before exposing it to EM bindings.","Exclude the struct from TS binding generation if it cannot be represented in the supported type set."],"exampleFix":"// before\npublic struct MyInteropData { public MyEnum State; public decimal Amount; }\n// after\npublic struct MyInteropData { public int State; public double Amount; }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"private static readonly HashSet<Type> _supported = new()\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\nstatic bool IsSupportedEmFieldType(Type t)\n    => _supported.Contains(Nullable.GetUnderlyingType(t) ?? t)\n       || (t.IsArray && IsSupportedEmFieldType(t.GetElementType()));\n\n// usage: assert IsSupportedEmFieldType(field.FieldType) before building","tryCatchPattern":null,"preventionTips":["Restrict EM-bound struct fields to the supported primitive set (string, int/uint, float/double, byte, short, IntPtr/UIntPtr, bool) and arrays of those.","Run a unit test asserting IsSupportedEmFieldType over every field of interop structs."],"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"}