tslint:不允许命名空间和模块
tslint: namespace and module are disallowed
我最近有一个遗留的 .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
。 top-level 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
{
}
// …
我最近有一个遗留的 .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
。 top-level 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
{
}
// …