[英]tslint: namespace and module are disallowed
I recently got a legacy .ts-file and want to update it. 我最近有一个旧的.ts文件,想要更新它。
Two of the warnings say: 其中两个警告说:
'namespace' and 'module' are disallowed
and 和
The internal 'module' syntax is deprecated, use the 'namespace' keyword instead.
I read about using standardized ES6-style external modules, but I cannot figure out, how to do this. 我读到有关使用标准化ES6样式的外部模块的信息,但我不知道如何执行此操作。
My code looks like the following: 我的代码如下所示:
export namespace MySpace
{
export module MyModule
{
export interface MyInterface
{
}
export class MyClass
{
}
...
}
}
May anyone give me a hint, how to update this structure to actual style rules? 谁能给我一个提示,如何将这种结构更新为实际的样式规则?
thank you all a lot in advance! 提前谢谢大家!
best regards 最好的祝福
mrt 捷运
The internal 'module' syntax is deprecated, use the 'namespace' keyword instead.
内部“模块”语法已被弃用,请改用“名称空间”关键字。
This warning from the linter is about export module MyModule
, because MyModule
is not a module but a namespace. 来自linter的警告是关于
export module MyModule
,因为MyModule
不是模块而是名称空间。 The keyword that should be used is namespace
: export namespace MyModule
. 应该使用的关键字是
namespace
: export namespace MyModule
。
'namespace' and 'module' are disallowed
不允许使用“命名空间”和“模块”
This warning from the linter is about export namespace MySpace
. 来自linter的警告是关于
export namespace MySpace
。 A top-level export
implies the file is a module, and it is a bad practice to use namespaces and modules together . 顶层
export
意味着文件是一个模块,并且将命名空间和模块一起使用是一种不好的做法 。
May anyone give me a hint, how to update this structure to actual style rules?
谁能给我一个提示,如何将这种结构更新为实际的样式规则?
Do not use namespace
at all. 根本不要使用
namespace
。 Here is your code in a module: 这是您在模块中的代码:
export interface MyInterface
{
}
export class MyClass
{
}
// …
See also: an introduction to modules from Mozilla . 另请参阅: Mozilla的模块简介 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.