Skip to content

"Property 'part' does not exist on type 'HTMLAttributes<HTMLDivElement>'." when used as web component with shadow dom #3594

@stevenle

Description

@stevenle
  • Check if updating to the latest Preact version resolves the issue

Describe the bug
A clear and concise description of what the bug is.

I'm using Preact and https://github.com/preactjs/preact-custom-element to define custom elements / web components. Using the part="..." attr throws the following error in vscode:

Property 'part' does not exist on type 'HTMLAttributes<HTMLDivElement>'.

To Reproduce

Sample code:

import register from 'preact-custom-element';
import styles from './styles.css';

export function CustomElement(props) {
  const styles = '...';
  return (
    <>
      <style>{styles}</style>
      <div part="container">
        {props.children}
      </div>
    </>
  );
}

register(CustomElement, 'custom-element', [], {shadow: true});

Expected behavior
What should have happened when following the steps above?

Is it possible to add the "part" attribute to HTMLAttributes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions