Skip to content

Commit 365bfa1

Browse files
committed
chore: Move jsdoc example comment into ts definition where it can be used
1 parent 6e082f0 commit 365bfa1

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

src/index.d.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,34 @@ type Options = {
1515
adoptedStyleSheets?: CSSStyleSheet[];
1616
};
1717

18+
/**
19+
* Register a preact component as web-component.
20+
*
21+
* @example
22+
* ```jsx
23+
* // use custom web-component class
24+
* class PreactWebComponent extends Component {
25+
* static tagName = 'my-web-component';
26+
* render() {
27+
* return <p>Hello world!</p>
28+
* }
29+
* }
30+
*
31+
* register(PreactComponent);
32+
*
33+
* // use a preact component
34+
* function PreactComponent({ prop }) {
35+
* return <p>Hello {prop}!</p>
36+
* }
37+
*
38+
* register(PreactComponent, 'my-component');
39+
* register(PreactComponent, 'my-component', ['prop']);
40+
* register(PreactComponent, 'my-component', ['prop'], {
41+
* shadow: true,
42+
* mode: 'closed'
43+
* });
44+
* ```
45+
*/
1846
export default function register(
1947
Component: AnyComponent,
2048
tagName?: string,

src/index.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,9 @@ import { h, cloneElement, render, hydrate } from 'preact';
44
* @typedef {import('./index.d.ts').PreactCustomElement} PreactCustomElement
55
*/
66

7+
78
/**
8-
* Register a preact component as web-component.
9-
*
109
* @type {import('./index.d.ts').default} Component The preact component to register
11-
*
12-
* @example
13-
* ```jsx
14-
* // use custom web-component class
15-
* class PreactWebComponent extends Component {
16-
* static tagName = 'my-web-component';
17-
* render() {
18-
* return <p>Hello world!</p>
19-
* }
20-
* }
21-
*
22-
* register(PreactComponent);
23-
*
24-
* // use a preact component
25-
* function PreactComponent({ prop }) {
26-
* return <p>Hello {prop}!</p>
27-
* }
28-
*
29-
* register(PreactComponent, 'my-component');
30-
* register(PreactComponent, 'my-component', ['prop']);
31-
* register(PreactComponent, 'my-component', ['prop'], {
32-
* shadow: true,
33-
* mode: 'closed'
34-
* });
35-
* ```
3610
*/
3711
export default function register(Component, tagName, propNames, options) {
3812
function PreactElement() {

0 commit comments

Comments
 (0)