Skip to content

Commit 8eaf11b

Browse files
docs: add an example of using defineComponent in a single-file component (#862)
1 parent eb244fd commit 8eaf11b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/guide/typescript-support.md

+12
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ const Component = defineComponent({
102102
})
103103
```
104104

105+
If you're using [single-file components](/guide/single-file-component.html) then this would typically be written as:
106+
107+
```vue
108+
<script lang="ts">
109+
import { defineComponent } from 'vue'
110+
111+
export default defineComponent({
112+
// type inference enabled
113+
})
114+
</script>
115+
```
116+
105117
## Using with Options API
106118

107119
TypeScript should be able to infer most of the types without defining types explicitly. For example, if you have a component with a number `count` property, you will have an error if you try to call a string-specific method on it:

0 commit comments

Comments
 (0)