1 year ago
#373807
metsys
Nuxt Typescript tsconfig types not working
Trying to migrate Nuxt project from JS to TS. Working in VS Code with Vetur plugin enabled.
Project works well, but I can't setup global variables hionts with tsconfig.json types field.
So here is tsconfig.json file:
"compilerOptions": {
"strictPropertyInitialization": false,
"target": "ES2018",
"module": "ESNext",
"moduleResolution": "Node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": ["./*"],
"@/*": ["./*"]
},
"types": [
"@nuxt/types",
"@types/node",
"@nuxtjs/axios",
"@nuxtjs/toast",
"@nuxtjs/i18n",
"vue-js-modal",
"vue-meta",
"vue-router",
"nuxt-i18n"
]
},
"exclude": [
"node_modules",
".nuxt",
"dist"
],
"include": [
"**/*.ts",
"**/*.vue",
"vue-shim.d.ts"
]
}
and here is component:
<script lang='ts'>
import { Zlaggable } from '@/types/zlaggables/Zlaggable'
import { Component, mixins } from 'nuxt-property-decorator'
import UtilMixin from '@/assets/ts/UtilMixin'
@Component({
name: 'ZlaggableHeaderCopyComponent'
})
export default class ZlaggableHeaderCopy extends mixins(UtilMixin) {
mounted() : void {
this.$toast.success("jj")
}
...
Instead of methods and property suggestions on $toast I have an error like on the image. The $toast actually works, but the declaration of types in tsconfig.json just do nothing or I did some setup mistake
typescript
types
nuxt.js
tsconfig
0 Answers
Your Answer