dotnet/aspnetcore · error · Error

Unknown type ' ' for parameter

Error message

Unknown type '${type}' for parameter '${parameterName}'

What it means

Thrown by parseAttributeValue's default case when the parameter's registered type string is none of 'string', 'boolean', 'number', 'boolean?', 'number?', 'object'. This indicates a mismatch between the JSComponentParameter type vocabulary the framework understands and what was supplied during custom-element registration — typically a framework/registration bug rather than an end-user mistake.

Solutions

  1. Rebuild and reload the Blazor custom-elements JS assets so the parameter descriptors match the runtime's expected vocabulary.
  2. Verify the type field in the emitted parameter list uses only the supported union members.
  3. If you author descriptors manually, restrict type values to 'string' | 'boolean' | 'number' | 'boolean?' | 'number?' | 'object'.
  4. Check for version skew between the server-side rendering of parameter metadata and the client-side parser.

Example fix

// before (manual descriptor using a .NET type name)
customElements.define('my-comp', class extends BlazorCustomElement {
  static get observedAttributes() { return ['count']; }
  // parameter type 'Int32' is invalid
});

// after — use the framework's JSComponentParameter vocabulary
parameters: [{ name: 'Count', type: 'number' }]
Defensive patterns

Strategy: validation

Validate before calling

// Validate parameter descriptors before registering a custom element.
const ALLOWED_TYPES = new Set(['string','boolean','number','boolean?','number?','object']);
function validateParameters(parameters) {
  for (const p of parameters) {
    if (!ALLOWED_TYPES.has(p.type)) {
      throw new Error(`Unsupported parameter type '${p.type}' for '${p.name}'`);
    }
  }
}

Type guard

function isKnownParameterType(t) {
  return ['string','boolean','number','boolean?','number?','object'].includes(t);
}

Prevention

When it happens

Trigger: RegisterAsCustomElement emits a parameter descriptor whose 'type' field contains an unsupported value (e.g. 'int', 'double', 'DateTime', 'long', a fully-qualified .NET type name, or undefined). The attributeChangedCallback routes that into parseAttributeValue and falls through to default.

Common situations: Upgrading the Blazor runtime to a version with a changed JSComponentParameterType union without rebuilding the custom-elements JS bundle; hand-written parameter descriptors using .NET type names; a serializer that omits or renames the type field.

Related errors


AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11). Data as JSON: /api/errors/339e4793e78173bd. Report an issue: GitHub.

Appendix: source

Thrown at src/Components/CustomElements/src/js/BlazorCustomElements.ts:136

            return false;
          default:
            throw new Error(`Invalid boolean value '${attributeValue}' for parameter '${parameterName}'`);
        }
      case 'number':
        const number = Number(attributeValue);
        if (Number.isNaN(number)) {
          throw new Error(`Invalid number value '${attributeValue}' for parameter '${parameterName}'`);
        } else {
          return number;
        }
      case 'boolean?':
        return attributeValue ? BlazorCustomElement.parseAttributeValue(attributeValue, 'boolean', parameterName) : null;
      case 'number?':
        return attributeValue ? BlazorCustomElement.parseAttributeValue(attributeValue, 'number', parameterName) : null;
      case 'object':
        throw new Error(`The parameter '${parameterName}' accepts a complex-typed object so it cannot be set using an attribute. Try setting it as a element property instead.`);
      default:
        throw new Error(`Unknown type '${type}' for parameter '${parameterName}'`);
    }
  }
}

function dasherize(value: string): string {
  return camelCase(value).replace(/([A-Z])/g, "-$1").toLowerCase();
}

function camelCase(value: string): string {
  return value[0].toLowerCase() + value.substring(1);
}

interface JSComponentParameter {
  name: string;
  type: JSComponentParameterType;
}

// JSON-primitive types, plus for those whose .NET equivalent isn't nullable, a '?' to indicate nullability

View on GitHub (pinned to 3600ca084e)