The return type for Wrap is incorrectly typed as HTMLElement. The function returns the class, i.e. the component constructor, and not an actual element, i.e. an instance of that constructor. The return type should be CustomElementConstructor or something more narrow.