找不到模块“xxx”或其相应的类型声明。

当我在ts文件中定义好interface,在vue文件中引入的时候出现了问题。

文件:type.ts

export interface IOption {
  label: string;
  value: string | number;
}

vue文件:

import { IOption } from '@/config/type'; //找不到模块“@/config/type”或其相应的类型声明

tsconfig.json

{
  "compilerOptions": {
    "sourceMap": true,
    "strict": true,
    // "noImplicitAny": true,
    "module": "esnext",
    "target": "es6",
    "moduleResolution": "Node",
    "baseUrl": ".",
    "paths": {
      "/@/*": ["src/*"]
    },
    "lib": ["esnext", "dom"],
    "esModuleInterop": true,
    "plugins": [{ "name": "@vuedx/typescript-plugin-vue" }],
    "suppressImplicitAnyIndexErrors": true,
    "skipLibCheck": true
  },
  "include": ["**/*.ts", "**/*.d.ts", "**/*.vue"],
  "exclude": ["node_modules"],
  "vueCompilerOptions": {
    "experimentalDisableTemplateSupport": true
  }
}
阅读 11.9k
2 个回答
"paths": {
  "@/*": ["src/*"]
},

评论中的 * 展示不出来

没记错的话,应该用 import type { } from 'module'

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题