Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Property 'registerElement' does not exist on type 'Document'. Did you mean 'createElement'? #30

@VladimirTambovtsev

Description

@VladimirTambovtsev

With typescript starter with create-react-app I got the following error: Property 'registerElement' does not exist on type 'Document'. Did you mean 'createElement'?

const proto = Object.create(HTMLElement.prototype, {
  attachedCallback: {
    value: function () {
      const mountPoint = document.createElement('span')
      const shadowRoot = this.createShadowRoot()
      shadowRoot.appendChild(mountPoint)
      ReactDOM.render(<App />, mountPoint)
      retargetEvents(shadowRoot)
    },
  },
})

document.registerElement('my-custom-element', { prototype: proto })

I know this is a problem with type, but looks like registerElement is deprecated. Should we use window.customElements.define(...)
instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions