我这样安装了Kepler.g:
npm i kepler.gl它被添加到我的package.json中:
"kepler.gl": "^2.1.2"但是,如果我尝试导入:
import keplerGlReducer from "kepler.gl/reducers";我收到一个错误,
Could not find a declaration file for module 'kepler.gl/reducers'. '/Users/grannyandsmith/web/web-admin/node_modules/kepler.gl/reducers.js' implicitly has an 'any' type.
Try `npm install @types/kepler.gl` if it exists or add a new declaration (.d.ts) file containing `declare module 'kepler.gl/reducers';`ts(7016)我也试过了
npm install @types/kepler.gl但不出所料,它给了我npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fkepler.gl - Not found
我该如何解决这个问题呢?
编辑:
tsconfig文件:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"typeRoots": ["types/global.d.ts"]
},
"include": [
"src"
]
}发布于 2020-04-22 02:44:57
如果类型对于您正在引入的特定库不可用。这里有两个选项。
*d.ts文件,在这个文件中让TS知道,嘿,我知道我在做什么。缺点是你没有可用的类型,自动补全功能也不能工作。@types/index.d.ts (需要让TS知道才能在这里找到类型)
declare module 'kepler.gl/reducers';https://stackoverflow.com/questions/61350728
复制相似问题