Typescript NUXT -PHPSTORM- VUE SFC模板中缺少定义
目前,我正在研究一个小型口袋妖怪API项目,以学习VUE2/Typescript/NUXT。它以Plain Vue App的速度开始,集成 Vue-Class-Component
,然后用Typescript(Nuxt-typescript模块)迁移到NUXT。
课程组件内部一切正常:例如,我获得了 this的类型提示。 ;模板>
标记我的phpstorm不再识别它们。
另一方面,我获得了组件属性的代码完成以及一些默认的VUE方法。
这是我的tsconfig.json和package.json:
{
"compilerOptions": {
"target": "ES2018",
"module": "ESNext",
"moduleResolution": "Node",
"lib": [
"ESNext",
"ESNext.AsyncIterable",
"DOM"
],
"jsx": "preserve",
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@types/lodash",
"@nuxt/types",
"@nuxt/i18n",
"@nuxtjs/axios",
"@nuxtjs/auth-next",
"@nuxtjs/sentry",
"@nuxtjs/vuetify",
"@nuxtjs/i18n",
"@nuxtjs/proxy",
"vuetify",
]
},
"exclude": [
"node_modules",
".nuxt",
"dist"
]
}
{
"name": "pokemon-vue",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.ts,.vue\" --ignore-path .gitignore .",
"lint:prettier": "prettier --check .",
"lint": "npm run lint:js && npm run lint:prettier",
"lintfix": "prettier --write --list-different . && npm run lint:js -- --fix"
},
"dependencies": {
"@nuxt/typescript-runtime": "^2.1.0",
"@nuxt/webpack": "^2.15.8",
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/i18n": "^7.2.2",
"@nuxtjs/pwa": "^3.3.5",
"core-js": "^3.19.3",
"lodash": "^4.17.21",
"nuxt": "^2.15.8",
"nuxt-property-decorator": "^2.9.1",
"nuxt-typed-vuex": "^0.3.1",
"pokedex-promise-v2": "^4.0.0",
"vue": "^2.6.14",
"vue-router": "^3.5.4",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"vuetify": "^2.6.1"
},
"devDependencies": {
"@babel/eslint-parser": "^7.16.3",
"@nuxt/types": "^2.15.8",
"@nuxt/typescript-build": "^2.1.0",
"@nuxtjs/eslint-config-typescript": "^8.0.0",
"@nuxtjs/eslint-module": "^3.0.2",
"@nuxtjs/vuetify": "^1.12.3",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-nuxt": "^3.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.2.0",
"prettier": "^2.5.1",
"vue-eslint-parser": "^9.0.2",
"@types/lodash": "^4.14.182"
}
}
我遵循 typescript.nuxtjs ,即使将其添加到我的/types/index.d.d.d.ts
import { CreateElement, VNode } from 'vue'
import 'vue-class-component/hooks'
declare module 'vue/types/vue' {
// Augment component instance type
interface Vue {
render?(createElement: CreateElement): VNode
}
}
// https://typescript.nuxtjs.org/guide/setup/#configuration
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
删除 .idea
文件夹和“重新集结”该项目对phpstorm也无济于事:(
现在我是出于想法如何解决此问题,我为任何提示感到非常高兴。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是IDE中的一个错误,请关注 Web-56522 用于更新
It's a bug in the IDE, please follow WEB-56522 for updates