Skip to content

Use 'import type' in TypeScript examples #1656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/guide/typescript/composition-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ year.value = '2020'
Sometimes we may need to specify complex types for a ref's inner value. We can do that by using the `Ref` type:

```ts
import { ref, Ref } from 'vue'
import { ref } from 'vue'
import type { Ref } from 'vue'

const year: Ref<string | number> = ref('2020')

Expand Down Expand Up @@ -269,7 +270,8 @@ function handleChange(event: Event) {
Provide and inject are usually performed in separate components. To properly type injected values, Vue provides an `InjectionKey` interface, which is a generic type that extends `Symbol`. It can be used to sync the type of the injected value between the provider and the consumer:

```ts
import { provide, inject, InjectionKey } from 'vue'
import { provide, inject } from 'vue'
import type { InjectionKey } from 'vue'

const key = Symbol() as InjectionKey<string>

Expand Down
6 changes: 4 additions & 2 deletions src/guide/typescript/options-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ However, the runtime `props` options only support using constructor functions as
To annotate complex props types, we can use the `PropType` utility type:

```ts
import { defineComponent, PropType } from 'vue'
import { defineComponent } from 'vue'
import type { PropType } from 'vue'

interface Book {
title: string
Expand Down Expand Up @@ -69,7 +70,8 @@ export default defineComponent({
Because of a [design limitation](https://github.com/microsoft/TypeScript/issues/38845) in TypeScript, you have to be careful when using function values for `validator` and `default` prop options - make sure to use arrow functions:

```ts
import { defineComponent, PropType } from 'vue'
import { defineComponent } from 'vue'
import type { PropType } from 'vue'

interface Book {
title: string
Expand Down