Typescript一直显示警告找不到模块xxx?

问题描述 投票:0回答:1

我不知道为什么我一直收到这个警告,尽管一切正常

关于 nuxi 生成的 tsconfig.json:

    // Generated by nuxi
{
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "jsx": "preserve",
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "Node",
    "skipLibCheck": true,
    "strict": true,
    "allowJs": true,
    "noEmit": true,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "types": [
      "node"
    ],
    "baseUrl": "..",
    "paths": {
      "~": [
        "."
      ],
      "~/*": [
        "./*"
      ],
      "@": [
        "."
      ],
      "@/*": [
        "./*"
      ],
      "~~": [
        "."
      ],
      "~~/*": [
        "./*"
      ],
      "@@": [
        "."
      ],
      "@@/*": [
        "./*"
      ],
      "assets": [
        "assets"
      ],
      "assets/*": [
        "assets/*"
      ],
      "public": [
        "public"
      ],
      "public/*": [
        "public/*"
      ],
      "#app": [
        "node_modules/nuxt/dist/app"
      ],
      "#app/*": [
        "node_modules/nuxt/dist/app/*"
      ],
      "vue-demi": [
        "node_modules/nuxt/dist/app/compat/vue-demi"
      ],
      "pinia": [
        "node_modules/pinia/dist/pinia"
      ],
      "#imports": [
        ".nuxt/imports"
      ],
      "#build": [
        ".nuxt"
      ],
      "#build/*": [
        ".nuxt/*"
      ],
      "#components": [
        ".nuxt/components"
      ]
    }
  },
  "include": [
    "./nuxt.d.ts",
    "../**/*"
  ],
  "exclude": [
    "../dist",
    "../.output"
  ]
}
typescript vue.js nuxt.js
1个回答
0
投票

我通过向 nuxt 添加类型定义找到了部分答案

tsconfig.json

    {
  // https://nuxt.com/docs/guide/concepts/typescript
  "extends": "./.nuxt/tsconfig.json",
  "files": ["./types/graphql.d.ts"]
}

graphql.d.ts

declare module '*.gql' {
    import { DocumentNode } from 'graphql'
    const Schema: DocumentNode
  
    export = Schema
  }
© www.soinside.com 2019 - 2024. All rights reserved.