【问题标题】:TypeScript class decorator get class nameTypeScript 类装饰器获取类名
【发布时间】:2018-06-21 19:37:31
【问题描述】:

我正在尝试在类装饰器中获取运行时(缩小!)的类的名称。

当我这样做时:

const metadata = Reflect.getMetadata('design:type', target.constructor);

我不确定。我需要知道类名而不是缩小值。我以为 TSC 会写关于班级名称的元数据信息,但我找不到任何证据。

我有

"emitDecoratorMetadata": true, "experimentalDecorators": true,

设置

【问题讨论】:

  • 您找到解决方案了吗?
  • @Richard 不,很遗憾没有。

标签: typescript


【解决方案1】:

您基本上是在寻找 nameof 运算符,但遗憾的是(尚未实现): https://github.com/microsoft/TypeScript/issues/1579

【讨论】:

    猜你喜欢
    • 2020-06-29
    • 1970-01-01
    • 2017-11-15
    • 2011-07-01
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-23
    相关资源
    最近更新 更多