AUR0760
Error Message
AUR0760: No element definition found for type <TypeName>
Where <TypeName> is the name of the class that was expected to be a custom element.
Description
This error occurs when Aurelia attempts to retrieve the definition metadata for a custom element class but fails to find it. Custom element definitions contain essential information like the element's name, template, bindables, dependencies, and other configurations, typically provided via the @customElement decorator or inferred through conventions.
Cause
The most common causes are:
Missing Decorator/Convention: The class intended to be a custom element is missing the
@customElementdecorator, and it doesn't follow a naming convention that allows Aurelia to automatically recognize it (e.g.,MyComponentCustomElementmapping tomy-component).Incorrect Registration: The custom element class might be defined but not correctly registered as a dependency within the application or the parent component where it's being used.
Missing Template: The
@customElementdecorator requires atemplateproperty (or relies on an associated.htmlfile by convention). If this is missing or cannot be found, definition retrieval might fail implicitly or lead to related errors.Build/Bundling Issues: Problems during the build process might prevent the decorator metadata from being correctly emitted or associated with the class.
Circular Dependencies: Complex circular dependencies involving the custom element class might interfere with metadata retrieval.
Solution
Apply Decorator: Ensure the class has the
@customElement({ name: 'element-name', template: '...' /* or template */ })decorator applied, specifying the HTML element name and providing a template (either inline, viaimport, or relying on convention).Or relying on convention (e.g.,
my-component.tsandmy-component.html):Use Naming Convention: If relying solely on conventions for the name and template, ensure the class name and
.htmlfile follow the expected patterns (e.g.,MyComponentCustomElementandmy-component.html). Verify conventions are enabled.Register Dependency: Make sure the custom element is registered appropriately, either globally in
main.tsor locally in thedependenciesarray of the parent component using it.Provide Template: Ensure a template is associated with the custom element, either via the
templateproperty in the decorator or a corresponding.htmlfile matching the convention.Check Build Configuration: Verify your build process correctly handles decorators, template loading/importing, and TypeScript/JavaScript compilation. Ensure relevant TSConfig flags are enabled.
Resolve Circular Dependencies: Analyze and refactor any circular dependencies.
Debugging Tips
Verify the
@customElementdecorator is present and correctly configured (especially thenameandtemplateor reliance on conventions).Check the element name provided/inferred matches the usage in the HTML template.
Confirm the element class is imported and included in the
dependenciesarray of the consuming component or registered globally.Ensure the associated template (
.htmlfile or imported string) exists and is accessible to the build process.Inspect the compiled JavaScript output for decorator metadata.
Temporarily replace the custom element usage with standard HTML to rule out other issues.
Last updated
Was this helpful?