如何在 Typescript 中明确识别全局命名空间中的实体?

How to explicitly identify entities from global namespace in Typescript?

我没有使用 Javascript 的 prototype,而是考虑使用 Typescript 的继承功能。

我想在属于我的 namespace Utilclass String 中添加一些有用的方法。所以这个 String implements 全局 interface String.
如何区分这两者?例如在 C++ 中,我们做类似的事情:

namespace Util
{
  class String : public ::String { ...

通知编译器该接口属于全局 space 的 :: 的 Typescript 等价物是什么?


Add-on Qnclass 继承是 Javascript [=18 的正确选择吗=]?

What is the Typescript equivalent for :: to inform compiler that the interface belongs to the global space?

没有关键字,请求被拒绝:https://github.com/Microsoft/TypeScript/issues/983

您可以创建全局引用以避免名称冲突

type GlobalString = String; 
namespace Util {
  // Use GlobalString
}