- 我们新建了一个纯TS项目,项目名为: demo 。 最开始使用 module.d.ts 设置引入的依赖为any 这个在编写ts项目的时候不会报错
declare module "tim-js-sdk" {
var content: any;
export default content;
}
declare module "tim-upload-plugin" {
var content: any;
export default content;
}
-
但是在 react 项目中,我们引入 demo 依赖发现,发现会ts报错 tim-js-sdk 含有any类型 但是没有声明。让下载@types/tim-js-sdk...
-
解决方法 在demo 项目中引入的那个文件夹 引入 module.d.ts 并将 module.d.ts 改为 module.ts
/// <reference path="../global.ts" />
/// <reference path="../module.ts" />
import TIM from "tim-js-sdk";
// 发送图片、文件等消息需要腾讯云即时通信IM上传插件
import TIMUploadPlugin from "tim-upload-plugin";