【发布时间】:2017-10-27 09:23:04
【问题描述】:
我们正在使用带有 VS Code 的 typescript v2.3.2 和 TSLint v4.5.1 来创建 SPA。代码库正在增长,我们需要以某种方式对其进行模块化。
我尝试使用 typescript 模块进行模块化,但在编译应用程序时发现以下 lint 错误。
[tslint] 'namespace' and 'module' are disallowed (no-namespace)
我正在为 linter 使用这个配置:
{
"extends": "tslint:recommended",
"rules": {
"no-var-requires": false,
"no-console": ["error", false],
"max-line-length": [false]
}
}
第 89 行的The recommended rules file 显示了此规则:
"no-namespace": true,
我想知道是否有什么问题,以及遵循不会很快过时的良好做法来模块化 SPA 的最佳方法是什么。
欢迎提供代码示例。非常感谢。
【问题讨论】:
-
使用标准 ES6 模块。 typescriptlang.org/docs/handbook/modules.html
-
如果您想使用可能适合大型代码库的命名空间,请关闭该规则。
标签: typescript module tslint