如何编写 3rd 方模块的打字稿定义,以便它我可以导入任何东西

How to write typescript definition of 3rd party module so that it I can import anything

我有一个没有打字稿定义的第三方库。

我可以编写允许我从该模块导入任何内容的模块声明吗?

import { Anything } from 'untypedexternalmodule';

是的。只需将 global.d.ts 文件添加到包含

的项目
declare module 'untypedexternalmodule';

如果您尝试 运行 您编写的代码,您将获得要求您执行此操作的信息。