Skip to content

Commit ce4175b

Browse files
committed
Included alternative example to annoate props with anon function
1 parent 3908106 commit ce4175b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,33 @@ export default Vue.extend({
117117
</script>
118118
```
119119

120+
Alternatively, you can also annote your prop types with an anonymous function:
121+
122+
```vue
123+
import Vue from 'vue'
124+
125+
<script lang="ts">
126+
import Vue from "vue";
127+
128+
interface PersonInfo {
129+
firstName: string,
130+
surname: string,
131+
age: number
132+
}
133+
134+
export default Vue.extend({
135+
136+
name: "InfoCard",
137+
props: {
138+
info: {
139+
type: Object as () => PersonInfo,
140+
required: true
141+
}
142+
}
143+
});
144+
</script>
145+
```
146+
120147
## Data Properties (Options API)
121148

122149
You can enforce types on Vue data properties by annotating the return data object:

0 commit comments

Comments
 (0)