[英]Angular how to read an excel file from an assets folder using typeScript
[英]TypeScript Declaration File not read while its folder is in typeRoots
在 typescript (Angular 9) 项目中,我正在尝试导入私有 JS 库。
当我使用import { myMethod } from 'my-private-repo/dist/util';
我收到以下错误:
Could not find a declaration file for module 'my-private-repo/dist@types/util'. 'my-private-repo/dist/util.js' implicitly has an 'any' type.
Try `npm install @types/my-private-repo` if it exists or add a new declaration (.d.ts) file containing `declare module 'my-private-repo/dist/util';`
我试图解决在类型文件夹中添加具有以下内容的声明文件的问题: declare module "my-private-repo/dist/util";
typings
,甚至使用declare module "*";
但错误没有改变,就像我的声明文件根本没有被读取,而我更改了我的 ts 配置以包含它:
{
...
"compilerOptions": {
...
"noImplicitAny": true,
...
"typeRoots": [
"./typings",
"./node_modules/@types"
]
}
}
我不明白为什么我的声明文件无法识别。
你有什么主意吗?
谢谢:)
您需要在以下路径之一中添加声明文件:
'my-private-repo/dist/util.d.ts'
'my-private-repo/dist/package.json'
(并指定“类型”属性)
'my-private-repo/dist/@types/util.d.ts'
了解如何 typescript 加载模块: https://www.typescriptlang.org/docs/handbook/module-resolution.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.