Skip to content

Commit 0b4ddb6

Browse files
committed
docs: update defineCustomElement
1 parent deb3a30 commit 0b4ddb6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

active-rfcs/0000-infer-attrs.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ I already published an npm package named [vue-ts-utils](https://github.com/rudy-
1010

1111
# Basic example
1212

13-
## Using `defineComponent` directly
13+
## Using `defineComponent`
1414
[TS Playground](https://www.typescriptlang.org/play?jsx=1#code/JYWwDg9gTgLgBAbzgEwKYDNgDtUGELgQ5bwC+c6UBcA5AG4CuqAtDAM7MMzAA2bNAWABQwgMZE28fODgBeFBmx4CkYjAAUCYXDhgqYNgC5E2nRQgRjAZRhRsAcwA0p0s6E6oqLGijqAlIikwq6IcACGMLZGgeFsoQBGYVDGWAwg8ahQcOSkfsJiEvDiMvIAPNJg5hCyCDQAjDTkiVA1deQA9AB8wkA)
1515
```tsx
1616
const Comp = defineComponent({
@@ -48,6 +48,21 @@ return { attrs, useAttrs, ref }
4848
4949
</details>
5050
51+
52+
## Using `defineCustomElement`
53+
```tsx
54+
const Comp = defineCustomElement({
55+
props: {
56+
foo: String
57+
},
58+
render() {
59+
// number
60+
console.log(this.$attrs.bar)
61+
}
62+
}, { attrs: {} as { bar: number } })
63+
64+
```
65+
5166
# Motivation
5267
This proposal is mainly to infer `attrs` using `defineComponent`.
5368
@@ -84,6 +99,8 @@ return { attrs, useAttrs, ref }
8499
}, { attrs: {} as { foo: number }})"
85100
```
86101

102+
## `defineCustomElement`
103+
The type inferrence of `defineCustomElement` is the same as `defineComponent`.
87104

88105

89106
# Unresolved questions

0 commit comments

Comments
 (0)