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

问题描述 投票:0回答:1

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

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

import { Anything } from 'untypedexternalmodule';
typescript es6-modules typescript-definitions
1个回答
0
投票

是。只需将global.d.ts文件添加到包含的项目中即可

declare module 'untypedexternalmodule';

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

© www.soinside.com 2019 - 2024. All rights reserved.