如何声明typescript模块以防止;隐式具有';任何';“类型”;错误?

如何声明typescript模块以防止;隐式具有';任何';“类型”;错误?,typescript,Typescript,我正在输入typescript代码中的相对模块: import * as NGLViewer from '../../ngl/build/js/ngl.esm' (位于) 这个模块是用typescript构建的,里面有很多类型,但不管出于什么原因,它都没有模块声明文件。因此,当我导入它时,会出现以下错误: 52:28 Could not find a declaration file for module '../../ngl/build/js/ngl.esm'. '/myproject/ng

我正在输入typescript代码中的相对模块:

import * as NGLViewer from '../../ngl/build/js/ngl.esm'
(位于) 这个模块是用typescript构建的,里面有很多类型,但不管出于什么原因,它都没有模块声明文件。因此,当我导入它时,会出现以下错误:

52:28 Could not find a declaration file for module '../../ngl/build/js/ngl.esm'.
'/myproject/ngl/build/js/ngl.esm.js' implicitly has an 'any' type.
12:16 Ambient module declaration cannot specify relative module name.
所以我想我可以在
modules.d.ts
文件中添加一个环境模块decl:

declare module '../../ngl/build/js/ngl.esm'
但这就产生了这个错误:

52:28 Could not find a declaration file for module '../../ngl/build/js/ngl.esm'.
'/myproject/ngl/build/js/ngl.esm.js' implicitly has an 'any' type.
12:16 Ambient module declaration cannot specify relative module name.

我不想修改“ngl”模块,除此之外,一切正常,所以我只想关闭错误。我的
模块.d.ts
中正确的咒语是什么?或者我导入的是错误的还是什么?

该错误指定模块声明不能有相对的模块名称,例如“../../module\u name”。您是否尝试过使用包管理器(如npm或Thread)将此模块添加到您的代码库中

如果您使用的是包管理器,在.d.ts文件中声明模块的正确方法如下:

declare module "ngl"{
    // properties and their types
}

该错误指定模块声明不能具有相对的模块名称,如“../../module\u name”。您是否尝试过使用包管理器(如npm或Thread)将此模块添加到您的代码库中

如果您使用的是包管理器,在.d.ts文件中声明模块的正确方法如下:

declare module "ngl"{
    // properties and their types
}
谢谢——不过我不能用npm/纱线来包装。我已经通读了文档中的“模块解析”部分,但是我仍然不知道该怎么做。谢谢——不过我不能在这个包中使用npm/Thread。我已经阅读了文档中的“模块解析”部分,但我仍然不知道如何做。