{"record":{"id":"339e4793e78173bd","repo":"dotnet/aspnetcore","slug":"unknown-type-type-for-parameter-parametern","errorCode":null,"errorMessage":"Unknown type '${type}' for parameter '${parameterName}'","messagePattern":"Unknown type '(.+?)' for parameter '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/CustomElements/src/js/BlazorCustomElements.ts","lineNumber":136,"sourceCode":"            return false;\n          default:\n            throw new Error(`Invalid boolean value '${attributeValue}' for parameter '${parameterName}'`);\n        }\n      case 'number':\n        const number = Number(attributeValue);\n        if (Number.isNaN(number)) {\n          throw new Error(`Invalid number value '${attributeValue}' for parameter '${parameterName}'`);\n        } else {\n          return number;\n        }\n      case 'boolean?':\n        return attributeValue ? BlazorCustomElement.parseAttributeValue(attributeValue, 'boolean', parameterName) : null;\n      case 'number?':\n        return attributeValue ? BlazorCustomElement.parseAttributeValue(attributeValue, 'number', parameterName) : null;\n      case 'object':\n        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.`);\n      default:\n        throw new Error(`Unknown type '${type}' for parameter '${parameterName}'`);\n    }\n  }\n}\n\nfunction dasherize(value: string): string {\n  return camelCase(value).replace(/([A-Z])/g, \"-$1\").toLowerCase();\n}\n\nfunction camelCase(value: string): string {\n  return value[0].toLowerCase() + value.substring(1);\n}\n\ninterface JSComponentParameter {\n  name: string;\n  type: JSComponentParameterType;\n}\n\n// JSON-primitive types, plus for those whose .NET equivalent isn't nullable, a '?' to indicate nullability","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/CustomElements/src/js/BlazorCustomElements.ts#L118-L154","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rebuild and reload the Blazor custom-elements JS assets so the parameter descriptors match the runtime's expected vocabulary.","Verify the type field in the emitted parameter list uses only the supported union members.","If you author descriptors manually, restrict type values to 'string' | 'boolean' | 'number' | 'boolean?' | 'number?' | 'object'.","Check for version skew between the server-side rendering of parameter metadata and the client-side parser."],"exampleFix":"// before (manual descriptor using a .NET type name)\ncustomElements.define('my-comp', class extends BlazorCustomElement {\n  static get observedAttributes() { return ['count']; }\n  // parameter type 'Int32' is invalid\n});\n\n// after — use the framework's JSComponentParameter vocabulary\nparameters: [{ name: 'Count', type: 'number' }]","handlingStrategy":"validation","validationCode":"// Validate parameter descriptors before registering a custom element.\nconst ALLOWED_TYPES = new Set(['string','boolean','number','boolean?','number?','object']);\nfunction validateParameters(parameters) {\n  for (const p of parameters) {\n    if (!ALLOWED_TYPES.has(p.type)) {\n      throw new Error(`Unsupported parameter type '${p.type}' for '${p.name}'`);\n    }\n  }\n}","typeGuard":"function isKnownParameterType(t) {\n  return ['string','boolean','number','boolean?','number?','object'].includes(t);\n}","tryCatchPattern":null,"preventionTips":["Rebuild custom-elements JS assets alongside runtime upgrades.","Restrict descriptor type strings to the framework's vocabulary.","Add a startup assertion that emits the parameter list and validates types.","Watch for version skew between server-emitted metadata and client parser."],"tags":["blazor-custom-elements","attribute-parsing","type-mismatch","registration"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}