Skip to content

Commit 0f51a46

Browse files
committed
chore: Move jsdoc example comment into ts definition where it can be used
1 parent 6728e58 commit 0f51a46

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
@@ -14,6 +14,34 @@ type Options = {
1414
mode: 'open' | 'closed';
1515
};
1616

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