You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vue can infer the type of your `ref`'s but if you need to represent some more complex types you can do so with generics:
39
+
40
+
```ts
41
+
import {ref} from"vue"
42
+
43
+
interfacePersonInfo {
44
+
firstName:string,
45
+
surname:string,
46
+
age:number
47
+
}
48
+
49
+
const people =ref<PersonInfo[]>([])
50
+
51
+
```
52
+
53
+
Alternatively you can use casting with `as`. This should be used if the type is unknown. Consider this example where we create a composition wrapper function around `fetch` and we dont know the data structure that will be returned.
54
+
55
+
```ts
56
+
57
+
import { ref, Ref } from"vue";
58
+
59
+
typeApiRequest= () =>Promise<void>;
60
+
61
+
// When using this function we can supply the type via generics
0 commit comments