module - 在 typescript 中封装子命名空间

标签 module typescript encapsulation

我正在从事的项目相当大,由一个主模块组成,我想将其作为 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/

相关文章:

linux - 如何从Linux内核空间获取用户名

javascript - Requirejs、d3 和 nvd3 集成

plugins - Intellij IDEA 看不到插件模块

reactjs - React.FC<T> 和 Function() 之间的 React TypeScript 区别

angular - Angular 中的 @Directive 与 @Component

javascript - 关于 django/javascript 模式以及如何最好地组织/封装的一般查询

ruby-on-rails - 从模块访问 session 变量或 Controller 变量

reactjs - 使用 Yup 和 Formik 自动修剪空白

iphone - 声明私有(private)成员变量

Java 包和类