Skip to content

Commit 8977bf9

Browse files
NickBollesPooya Parsa
authored andcommitted
docs: add typescript instructions (nuxt-community#264)
1 parent 953ab8c commit 8977bf9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/setup.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,24 @@ module.exports = {
2626
}
2727
}
2828
```
29+
30+
31+
### Typescript setup
32+
33+
Add the types to your "types" array in tsconfig.json after the `@nuxt/vue-app` entry
34+
35+
**tsconfig.json**
36+
37+
```json
38+
{
39+
"compilerOptions": {
40+
"types": [
41+
"@nuxt/vue-app",
42+
"@nuxtjs/axios"
43+
]
44+
}
45+
}
46+
```
47+
> **Why?**
48+
>
49+
> Because of the way nuxt works the `$axios` property on the context has to be merged into the nuxt `Context` interface via [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html). Adding `@nuxtjs/axios` to your types will import the types from the package and make typescript aware of the additions to the `Context` interface.

0 commit comments

Comments
 (0)