【发布时间】:2022-11-08 16:47:13
【问题描述】:
我在 Vue@3.2.38 项目中使用带有 Typescript@4.5.5 的 plotly.js,我通过以下命令安装了它:
npm install plotly.js-dist-min
npm install @types/plotly.js-dist-min
我在带有 Volar 扩展名的 Visual Studio Code 中编写代码。
当我使用动画函数 (https://plotly.com/javascript/animations/) 时,VSCode 在
Plotly.animate()
^^^^^^^^
也就是说
“类型'typeof import(“/WORKSPACE-PATH/node_modules/@types/plotly.js/index”)'上不存在属性'animate'”
这是否意味着 @types/plotly.js-dist-min 不包含“动画”函数的类型?
以及如何解决?
请原谅我糟糕的英语。谢谢你。
目录
dist/ node_modules/ - @types/ - plotly.js/ - lib/ - index.d.ts - LICENSE - package.json - README.md - plotly.js-dist-min/ - index.d.ts - LICENSE - package.json - README.md - others - plotly.js-dist-min - LICENSE - package.json - plotly.min.js - README.md - others public/ - index.html src/ - others .eslintrc.js .gitignore babel.config.js package-lock.json package.json README.md tsconfig.json vue.config.jstsconfig.json
{ "compilerOptions": { "target": "esnext", "module": "esnext", "strict": true, "jsx": "preserve", "moduleResolution": "node", "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "useDefineForClassFields": true, "resolveJsonModule": true, "sourceMap": true, "baseUrl": ".", "types": [ "webpack-env" ], "paths": { "@/*": [ "src/*" ] }, "lib": [ "esnext", "dom", "dom.iterable", "scripthost" ] }, "include": [ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"], "exclude": [ "node_modules" ] }
【问题讨论】:
-
打字的source 字面上是
plotly.js的打字,所以我猜你也需要安装@types/plotly.js。 -
感谢您的评论,但另外安装
@types/plotly.js对我不起作用。 -
我们可以看到您的 TSConfig 和文件夹结构吗?
-
好的,信息已添加到问题中。
标签: typescript plotly.js