如何忽略 VS Code 和 TypeScript 中的 "Could not find a declaration" 错误

How to ignore "Could not find a declaration" error in VS Code and TypeScript

我正在使用 VS Code 使用 Typescript 和 Vue Cli。我在这一行收到 "definition missing warning":

 import { setupCalendar, DatePicker } from "v-calendar";

Could not find a declaration file for module 'v-calendar'.

这个错误确实影响了tsc编译,但是VS Code总是在代码和导航栏显示这个错误

我该怎么做才能消除此错误并恢复我的 "no error" 状态?

PS:v-calendar没有定义,是第三方导入模块

PS: 这是我的"tsconfig.json"

{
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "strictPropertyInitialization": false,
    "strictNullChecks": false,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": ["webpack-env", "mocha", "chai"],
    "paths": {
      "@/*": ["src/*"]
    },
    "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
  },
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
  "exclude": ["node_modules"]
}

Could not find a declaration file for module 'v-calendar'.

使用以下

创建一个文件external.d.ts
declare module 'v-calendar';

更多

Some docs on migration including declaring existing modules