Skip to content

Commit

Permalink
Update docs on usage of external types in defineProps (#2600)
Browse files Browse the repository at this point in the history
* Update composition-api.md

Add documentation for when types for `defineProps` are coming from an external file

* Update composition-api.md

* Update composition-api.md
  • Loading branch information
franklin-tina committed Dec 14, 2023
1 parent 7d08ac3 commit 4cbc64e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/guide/typescript/composition-api.md
Expand Up @@ -50,6 +50,16 @@ const props = defineProps<Props>()
</script>
```

This also works if `Props` is imported from an external source. This feature requires TypeScript to be a peer dependency of Vue.

```vue
<script setup lang="ts">
import type { Props } from './foo'
const props = defineProps<Props>()
</script>
```

#### Syntax Limitations {#syntax-limitations}

In version 3.2 and below, the generic type parameter for `defineProps()` were limited to a type literal or a reference to a local interface.
Expand Down

0 comments on commit 4cbc64e

Please sign in to comment.