unoplatform/uno · error · NotSupportedException

GetTSType: The type {type} is not supported (SpecialType: {t

Error message

GetTSType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})

What it means

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.

Source

Thrown at src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs:551

				type.SpecialType == SpecialType.System_Int32 ||
				type.SpecialType == SpecialType.System_UInt32 ||
				type.SpecialType == SpecialType.System_Single ||
				type.SpecialType == SpecialType.System_Double ||
				type.SpecialType == SpecialType.System_Byte ||
				type.SpecialType == SpecialType.System_Int16 ||
				type.SpecialType == SpecialType.System_IntPtr ||
				type.SpecialType == SpecialType.System_UIntPtr
			)
			{
				return "Number";
			}
			else if (type.SpecialType == SpecialType.System_Boolean)
			{
				return "Boolean";
			}
			else
			{
				throw new NotSupportedException($"GetTSType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})");
			}
		}

		private static string GetTSFieldType(ITypeSymbol type)
		{
			if (type == null)
			{
				throw new ArgumentNullException(nameof(type));
			}

			if (type is IArrayTypeSymbol array)
			{
				return $"Array<{GetTSFieldType(array.ElementType)}>";
			}
			else if (type.SpecialType == SpecialType.System_String)
			{
				return "string";
			}

View on GitHub (pinned to 0418340488)

Solutions

  1. 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.
  2. If the complex type is required, serialize it to a supported primitive (e.g. a JSON string) before exposing it to EM bindings.
  3. Exclude the struct from TS binding generation if it cannot be represented in the supported type set.

Example fix

// before
public struct MyInteropData { public MyEnum State; public decimal Amount; }
// after
public struct MyInteropData { public int State; public double Amount; }
Defensive patterns

Strategy: type-guard

Type guard

private static readonly HashSet<Type> _supported = new()
{
    typeof(string), typeof(int), typeof(uint), typeof(float), typeof(double),
    typeof(byte), typeof(short), typeof(IntPtr), typeof(UIntPtr), typeof(bool)
};

static bool IsSupportedEmFieldType(Type t)
    => _supported.Contains(Nullable.GetUnderlyingType(t) ?? t)
       || (t.IsArray && IsSupportedEmFieldType(t.GetElementType()));

// usage: assert IsSupportedEmFieldType(field.FieldType) before building

Prevention

When it happens

Trigger: 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>.

Common situations: 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.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/0e699aa501ea36af. Report an issue: GitHub.