我正在从事的项目相当大,由一个主模块组成,我想将其作为 API 接口(interface),并在其中定义了许多子模块。这是按如下方式完成的:
<Library.ts>
module Library { }
<Core/Core.ts>
module Library.Core {}
子模块通常会跨越多个文件。我遇到的问题是在这种情况下,一个文件不能使用同一子模块中定义的非导出属性,而是在另一个文件中。
有没有什么方法可以使用这些属性,或者如果不能,有什么方法可以防止子模块的全部导出在其父模块中暴露?
最佳答案
Is there any way I can use these properties, or failing that, any way I can prevent the entirety of a sub-module's exports being exposed within its parent module?
没有。您需要从 module Foo
中导出它以供另一个文件中的 module Foo
使用。这同样适用于子模块
关于module - 在 typescript 中封装子命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22693627/