Skip to content

Commit deb3a30

Browse files
committed
docs: update cases
1 parent 9be5fbf commit deb3a30

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

active-rfcs/0000-infer-attrs.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,23 @@ So I propose to pass `attrs` type to the second params of `defineComponent`.
6767
The following blow is the design details.
6868
- `attrs` is inferred to `{ class: unknown; style: unknown }` when the value of the second param is `undefined`
6969
- `attrs` is lower priority than `props`.
70-
70+
- [see for more detail cases](https://github.com/vuejs/core/pull/7444/files)
7171
7272
## `useAttrs<T>`
73-
In the `setup-script`, the generic type of `useAttrs` will compile to the second param of `defineComponent`
73+
In the `setup-script`, the generic type of `useAttrs` will compile to the second param of `defineComponent`.
74+
```ts
75+
export default /*#__PURE__*/_defineComponent({
76+
setup(__props, { expose }) {
77+
expose();
78+
79+
const attrs = useAttrs<{ foo: number }>()
80+
81+
return { attrs, useAttrs, ref }
82+
}
83+
84+
}, { attrs: {} as { foo: number }})"
85+
```
86+
7487

7588

7689
# Unresolved questions

0 commit comments

Comments
 (0)