我最近有一个旧的 .ts 文件并想更新它。
其中两个警告说:'namespace' and 'module' are disallowed
和The internal 'module' syntax is deprecated, use the 'namespace' keyword instead.
我阅读了有关使用标准化 ES6 样式的外部模块的信息,但我不知道如何做到这一点。
我的代码如下所示:
export namespace MySpace
{
export module MyModule
{
export interface MyInterface
{
}
export class MyClass
{
}
...
}
}
谁能给我一个提示,如何将此结构更新为实际的样式规则?
非常感谢你们!
最好的祝福
捷运
最佳答案
The internal 'module' syntax is deprecated, use the 'namespace' keyword instead.
来自 linter 的这个警告是关于
export module MyModule
, 因为 MyModule
不是模块而是命名空间。应该使用的关键字是namespace
: export namespace MyModule
.'namespace' and 'module' are disallowed
来自 linter 的这个警告是关于
export namespace MySpace
.顶级export
表示文件是一个模块,it is a bad practice to use namespaces and modules together .May anyone give me a hint, how to update this structure to actual style rules?
不要使用
namespace
一点也不。这是您在模块中的代码:export interface MyInterface
{
}
export class MyClass
{
}
// …
另见:an introduction to modules from Mozilla .
关于typescript - tslint:不允许命名空间和模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56059351/